(注意:在安装过程中,软件版本要严格按照本文中的安装)
1.在docker中安装mysql5.6
docker run -p 4306:3306 --name mysql5 -v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs -v $PWD/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.6
2.进入mysql docker exec -it mysql bash
mysql -u root -p
创建用户:
CREATE DATABASE sonar DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'sonar' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';
FLUSH PRIVILEGES;
3.JDK版本8
4.下载sonarqube7.3 ,解压后,进入解压目录配置
先配置环境变量
sudo vim /etc/profile
export SONAR_HOME=/usr/local/sonarqube-7.3
export PATH=$PATH:$SONAR_HOME/bin
使环境变量生效
source /etc/profile
再配置conf文件夹中的sonar
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:mysql://localhost:4306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
sonar.jdbc.driverClassName:com.mysql.jdbc.Driver
sonar.web.host=192.168.1.7
sonar.web.context=/sonar
sonar.web.port=9000
运行sonarqube,进入bin目录,选择相应的系统
./sonar.sh start
5.在浏览器中访问
192.168.0.4:10090/sonar
由于是在内网中搭建的sonar,故通过端口映射,将路由的10090端口映射到内网服务器的9000.
./sonar.sh restart 为重启指令
6.错误排查
如果网页不能显示,需要进入到sonar中的logs目录中,查看相应问题,注意,web的日志是叠加的,故在每次运行之前可以删除web日志文件。