How to install sonarqube on CentOS7

来自koorka知识分享
跳转至: 导航搜索
  • Download SonarQube

https://www.sonarqube.org/downloads/ unzip the package to /opt/data/sonarqube

  • Edit config file conf/sonar.properties
sonar.web.javaOpts=-server -Xmx768m -XX:MaxPermSize=160m -XX:+HeapDumpOnOutOfMemoryError

sonar.jdbc.username=sonar
sonar.jdbc.password=sonarpassword

sonar.jdbc.url=jdbc:mysql://mysql.yfq.com:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance

sonar.web.port=8084
If your java did not in your PATH, please edit conf/wrapper.conf, change the java command option:
wrapper.java.command=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.131-2.6.9.0.el7_3.x86_64/jre/bin/java
  • Create Database and database access user
CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_bin;

CREATE USER 'sonar'@'%' IDENTIFIED BY 'sonarpassword';

GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX on sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonarpassword';
flush privileges;
  • Running SonarQube as a Service on CentOS7
vim /etc/systemd/system/sonarqube.service :
[Unit]
Description=SonarQube system (www.sonarsource.org)
Documentation=https://docs.sonarqube.org/display/SONAR/Documentation 
Wants=local-fs.target network.target
After=local-fs.target network.target

[Install]
WantedBy=multi-user.target

[Service]
Type=simple
User=jenkins
Group=jenkins
WorkingDirectory=/opt/data/sonarqube

ExecStart=/opt/data/sonarqube/bin/linux-x86-64/sonar.sh
KillMode=process
Restart=on-success
PrivateTmp=true
StandardOutput=syslog
chown jenkins.jenkins -R sonarqube
  • Setting sonarqube

When you installed the sonarqube, you can use the default user login to sonarqube. The default username/password:

admin / admin