1.环境准备
jdk1.8+
yum search java|grep jdk
yum install java-1.8.0-openjdk
mysql 参考菜鸟教程
更改mysql 端口号 /etc/my.cnf 添加port= 新端口号
maven 参考我另一篇博客
2.下载安装
2.1下载安装包( /opt/sonar 我的路径)
wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-7.5.zip
解压即可
unzip sonarqube-7.5.zip
2.2 创建sonar用户并设置密码
useradd sonar
userpwd sonar
2.3 赋权
sudo chown -R sonar.sonar /opt/sonar/sonarqube-7.5
2.4 更改端口号(可选)
/opt/sonar/sonarqube-7.5/conf/sonar.properties
添加
sonar.web.port=9900
2.4 mysql 创建sonar用户
mysql> CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql> CREATE USER 'sonar' IDENTIFIED BY 'sonar';
mysql> GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar';
mysql> GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';
mysql> FLUSH PRIVILEGES;
2.5 修改配置文件,添加连接mysql配置
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
3.使用sonar用户启动
划重点,启动sonar 时一定要使用sonar用户启动,否则es会报错
cd /opt/sonar/sonarqube-7.5/bin/linux-x86-64
sh sonar.sh start
4.访问sonar首页
http://IP:端口号 即可
汉化包,下载到 /opt/sonar/sonarqube-7.5/extensions/plugins 重启服务即可
wget https://github.com/SonarQubeCommunity/sonar-l10n-zh/releases/download/sonar-l10n-zh-plugin-1.25/sonar-l10n-zh-plugin-1.25.jar