Saturday, July 30, 2022

How to Install Sonar-Qube on Ubuntu-18.0.4 Operating System

 Pre-requisite's to install Sonar-Qube 

  • Operating System Ubuntu-18.0.4 with 2 Core-CPU & 4 GB-RAM  
  • Here demo purpose installing Sonar-Qube Software 7.5Version only
  • Install Open JDK Java-version-8
  • Data Base Configured My-Sql
  • Cloud Technology AWS Using 
👉Reference: 


Lets Start Process & Steps to be followed like Shown below

  • Login to Server Ubuntu-18.0.4
  • Next switch to Root User by this command sudo -i
  • Adding Sonar-Qube user to server by this command adduser --system --no-create-home --group --disabled-login sonarqube
  • Create one Sonar-Qube Directory under opt by this command  mkdir /opt/sonarqube
  • Next Move to Sonarqube directory  cd /opt/sonarqube
  • Install wget tool to install the software's in ubuntu apt install wget -y
  • Install unzip tool open the software which using wget apt install unzip  -y
  • Next Install Sonar-Qube Software from official documentation provided by Sonar-Qube https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-7.5.zip
  • Next Unzip sonarqube software which installed from official documentation unzip sonarqube-7.5.zip
  • Once the files extract, delete the downloaded zip file, those files are no longer needed rm sonarqube-7.5.zip

  • Change the ownership for sonarqube software to access the sonarqube user chown -R sonarqube: sonarqube /opt/sonarqube 
  • After that update the server sudo apt update -y
  • Now to install open jdk java search for java  sudo apt search Openjdk

  • Next install java 8 version sudo apt-get install openjdk-8-jdk -y

  • we can also set updated versions of java using sudo update-alternatives --config java

  • Check the java version java -version

  • Now install the My-Sql data base sudo apt-get install mysql-server -y
  • check the status of the data base running successfully or not sudo systemctl status mysql
  • Now exit or logout from current user
  • then login as a data base user sudo mysql -u root -p
  • Then create the SonarQube database: CREATE DATABASE sonarqube;

    Now create the credentials that SonarQube will use to access the database CREATE USER sonarqube@'localhost' IDENTIFIED BY 'some_secure_password';

    Then grant permissions so that the newly created user can make changes to the SonarQube database: GRANT ALL ON sonarqube.* to sonarqube@'localhost';

    Then apply the permission changes and exit the MySQL console: FLUSH PRIVILEGES;

    EXIT; 
  • After that login as a root user by sudo -i and switch to opt directory cd /opt
  • Next edit the sonarqube config file and add the sonarqube credentials vi  sonarqube-7.5/conf/sonar.properties

  • sonar.jdbc.username=sonarqube

    sonar.jdbc.password= password

     sonar.jdbc.url=jdbc:mysql://localhost:3306/sonarqube?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxerformance&useSSL=false

    sonar.web.javaAdditionalOpts=-server

    sonar.web.host=0.0.0.0

    sonar.web.port=9000

  • NextCreate SONARQUBE service file to Add the following content to the file which specifies how the SonarQube service will start and stop vi   /etc/systemd/system/sonarqube.service      [Unit]

    Description=SonarQube service

    After=syslog.target network.target

    [Service]

    Type=forking

    ExecStart=/opt/sonarqube/sonarqube-7.5/bin/linux-x86-64/sonar.sh start

    ExecStop=/opt/sonarqube/sonarqube-7.5/bin/linux-x86-64/sonar.sh stop

    User=sonarqube

    Group=sonarqube

    Restart=always

    [Install]

    WantedBy=multi-user.target

  • Start sonarqube with Norml or any other user which has sudo access sudo systemctl restart sonarqube

  • Then Check the Status of the Sonarqube sudo systemctl status sonarqube



  • Note: 

    ü open Sonarqube Port- 9000 from aws console in Security Groups under Edit Inbound Rules Add Port number 9000.

    ü Then Like shown Below Copy Paste on browser you can Access The sonar from browser

    ü    http://Public IP sonarqube installed server:9000     Ex: [172.13.25.1:9000]



  • Are You Interested To Learn DevOps Book Your Slot Today
    Trainer: Subhan Shaik
    Contact: +91- 7995165865


No comments:

Post a Comment