Sonar Platform Setup
Install sonar Environment
Uncompress
Unzip sonarqube-5.6.4.zip-d/usr/local/src/
unzip sonar-scanner-2.6.1.zip-d
add environment variables
export path= "/LETV/REDIS-2.8.17/SRC: $SONAR _home: $SONAR _runner_home/bin: $MAVEN _home/bin: $PATH"
Export sonar_home=/usr/local/src/sonarqube-5.6.4/bin/linux-x86-64
Export sonar_runner_home=/usr/local/src/ SONAR-SCANNER-2.6.1/
Export maven_home=/usr/local/src/apache-maven-3.3.9
Install the database and configure >sonar also need to install MySQL database (more than 5.6)
This group DBA has been installed to see if it fits well
Install this yourself. This is 5.6, the group database version is not supported.
# RPM-IVH https://mirror.tuna.tsinghua.edu.cn/mysql/yum/mysql57-community-el6/ mysql-community-release-el6-7.noarch.rpm
#yum Install mysql-server-y
#/etc/init.d/mysqld start
#mysql
CREATE DATABASE sonar CHARACTER SET UTF8 COLLATE utf8_general_ci;
GRANT all on sonar.* to ' sonar ' @ ' localhost ' identified by ' SONAR@PW ';
GRANT all on sonar.* to ' sonar ' @ '% ' identified by ' SONAR@PW ';
FLUSH privileges;
Take care of
Sonar.jdbc.username=sonar
sonar.jdbc.password=******
sonar.jdbc.url=jdbc:mysql://localhost. : 3306/sonar?useunicode=true&characterencoding=utf8&rewritebatchedstatements=true&useconfigs= Maxperformance
sonar.web.host=0.0.0.0
sonar.web.port=9000
Before testing the environment for some pits
1, mysql5.7 need to use complex passwords (not recommended), and modify the password method as follows
first modify VIM/ETC/MY.CNF
#skip-grant-tables
and then try the
update Mysql.user Set Authentication_string=password (' Keynzh0ok5puioix ') where user= ' root ';
ALTER USER ' root ' @ ' localhost ' identified by ' Dwlrdko4ateo^wzh ';
Then cancel #skip-grant-tables restart
mysqld, and then create the sonar library before you can.
2, modify the JDBC Connection pool
/usr/local/sonar/conf/sonar.properties
Sonar.jdbc.username=sonar
Sonar.jdbc.password=dwlrdko4ateo^wzh
Sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useunicode=true &characterencoding=utf8&rewritebatchedstatements=true&useconfigs=maxperformance
3, JDK version must be more than 1.8 or throw abnormal
/usr/local/sonar/logs/sonar.log
Come here to test the group MySQL
Mysql-h 10.149.14.242-p3927-u sonar_w-p *******
/usr/local/src/sonarqube-5.6.4/conf
Modify the configuration file as follows
Sonar.jdbc.username=sonar_w
sonar.jdbc.password=nji2ogexo7ti4ndu1
sonar.jdbc.url=jdbc:mysql:// 10.149.14.242:3927/sonar?useunicode=true&characterencoding=utf8&rewritebatchedstatements=true& Useconfigs=maxperformance
sonar.web.host=0.0.0.0
sonar.web.port=9000
Start sonar
Source/etc/profile
sonar.sh Start
Check the log to find the linked database error
Tail-f/usr/local/src/sonarqube-5.6.4/logs/sonar.log
2017.01.23 17:58:21 ERROR web[o.a.c.c.c.[.[. [/]] Exception sending context initialized event to listener instance of class Org.sonar.server.platform.PlatformServletContextListener
org.sonar.api.utils.MessageException:Unsupported MySQL version:5.5. Minimal supported version is 5.6.
To view the MySQL version, does not meet the 5.6 requirements
mysql> status
--------------
mysql Ver 14.14 distrib 5.1.73, for Redhat-linux-gnu (x86_64) using ReadLine 5.1
Connection ID: 354 current
database: Current
User: sonar_w@10.127.96.124
SSL: Not in use
Current Pager: stdout
using outfile: '
using delimiter: ;
Server version: 5.5.5-10.0.14-mariadb-log Source distribution
Protocol version:
Connection: 10.149.14.242 via TCP/IP
Server characterset: UTF8
Db characterset: UTF8
Client characterset: UTF8
Conn. CharacterSet: UTF8
TCP port: 3927
Uptime: 7 hours min sec
threads:2 questions:5224 Slow queries:0 opens:0 Flush tables:1 Open tables:63 queries per second avg: 0.195
--------------
IE input http://10.127.96.124:9000/See if you can access this process is about 10 minutes, the default username and password are admin, the installation is over I have to create a new user to give admin permissions, Once was a teammate Pit Admin permissions have been deleted. The English interface is not very friendly, the following he han.
Cd/usr/local/src/sonarqube-5.6.4/extensions/plugins
/usr/local/src/sonarqube-5.6.4/bin/linux-x86-64/ sonar.sh restart
I just wrote a startup script to share.
#!/bin/sh
#
RC file for sonarqube
#
chkconfig:345 #
Description:sonarqube System (Www.sona rsource.org)
#
### BEGIN INIT INFO
# provides:sonar
# Required-start: $network
# Required-stop: $ Network
# Default-start:3 4 5
# default-stop:0 1 2 6
# Short-description:sonarqube System (Www.sonarsour ce.org)
# Description:sonarqube System (www.sonarsource.org)
### end INIT INFO
#/usr/bin/sonar $*
/usr/local/src/sonarqube-5.6.4/bin/linux-x86-64/sonar.sh $*
service sonar restart no problem.
power-on Boot
Sonarqube Boot from (Ubuntu, 32-bit):
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
sonarqube boot from (RedHat, CentOS, 64-bit):
#sudo ln-s $SONAR _ Home/bin/linux-x86-64/sonar.sh/usr/bin/sonar
sudo ln-s $SONAR _home/sonar.sh/usr/bin/sonar
sudo chmod 755/ Etc/init.d/sonar
sudo chkconfig--add sonar
Installing the Sonar Plugin
Install scanner plugin > Note This scanner is to be installed on the Jenkins server
# cd/usr/local/src/
# wget https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/ Sonar-scanner-2.6.1.zip
# Unzip sonar-scanner-2.6.1.zip-d/usr/local/
#ln-S/usr/local/sonar-scanner-2.6.1 //usr/local/sonar-scanner
configuration Let the scanner be associated with Sonar
# CD
# cd/usr/local/sonar-scanner/conf/
# grep ' ^[a-z ' Sonar-scanner.properties
sonar.host.url=http://10.0.0.102:9000
sonar.sourceencoding=utf-8
Sonar.jdbc.username=sonar
SONAR.JDBC.PASSWORD=SONAR@PW
sonar.jdbc.url=jdbc:mysql://10.0.0.102:3306/ Sonar?useunicode=true&characterencoding=utf8
Download the test code to test
# CD
# wget Https://github.com/SonarSource/sonar-examples/archive/master.zip #
unzip master.zip
# CD/ Root/sonar-examples-master/projects/languages/php/php-sonar-runner
#/usr/local/sonar-scanner/bin/ Sonar-scanner
Test
[root@gitlab-102 php]# pwd
/root/sonar-examples-master/projects/languages/php
[root@gitlab-102 php]# Cat Php-sonar-runner/sonar-project.properties
# Required metadata
Sonar.projectkey=org.sonarqube: Php-simple-sq-scanner
#项目名称
sonar.projectname=php:: Simple Project:: Sonarqube scanner
#版本号
sonar.projectversion=1.0
# comma-separated paths to directories with sources (required)
#代码目录
SONAR.SOURCES=SRC
#语言格式
# Language
sonar.language=php #
Code
# Encoding of the source files
Sonar.sourceencoding=utf-8
Sonar's token
Configure Sonar
Configure Sonar Scanner
Jenkins directly pull up my previous upload Gitlab code