#鑑於sonar7.9以上版本都不支持mysql。於是選擇了pgsql
1.安裝jdk11,
https://blog.csdn.net/Cookie_1030/article/details/106944551
2.安裝pgsql
#官方推薦安裝方式
yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum install postgresql96-server
/usr/pgsql-9.6/bin/postgresql96-setup initdb
systemctl enable postgresql-9.6
systemctl start postgresql-9.6
#切到postgres用戶
su postgres
#進入psql
psql
#創建用戶sonar,密碼爲sonar123
CREATE USER sonar WITH PASSWORD 'sonar123';
#創建數據庫sonar,且指定所屬爲sonar用戶
CREATE DATABASE sonar WITH OWNER sonar ENCODING 'UTF8';
#賦權
ALTER ROLE sonar CREATEDB;ALTER ROLE sonar SUPERUSER;ALTER ROLE sonar CREATEROLE;
#退出
\q
exit
#編輯pg_hba.conf配置文件
vim /var/lib/pgsql/9.6/data/pg_hba.conf
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
#重啓pgsql
systemctl restart postgresql-9.6
su postgres
psql -U sonar -W
3.安裝sonar
#下載sonar安裝包
cd /opt/
wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-8.3.1.34397.zip
#解壓
unzip sonarqube-8.3.1.34397.zip
#移動到指定目錄
mv sonarqube-8.3.1.34397 /usr/local/sonarqube
#編輯配置文件,和psql連接
cd /usr/local/sonarqube/conf
vim sonar.properties
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar123
sonar.jdbc.url=jdbc:postgresql://localhost/sonar
#啓動sonar (1.必須sonar用戶啓動;2.sonarqube目錄下所有文件均爲sonar權限)
useradd sonar
chown -R sonar.sonar /usr/local/sonarqube/
su sonar
bash /usr/local/sonarqube/bin/linux-x86-64/sonar.sh start