安装jdk
查看相对应jdk版本支持Prerequisitesand overview (sonarqube.org)
创建用户useradd -m sonarqube && echo '0j4tyakIxxxxx' |passwd --stdin sonarqube
下载JDK https://repo.huaweicloud.com/openjdk/
将jdk11的tar解压至/usr/local/下
配置环境变量,
vim /etc/profile
export JAVA_HOME=/usr/local/jdk-11
export CLASSPATH=$JAVA_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin
source /etc/profile
数据库安装并启动postgresql
yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum install -y postgresql13-server
/usr/pgsql-13/bin/postgresql-13-setup initdb
systemctl enable postgresql-13
systemctl start postgresql-13
切换postgres用户:sudo su – postgres
登录postgresql:psql
创建数据库用户:createuser sonar with password 'cduVuemxxxxx';
创建数据库:CREATEDATABASE sonar;
授权:GRANTALL PRIVILEGES ON DATABASE sonar TO sonar;
更新数据库密码
ALTER USER postgres WITH PASSWORD 'TPptvuxxxxxx';
\q 退出
Exit到root更新linux用户postgres密码
passwd postgres
TPptvu3ccccc
解压tar文件
下载地址Download |SonarQube | Sonar (sonarsource.com)
安装的版本为sonar9.8.0
unzip sonarqube-9.8.0.63668.zip
chown -R sonarqube:sonarqube sonarqube-9.8.0.63668
su sonarqube
必须用sonarqube用户去启动sonar
vim/opt/sonar/sonarqube-9.8.0.63668/conf/sonar.properties
sonar.jdbc.username=sonar
sonar.jdbc.password= cduVuemxxxxx
sonar.jdbc.url=jdbc:postgresql://localhost:5432/sonar
sonar.web.host=(本机ip)
sonar.web.port=9000
wq保存
然后exit退到root用户下执行下列的步骤4,
修改vm.max_map_count
echo"vm.max_map_count=262144" >> /etc/sysctl.conf
sysctl -p
修改fs.file-max
echo"fs.file-max = 6553560" >> /etc/sysctl.conf
sysctl -p
修改ulimit
vim/etc/security/limits.d/99-sonarqube.conf
# 增加sonarqube用户大开文件数
sonarqube - nofile 131072
sonarqube - nproc 8192
执行完切换用户 su sonarqube
cd/opt/sonar/sonarqube-9.8.0.63668/bin/linux-x86-64/
./sonar.sh start
web访问http://本机IP:9000
用户名admin
密码admin