Fading Coder

An Old Coder’s Final Dance

You are here: Home > Tech > Content

Offline Installation of PostgreSQL 12 on RHEL 7 for SonarQube

Tech 4

SonarQube 8.3 supports Oracle, SQL Server, and PostgreSQL. For a lightweight, license-free option suitable for isolated environments, PostgreSQL is a practical choice. The following steps outline an offline setup on a RHEL 7 system.

Download RPMs for Offline Install

  • Visit https://www.postgresql.org/download/
  • Select the Red Hat family and navigate to the Direct RPM download section.
  • Choose PostgreSQL 12 for RHEL 7.
  • Download the required packages (e.g., postgresql12-libs, postgresql12, postgresql12-server). Transfer them to the target server.

Install Packages

rpm -ivh postgresql12-libs-12.2-2PGDG.rhel7.x86_64.rpm
rpm -ivh postgresql12-12.2-2PGDG.rhel7.x86_64.rpm
rpm -ivh postgresql12-server-12.2-2PGDG.rhel7.x86_64.rpm

Initialize the Data base Cluster

/usr/pgsql-12/bin/postgresql-12-setup initdb

Enable and Start the Service

systemctl enable postgresql-12
systemctl start postgresql-12

Configure Listen Address and Port

vi /var/lib/pgsql/12/data/postgresql.conf

Update these settings as required:

# *It means to listen to all ip information. You can also use localhost, 127.0.0.1, etc
listen_addresses = '*'
# The default listening port is 5432, which can be changed to another
port = 5432

Allow client hosts in pg_hba.conf (same directory). Example to permit all IPv4 clients using password auth:

host all all 0.0.0.0/0 md5

Apply changes by restarting the service:

systemctl restart postgresql-12

Quick Connectivity Check

If the port was changed (example below uses 5433), verify the TCP listener:

curl 127.0.0.1:5433
curl: (52) Empty reply from server

Set the postgres Superuser Password and Enable Local Password Auth

Switch to the postgres account and connect with psql (include the port if changed):

su - postgres
psql -p 5433

Set a password for the postgres role:

alter user postgres with password 'postgres';

Change local authentication in pg_hba.conf to use password-based auth:

#load all all    peer
local all all   md5
#host all all 127.0.0.1/32 ident
host all all 127.0.0.1/32 md5

Create a Dedicated SonarQube Role

Enter the psql shell (supply the password if prompted):

su - postgres
psql -p 5433

Create the application role:

create user sonar with password 'sonar';

Create and Prepare the SonarQube Database

Create the database:

create database sonar;

Grant permissions to the application role:

grant all privileges on database sonar to sonar;

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.