For this lab, both SELinux and firewalld have been disabled …

Software requirement

Database

We willl use PostgreSQL

Download latest stable PostgreSQL RPM for CentOS 7 :

[root@sonarqube ~]# cd /tmp
[root@sonarqube tmp]# curl -O https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  5460  100  5460    0     0  10677      0 --:--:-- --:--:-- --:--:-- 10664
[root@sonarqube tmp]# file pgdg-centos95-9.5-2.noarch.rpm
pgdg-centos95-9.5-2.noarch.rpm: RPM v3.0 bin i386/x86_64 pgdg-centos95-9.5-2

Install this release :

[root@sonarqube tmp]# rpm -ivh pgdg-centos95-9.5-2.noarch.rpm
warning: pgdg-centos95-9.5-2.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:pgdg-centos95-9.5-2              ################################# [100%]
[root@sonarqube tmp]# cd
[root@sonarqube ~]# yum groups mark convert
[root@sonarqube ~]# yum group list | grep -i postgre
   PostgreSQL Database Server 9.5 PGDG
[root@sonarqube ~]# yum -y group install "PostgreSQL Database Server 9.5 PGDG"
...
...
...
Installed:
  postgresql95.x86_64 0:9.5.1-1PGDG.rhel7                  postgresql95-contrib.x86_64 0:9.5.1-1PGDG.rhel7           postgresql95-libs.x86_64 0:9.5.1-1PGDG.rhel7
  postgresql95-server.x86_64 0:9.5.1-1PGDG.rhel7

Dependency Installed:
  libxslt.x86_64 0:1.1.28-5.el7

Complete!

Create a new PostgreSQL database cluster :

[root@sonarqube ~]# /usr/pgsql-9.5/bin/postgresql95-setup initdb
Initializing database ... OK

Start PostgreSQL :

[root@sonarqube ~]# systemctl list-unit-files | grep -i postgre
postgresql-9.5.service                 disabled
[root@sonarqube ~]# systemctl start postgresql-9.5

Keep it started across reboot :

[root@sonarqube ~]# systemctl enable postgresql-9.5
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-9.5.service to /usr/lib/systemd/system/postgresql-9.5.service.

PostgreSQL works well :

[root@sonarqube /]# su - postgres
Last login: Wed Mar  9 16:00:05 CET 2016 on pts/0
-bash-4.2$ psql
psql (9.5.1)
Type "help" for help.

postgres=# \q

Java

We will install Java 8 SDK

Install “java-1.8.0-openjdk-devel” package :

[root@sonarqube ~]# yum -y install java-1.8.0-openjdk-devel

Java is now installed :

[root@sonarqube ~]# java -version
openjdk version "1.8.0_71"
OpenJDK Runtime Environment (build 1.8.0_71-b15)
OpenJDK 64-Bit Server VM (build 25.71-b15, mixed mode)

Web browser

We will install firefox

Install “firefox” package :

[root@sonarqube ~]# yum -y install firefox

“No machine” utility

We already installed X2Go with Xfce

And firefox is working well :

sonarqubefirefox

 

 

 

 

 

 

 

 

 

SonarQube installation

Installation

Download SonarQube, and copy it to your server :

[root@sonarqube /]# ls -l sonarqube-5.3.zip
-rw-r--r-- 1 root root 111318629 Mar 8 15:31 sonarqube-5.3.zip

Uncompress this archive :

[root@sonarqube /]# unzip sonarqube-5.3.zip

Configuration

Edit the configuration file for PosgreSQL database :

[root@sonarqube linux-x86-64]# egrep "^sonar.jdbc." /sonarqube-5.3/conf/sonar.properties
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:postgresql://localhost/sonar

PosgreSQL configuration

User & database

Logon as “postgres” :

-bash-4.2$ id
uid=26(postgres) gid=26(postgres) groups=26(postgres)

And launch “psql” utility :

-bash-4.2$ psql
psql (9.5.1)
Type "help" for help.

Create PosgreSQL user “sonar” :

postgres=# create user sonar;
CREATE ROLE

Set “create database role” to this PosgreSQL user :

postgres=# alter role sonar with createdb;
ALTER ROLE

Set password (here : ‘sonar’) to this PosgreSQL user :

postgres=# alter user sonar with encrypted password 'sonar';
ALTER ROLE

We can list the PosgreSQL current users :

postgres=# \du
                                   List of roles
 Role name |                         Attributes                         | Member of
-----------+------------------------------------------------------------+-----------
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
 sonar     | Create DB                                                  | {}

Create the database ‘sonar’ :

postgres=# create database sonar owner sonar;
CREATE DATABASE

Give all privileges for this database to the user ‘sonar’ :

postgres=# grant all privileges on database sonar to sonar;
GRANT

We can list the existing databases :

postgres=# \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 sonar     | sonar    | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =Tc/sonar            +
           |          |          |             |             | sonar=CTc/sonar
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
(4 rows)

Don’t forget to set a password (here : ‘password’) to ‘postgres’ PosgreSQL user :

postgres=# alter user postgres password 'password';
ALTER ROLE

We can leave ‘psql’ utility :

postgres=# \q
-bash-4.2$

PosgreSQL authentication

Edit this configuration file :

[root@sonarqube ~]# egrep "^local|^host" /var/lib/pgsql/9.5/data/pg_hba.conf
local   all             all                                     md5
host    all             all             127.0.0.1/32            md5
host    all             all             ::1/128                 md5

And restart PostgreSQL :

[root@sonarqube ~]# systemctl restart postgresql-9.5

Start & stop SonarQube

To start SonarQube :

[root@sonarqube ~]# /sonarqube-5.3/bin/linux-x86-64/sonar.sh start

Is sonarQube up & running ?

[root@sonarqube ~]# /sonarqube-5.3/bin/linux-x86-64/sonar.sh status
SonarQube is running (16076).

We can now open a browser :

sonarqubefirefox1

 

 

 

 

 

 

 

 

 

 

 

To stop SonarQube :

[root@sonarqube ~]# /sonarqube-5.3/bin/linux-x86-64/sonar.sh stop
Stopping SonarQube...
Stopped SonarQube.

Logs with more details ?

Edit SonaQube configuration file :

 

[root@sonarqube ~]# egrep "^sonar.log.level" /sonarqube-5.3/conf/sonar.properties
sonar.log.level=DEBUG

to see logs (default path) :

cat  /sonarqube-5.3/logs/sonar.log

 

 

PDF24 Tools    Send article as PDF   

One thought on “SonarQube 5.3 installation on CentOS 7.2

Leave a Reply

Your email address will not be published. Required fields are marked *


*