1. 程式人生 > >Sonar6.7.1安裝

Sonar6.7.1安裝

1.下載安裝包

從sonar的官方網站下載最新的sonar版本:https://www.sonarqube.org/downloads/
下載一個名字為sonarqube-6.7.1的zip壓縮包,解壓縮到安裝目錄:

unzip sonarqube-6.7.1.zip

2.啟動sonar

進入安裝目錄下的sonarqube-6.7.1/bin/linux-x86-64目錄,執行啟動指令碼:

./sonar.sh start

3.mysql資料庫設定

1.在 MySQL 中建立 sonar 資料庫

CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci; 
grant all privileges on sonar.* to 'sonar'@'%' identified by 'sonar'; 
GRANT ALL ON sonar.* TO ‘sonar’@’localhost’ IDENTIFIED BY ‘sonar’;
flush privileges;

2.將 MySQL 的驅動檔案(如mysql-connector-java-5.1.44-bin.jar)拷貝到 sonarqube-6.7.1/extensions/jdbc-driver/mysql 目錄

3.修改 sonarqube-6.7.1\conf\sonar.properties 檔案,用 # 註釋原來 Derby 的配置項,並開啟 MySQL 資料庫的配置項:

# Comment the following lines to deactivate the default embedded database.
#sonar.jdbc.url: jdbc:derby://localhost:1527/sonar;create=true
#sonar.jdbc.driverClassName: org.apache.derby.jdbc.ClientDriver
#sonar.jdbc.validationQuery: values(1)

~~~~~~~~~~~~~~~省略部分~~~~~~~~~~~~~~~~~~
# The schema must be created first.
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar

#----- MySQL 5.x/6.x
# Comment the embedded database and uncomment the following 
#properties to use MySQL. The validation query is optional.
        sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar
useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
#sonar.jdbc.validationQuery: select 1
sonar.web.host=0.0.0.0
# Web context. When set, it must start with forward slash (for example /sonarqube).
# The default value is root context (empty value).
sonar.web.context=/
# TCP port for incoming HTTP connections. Default value is 9000.
sonar.web.port=9000

4.重啟 Sonar。