Instance should have at least 2 GB RAM. For AWS or Azure cloud, instance should be atleast 2 GB RAM
Install Open JDK 11
Postgres DB Setup
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/
sudo apt-get -y install postgresql postgresql-contrib
Ignore the message in red color below:
sudo systemctl start postgresql
sudo systemctl enable postgresql
sudo su - postgres
9. Switch to sql shell by entering
psql
Execute the below three lines (one by one)
ALTER USER sonar WITH ENCRYPTED password 'password';
CREATE DATABASE sonarqube OWNER sonar;
GRANT ALL PRIVILEGES ON DATABASE sonarqube to sonar;
and then type exit to come out of postgres user.
3. Download SonarQube and Install
sudo apt-get -y install unzip
sudo unzip sonarqube*.zip -d /opt
sudo mv /opt/sonarqube-8.6.0.39681 /opt/sonarqube -v
sudo vi /opt/sonarqube/conf/sonar.prop
uncomment the below lines by removing # and add values highlighted yellow
sonar.jdbc.username=sonar
sonar.jdbc.password=password
sonar.jdbc.url=jdbc:postgresql
Now press escape button, and enter :wq! to come out of the above screen.
Execute the below command:
sudo vi /etc/systemd/system/sonar.serv
add the below code in green color:
[Unit]
Description=SonarQube service
After=syslog.target network.target
[Service]
Type=forking
ExecStart=/opt/sonarqube/bin/l
ExecStop=/opt/sonarqube/bin/li
LimitNOFILE=131072
LimitNPROC=8192
User=sonar
Group=sonarGroup
Restart=always
[Install]
WantedBy=multi-user.target
Add the following lines to the bottom of that file:
vm.max_map_count=262144
fs.file-max=65536
Next, we're going to edit limits.conf. Open that file with the command:
sonar - nofile 65536
sonar - nproc 4096
sudo systemctl status sonar
type q now to come out of this mode.
Now execute the below command to see if Sonarqube is up and running. This may take a few minutes.
tail -f /opt/sonarqube/logs/sonar*.log
Make sure you get the below message that says sonarqube is up..
Now access sonarQube UI by going to browser and enter public dns name with port 9000
https://www.coachdevops.com/2020/04/how-to-integrate-sonarqube-with-jenkins.html