SonarQube server installation in Ubuntu

‘SonarQube Server installation in Ubuntu 22.0’

Installation of SonarQube in the EC2 Ubuntu 20.04 LTS

Prerequisites 

  • Ubuntu 20.04 LTS with t2.medium 
  • https://www.sonarqube.org/trial-request/developer-edition/ (Click on the link, register and download sonarqube-9.7.1.62043) 
  • Open GitBash terminal in local 
  • How to copy sonarqube-9.7.1.62043.zip from local to EC2:
    • download key pair “sonar_qube_key_pair” to your local  
    • chmod 400 sonar_qube_key_pair” 
    • Keep key pair and  sonarqube-9.7.1.62043.zip at same folder or location. 
    • Run command below to copy SonarQube from download to EC2 instance home:  
    • scp -i sonar_qube_key_pair.pem sonarqube-developer-9.7.1.62043.zip ubuntu@ec2-3-215-186-196.compute-1.amazonaws.com:/home/ubuntu 
  • PostgreSQL Version 9.3 or higher 
  • SSH access with sudo privileges 

Port opens: 

TCP: 9000

 TCP: 5432 

TCP: 22:

TCP: 443

Steps followed to configure the SonarQube: 

To Increase the vm.max_map_count kernal ,file discriptor and ulimit for current session at runtime. 

sudo sysctl -w vm.max_map_count=262144 

sudo sysctl -w fs.file-max=65536 

ulimit -n 65536 

Upgrade and update EC2 instance and install Java 11jdk and jre: 

Sudo apt-get upgrade 

Sudo apt-get update 

sudo apt-get install openjdk-11-jdk -y 

sudo apt-get install openjdk-11-jre -y 

Check java version: 

Install and Setup PostgreSQL 10 Database For SonarQube 

sudo apt-get -y install postgresql postgresql-contrib 

sudo systemctl start postgresql  

sudo systemctl enable postgresql 

sudo passwd postgres  

su – postgres 

createuser sonar  

Password: Glob@qw 

Type:psql 

ALTER USER sonar WITH ENCRYPTED password ‘sonar’; 

grant all privileges on DATABASE sonarqube to sonar; 

\q 

exit 

Create a sonar user : 

Password for soanr user: MasterB#456OpLead 

Configure SonarQube 

Copy sonarqube-9.7.1.62043.zip to /opt: and unzip 

sudo unzip sonarqube-9.7.1.62043.zip -d /opt 

sudo mv /opt/sonarqube-9.7.1.62043 /opt/sonarqube 

Give access to the sonar user: 

sudo useradd -c “user to run SonarQube” -d /opt/sonarqube -g sonar sonar 

sudo chown sonar:sonar /opt/sonarqube -R 

sudo vim /opt/sonarqube/conf/sonar.properties 

Update the username and password of database

sudo vim /opt/sonarqube/bin/linux-x86-64/sonar.sh 

sudo su sonar 

cd /opt/sonarqube/bin/linux-x86-64/ 

./sonar.sh start 

Configure Systemd service: 

cd /opt/sonarqube/bin/linux-x86-64/ 

./sonar.sh stop 

sudo vim /etc/systemd/system/sonar.service 

sudo systemctl start sonar 

sudo systemctl enable sonar 

Click on the link below: 

http://3.239.83.182:9000/sessions/new?return_to=%2F 

Username:admin 

Password: Glob@qw 

Solverwp- WordPress Theme and Plugin