sonar安装

本地环境:ubuntu11.4,tomcat 6.0,mysqljava

按照官方文档,sonar有4种安装方式,我在这边介绍怎么安装。mysql

首先下载最新版的sonar,下载地址:http://www.sonarsource.org/downloads/linux

下载完成以后,要注意一个问题,官方的说明是不要安装在以数字开头的目录中。因此咱们就不要解压在数字开头的目录中。web

因为sonar的安装须要数据库,咱们如今mysql中创建一个名叫sonar的数据库。在建立数据库时,建议的字符集是UTF-8。sql

数据库创建完成以后,再在配置文件conf/sonar.properties中修改:数据库

# WEB SETTINGS - STANDALONE MODE ONLY
# These settings are ignored when the war file is deployed to a JEE server.
#---------------------------------------------------------
# Listen host/port and context path (for example / or /sonar). Default values are 0.0.0.0:9000/.
sonar.web.host:                           localhost
sonar.web.port:                           9001
sonar.web.context:                        /apache

(之前没有修改端口,默认端口是9000,有时候会出现别的应用程序会占用这个端口,最好仍是改一下的好)ubuntu

#----- Credentials
# Permissions to create tables and indexes must be granted to JDBC user.
# The schema must be created first.
sonar.jdbc.username:                       tmy
sonar.jdbc.password:                       1
修改数据的用户名和密码,这里是我这边的配置windows

#----- MySQL 5.x/6.x
# Comment the embedded database and uncomment the following line to use MySQL
sonar.jdbc.url:                            jdbc:mysql://localhost:3306/sonar?user=tmy&password=1&useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
 
# Optional properties
sonar.jdbc.driverClassName:                com.mysql.jdbc.Driver
sonar.jdbc.validationQuery:                select 1
 
最后修改配置,将mysql的注释去掉就能够了。tomcat

模式1 - 独立的应用程序启动

进入bin中,选择适合本身系统,运行sonar.sh,若是是windows运行bat。
运行命令:sh sonar.sh start
而后咱们看看日志,logs/sonar.log,能够看到运行状况了,当数据库中表创建完成以后,再进入localhost:9001,就能够进入sonar了。

若是不修改配置,默认的监听端口是9000,默认的上下文路径是/和声纳侦听默认状况下,全部的网络接口:'0 .0.0.0'。一旦启动,声纳Web服务器是可用http://localhost:9000参数能够改变到文件CONF / sonar.properties的“。下面是一个例子来听http://localhost:80/sonar

sonar.web.host: 192.0 0.1
sonar.web.port: 80
sonar.web.context:/sonar

模式2 - JEE服务器的部署

进入war目录,修改文件:sonar-server/WEB-INF/classes/sonar-war.properties

SONAR_HOME=/home/tmy/sonar/sonar-2.14

(设置变量SONAR_HOME为sonar的解压目录,此处必定要修改,否则war包部署到tomcat里面会报错误)

运行build-war.sh(windows 运行bat),就可以自动打出war包了。而后将war包部署到tomcat中去,就能够运行sonar。

注意:

按照官方文档的说明。咱们要在sonar在tomcat中运行须要一个最小堆大小为512MB。加大对Tomcat的内存堆大小,设置启动Tomcat以前CATALINA_OPTS变量

CATALINA_OPTS="-Xmx1024m -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -XX:MaxPermSize=256m"

 

声纳2.2以前,WAR文件必须重建每一个配置更新的时间(新插件或新的扩展)。
从声纳2.2起,WAR文件的的声纳目录(分布在解压缩的目录)。它意味着:

  • 分布在解压缩的目录不能被删除
  • 安装/卸载插件或规则扩展时,有没有必要重建war
  • WAR文件必须部署在主机上,其中包含sonar目录
  • sonar目录被移动时,必须重建WAR文件
  • 配置文件被更新时,必须重建WAR文件(目录的conf /)

    运行Tomcat的用户必须有读写访问声纳主目录(例如Web管理控制台容许插件安装)。

后面还有两种安装方式就在这边再也不详细说明了,也很简单。我把官方文档贴出来

模式3 - 做为一个服务运行在MS Windows

安装/卸载NT服务(可能须要运行这些批处理文件,经过“以管理员身份运行”):

bin/windows-x86- 32 / InstallNTService.bat
bin/windows-x86- 32 / UninstallNTService.bat

启动/中止服务:

bin/windows-x86- 32 / StartNTService.bat
bin/windows-x86- 32 / StopNTService.bat

 

模式4 - 做为一个服务运行在Linux

如下已经过测试在Ubuntu 8.10。

建立文件/ etc / init.d/sonar与此内容:

#! /bin/sh
/usr/bin/sonar $*

在启动时注册声纳:

sudo ln -s $SONAR_HOME/bin/linux-x86- 32 /sonar.sh /usr/bin/sonar
sudo chmod 755 /etc/init.d/sonar
sudo update-rc.d sonar defaults
相关文章
相关标签/搜索