1.安装mysql等参考文档
https://docs.sonarqube.org/latest/setup/operate-server/
2.配置数据库用户名和密码
vi /usr/local/sonarqube-6.7.4/conf/sonar.properties#sonar.jdbc.username=sonar.jdbc.username=root#sonar.jdbc.password=sonar.jdbc.password=yzyx123
3.修改数据库名称
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
4.修改浏览器访问后缀
# Web context. When set, it must start with forward slash (for example /sonarqube).# The default value is root context (empty value).#sonar.web.context=sonar.web.context=/sonar
5.修改浏览器访问端口
# TCP port for incoming HTTP connections. Default value is 9000.#sonar.web.port=9000sonar.web.port=9000
6.修改浏览器访问ip
# Binding IP address. For servers with more than one IP address, this property specifies which# address will be used for listening on the specified ports.# By default, ports will be used on all IP addresses associated with the server.#sonar.web.host=0.0.0.0sonar.web.host=0.0.0.0
7.配置启动用户
useradd sonar
8.授权sonar用户文件夹权限
chown -R sonar:sonar /usr/local/sonarqube-6.7.4/
9.启动sonar
/usr/local/sonarqube-6.7.4/bin/linux-x86-64/sonar.sh start
10.生成token,启动bash接入项目源码
mvn sonar:sonar \ -Dsonar.host.url=http://10.10.95.5:9000/sonar \ -Dsonar.login=15f5ac1cd99943cdc4fc64a5c313d8b14e03f0ff
11.配置开机自启动
vim /etc/systemd/system/sonarqube.service---------------------------------------------[Unit]Description=SonarQube serviceAfter=syslog.target network.target[Service]Type=simpleUser=sonarGroup=sonarPermissionsStartOnly=trueExecStart=/bin/nohup /usr/local/jdk1.8.0_11/bin/java -Xms32m -Xmx32m -Djava.net.preferIPv4Stack=true -jar /usr/local/sonarqube-6.7.6/lib/sonar-application-6.7.6.jarStandardOutput=syslogLimitNOFILE=65536LimitNPROC=8192TimeoutStartSec=5Restart=always[Install]WantedBy=multi-user.target------------------------------------------chmod a+x sonarqube.servicesysytemct enable sonarqube.service