CentOS7 SonarQube安装
Download
Database
设定Postgres数据库
su postgrespsql -U postgresCREATE USER sonar WITH PASSWORD ‘sonar‘;CREATE DATABASE sonar WITH OWNER sonar ENCODING ‘UTF8‘;\q
Install
- 安装
上传ZIP文件到/tmp目录下
mkdir /opt/sonarcd /opt/sonarunzip /tmp/sonarqube-5.0.zipunzip /tmp/sonar-runner-dist-2.4.zip
环境变量
在/etc/profile.d目录下新建sonar.sh
#!/bin/bashSONAR_HOME=/opt/sonar/sonarqube-5.0SONAR_RUNNER_HOME=/opt/sonar/sonar-runner-2.4PATH=$SONAR_RUNNER_HOME/bin:$PATHexport SONAR_HOMEexport SONAR_RUNNER_HOMEexport PATH
并赋予执行权限
chmod +x /etc/profile.d/sonar.shsource /etc/profile.d/sonar.sh
/opt/sonar/sonarqube-5.0/conf/sonar.properties sonar.jdbc.username=sonar sonar.jdbc.password=sonar sonar.jdbc.url=jdbc:postgresql://localhost/sonar sonar.web.context= sonar.web.port=9084 sonar.search.port=9085
/opt/sonar/sonar-runner-2.4/conf/sonar-runner.properties #Configure here general information about the environment, such as SonarQube DB details for example #No information about specific project should appear here
#----- Default SonarQube serversonar.host.url=http://localhost:9084 #----- PostgreSQLsonar.jdbc.url=jdbc:postgresql://localhost/sonar #----- MySQL#sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8 #----- Oracle#sonar.jdbc.url=jdbc:oracle:thin:@localhost/XE #----- Microsoft SQLServer#sonar.jdbc.url=jdbc:jtds:sqlserver://localhost/sonar;SelectMethod=Cursor #----- Global database settingssonar.jdbc.username=sonarsonar.jdbc.password=sonar #----- Default source code encodingsonar.sourceEncoding=UTF-8 #----- Security (when ‘sonar.forceAuthentication‘ is set to ‘true‘)sonar.login=adminsonar.password=admin
新建/etc/init.d/sonar
#!/bin/sh # chkconfig: - 80 20# Description: SONAR /opt/sonar/sonarqube-5.0/bin/linux-x86-64/sonar.sh $*exit $?
赋予执行权限
chmod +x /etc/init.d/sonar
设定开机启动
chkconfig sonar on
- 防火墙
新建文件/usr/lib/firewalld/services/sonar.xml
<?xml version="1.0" encoding="utf-8"?><service> <short>Sonar Qube 5.0 service</short> <description>SonarQube</description> <portprotocol="tcp"port="9084"/></service>
修改防火墙设定
firewall-cmd --permanent --add-service=sonarfirewall-cmd --reload
时间: 2024-12-29 07:28:05