Sonarqube安装文档
1. 环境准备
参照官方文档Prerequisites and Overview | SonarQube Docs
安装符合sonarqube版本的JDK和数据库
目前服务器上JDK版本为11.0.2
sonarqube版本为9.1.0
postgresql版本为13.7
2. 安装JDK11.0.2
将openjdk-11.0.2_linux-x64_bin.tar.gz放到/usr/local/java路径下解压
创建用户sonarUser: useradd sonarUser
切换至sonarUser用户: sudo su – sonarUser
添加用户环境变量:vim ~/.bash_profile
export SONAR_JAVA_PATH=/usr/local/java/jdk-11.0.2/bin/java
PATH=$PATH:$HOME/.local/bin:$HOME/bin:$SONAR_JAVA_PATH
export PATH
source ~/.bash_profile
3. 安装并启动postgresql
# Install the repository RPM:
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# Install PostgreSQL:
sudo yum install -y postgresql13-server
# Optionally initialize the database and enable automatic start:
sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
sudo systemctl enable postgresql-13
sudo systemctl start postgresql-13
切换postgres用户:sudo su – postgres
登录postgresql:psql
创建数据库用户:createuser sonar with password 'sonarP@ssw0rd';
创建数据库:CREATE DATABASE sonar;
授权:GRANT ALL PRIVILEGES ON DATABASE sonar TO sonar;
4. 安装sonarqube
官网下载sonarqube压缩包:https://www.sonarqube.org/downloads/
解压sonarqube-9.1.0.47736.zip至/opt/sonar/目录下
将文件所有者指定为sonarUser
chown -R sonarUser. ./sonarqube-9.1.0.47736
切换sonarUser用户,修改/opt/sonar/sonarqube-9.1.0.47736/conf/sonar.properties 文件
添加以下参数:
sonar.jdbc.username=sonar
sonar.jdbc.password=数据密码
sonar.jdbc.url=jdbc:postgresql://localhost:5432/sonar
sonar.web.host=10.xxx.xx.xx
sonar.web.context=/
启动sonarqube
./bin/linux-x86-64/sonar.sh start
浏览器打开sonarqube
http://localhost:9000