Friday 28 February 2020

SonarQube installation on CentOS

Pre-Requirement: 
Add port forwarding rule to Vagrantfile
config.vm.network "forwarded_port", guest: 9000, host: 9000

Then reload VM with below command
vagrant reload

Follow below instructions to install and configure SonarQube

1) Download the SonarQube software.
cd /opt
sudo wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-7.6.zip

2) Extract sonarqube software
sudo unzip sonarqube-7.6.zip
sudo mv sonarqube-7.6 sonarqube

4) Please change permissions 
cd /opt/
sudo chown -R vagrant:vagrant sonarqube

5) Start Sonar
cd /opt/sonarqube/bin/linux-x86-64
./sonar.sh start

You should able to access SonarQube over 9000 port now. By default admin/admin will be credentials for SonarQube.

If you are using VM or Vagrant please enable port forwarding.




6) Enable Sonar as service on centos 7
Create sonar service file
sudo vi /etc/systemd/system/sonarqube.service

7) Cope below content to above file. If you want to change user to run sonarqube process please update User and Group.

[Unit]
Description=SonarQube service
After=syslog.target network.target

[Service]
Type=simple
User=vagrant
Group=vagrant
PermissionsStartOnly=true
ExecStart=/bin/nohup java -Xms32m -Xmx32m -Djava.net.preferIPv4Stack=true -jar /opt/sonarqube/lib/sonar-application-7.6.jar
StandardOutput=syslog
LimitNOFILE=65536
LimitNPROC=8192
TimeoutStartSec=5
Restart=always

[Install]
WantedBy=multi-user.target


8) Start and Enable Sonar Service
sudo systemctl start sonarqube
sudo systemctl enable sonarqube

9) Check SonarQube status to ensure it is working as expected.
sudo systemctl status  sonarqube



No comments:

Post a Comment