What’s up Guys! Welcome to automationcalling.com

Introduction
SonarQube also formerly known as Sonar which is one of the popular tool in the market for Code Quality and Security. To precise more, it helps to find out Bugs, Vulnerabilities, Code Smells, Duplication for Static Code Analysis and Unit test for Code Coverage. This post is mostly focus on how to install SonarQube Server in CentOS Machine.
Pre-requisites
- CentOS Machine
- Postgress
PostgreSQL Installation
To Install PostgreSQL, for this example I use postgress version 10.
- yum install postgresql10-server postgresql10
- /usr/pgsql-10/bin/postgresql-10-setup initdb
After successful installation, postgress is installed in the following location.
Database | Postgres |
Version | 10.9 |
Installed Location | /usr/pgsql-10/ |
To Verify Version | /usr/pgsql-10/bin/postgres –version |
Postgres Log | /var/lib/pgsql/10/data |
Username/password | <your username> |
Database Name | <Your DB Name> |
Configuration
By Default, postgreSQL doesn’t have credentials. In order to accept credential in postgreSQL, you need to make the following changes in pg_hba.conf
- sudo vi /var/lib/pgsql/data/pg_hba.conf

Start/Stop
To Start/Stop PostgreSQL, Please follow the below commands.
Operation | Commands |
---|---|
Start & Enable | systemctl start postgresql-10.servicesystemctl enable postgresql-10.service |
Stop | systemctl stop postgresql-10.service |
How to Connect PostgreSql
To verify version:
- sudo -i -u postgres
- psql
- \conninfo
To exit from psql mode:
- To exit from psql
- \q
- logout
Sonar Installation
- Download latest version using wget in linux family
- unzip sonarqube-7.9.zip -d /opt
- mv /opt/sonarqube-7.9 /opt/sonarqube
- nano /opt/sonarqube-7.9/conf/sonar.properties
- sonar.jdbc.username=<postgreSqlusername>
- sonar.jdbc.password=<postgreSqlpassword>
- sonar.jdbc.url=jdbc:postgresql://<IP or localhost>/sonar
After successful installation, use the following commands to start/stop server
Start | /opt/sonarqube-7.9/bin/linux-x86-64/sonar.sh start |
Stop | /opt/sonarqube-7.9/bin/linux-x86-64/sonar.sh stop |
Start as Console | /opt/sonarqube-7.9/bin/linux-x86-64/sonar.sh console |
Note: In case sonar is not getting started, please troubleshoot on the following areas
- Make sure you start sonar in test login (sonar doesn’t accept root login)
- Make sure you give full access to /opt/sonarqube-7.9/temp
After successful start the server, log onto the SonarQube Server http://localhost:9000. The Sonar console page gets opened.
Sonar Project Configuration
Each project required a token, you can either use same token or create independent token for each project.

Debugging and Trouble Shooting
- Sonar uses elastic search which expect minimum no of files /etc/sysctl.conf is 262144. Hence. please set value like this vm.max_map_count=262144
- SonarQube shouldn’t allow to start as root user.
- Make sure necessary permission is assigned for folders and its sub folders.
Leave a Reply