PostgreSQL 17 Installation on RHEL 9 / Oracle Linux 9
Introduction: Why PostgreSQL?
When you work with databases in real production environments not just labs you quickly learn that stability, predictability, and data integrity matter more than trends. That’s exactly why PostgreSQL has earned its reputation.
PostgreSQL is:
- Fully ACID compliant
- Battle-tested for decades
- Designed around MVCC for concurrency
- Rich in features like JSONB, indexing strategies, partitioning, replication, and extensions
It is trusted by startups, fintech systems, analytics platforms, SaaS companies, and even large enterprises that demand correctness and performance.
PostgreSQL 17 continues to improve performance, logical replication, and overall efficiency making it an excellent choice for modern deployments.
Installation Overview – What We Are About to Do
Before jumping into commands, it’s important to understand the installation process conceptually.
Installing PostgreSQL on Red Hat Enterprise Linux 9 or Oracle Linux 9 is not just about running one install command.
A proper installation involves:
- Adding the official PostgreSQL repository (to get the latest supported version).
- Installing the PostgreSQL 17 server packages.
- Initializing the database cluster (this creates the actual database structure).
- Enabling and starting the PostgreSQL service.
- Verifying that everything is running correctly.
In this guide, we’ll go through each step of the PostgreSQL installation carefully.
Step 1: Install PostgreSQL Official Repository
Why this step is required?
RHEL 9 / Oracle Linux 9 come with their own PostgreSQL versions in default repositories.
But those versions are usually older.
We want PostgreSQL 17, so we must add the official PostgreSQL (PGDG) repository.
Run this command:
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm
or (same thing using yum):
yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm
Sample Output
[root@dbadiscovery ~]# yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm
Oracle Linux 9 BaseOS Latest (x86_64) 52 kB/s | 4.3 kB 00:00
Oracle Linux 9 BaseOS Latest (x86_64) 22 MB/s | 111 MB 00:04
Oracle Linux 9 Application Stream Packages (x8 47 kB/s | 4.5 kB 00:00
Oracle Linux 9 Application Stream Packages (x8 23 MB/s | 84 MB 00:03
Oracle Linux 9 UEK Release 7 (x86_64) 17 kB/s | 3.5 kB 00:00
Oracle Linux 9 UEK Release 7 (x86_64) 24 MB/s | 95 MB 00:04
Last metadata expiration check: 0:00:09 ago on Fri 27 Feb 2026 03:44:34 PM IST.
pgdg-redhat-repo-latest.noarch.rpm 17 kB/s | 13 kB 00:00
Dependencies resolved.
==============================================================================================================================================================================================================================================
Package Architecture Version Repository Size
==============================================================================================================================================================================================================================================
Installing:
pgdg-redhat-repo noarch 42.0-64.rhel9PGDG @commandline 13 k
Transaction Summary
==============================================================================================================================================================================================================================================
Install 1 Package
Total size: 13 k
Installed size: 16 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : pgdg-redhat-repo-42.0-64.rhel9PGDG.noarch 1/1
Verifying : pgdg-redhat-repo-42.0-64.rhel9PGDG.noarch 1/1
Installed:
pgdg-redhat-repo-42.0-64.rhel9PGDG.noarch
Complete!
What this command does:
dnf/yum install→ installs a package- The URL → downloads the repository RPM file
-y→ automatically answers “yes” to prompts
This does NOT install PostgreSQL yet.
It only adds the PostgreSQL repository to your system.
At this stage, your system is configured to download PostgreSQL 17 packages.
Step 2: Install PostgreSQL 17 Server
Now we install the actual database server.
yum install -y postgresql17-server
Installation Output
[root@dbadiscovery ~]# yum install -y postgresql17-server
PostgreSQL common RPMs for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 1.0 kB/s | 659 B 00:00
PostgreSQL common RPMs for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 2.4 MB/s | 2.4 kB 00:00
Importing GPG key 0x08B40D20:
Userid : "PostgreSQL RPM Repository <[email protected]>"
Fingerprint: D4BF 08AE 67A0 B4C7 A1DB CCD2 40BC A2B4 08B4 0D20
From : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL
PostgreSQL common RPMs for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 3.9 MB/s | 694 kB 00:00
PostgreSQL 18 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 7.2 kB/s | 659 B 00:00
PostgreSQL 18 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 2.4 MB/s | 2.4 kB 00:00
Importing GPG key 0x08B40D20:
Userid : "PostgreSQL RPM Repository <[email protected]>"
Fingerprint: D4BF 08AE 67A0 B4C7 A1DB CCD2 40BC A2B4 08B4 0D20
From : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL
PostgreSQL 18 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 1.7 MB/s | 334 kB 00:00
PostgreSQL 17 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 7.6 kB/s | 659 B 00:00
PostgreSQL 17 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 2.4 MB/s | 2.4 kB 00:00
Importing GPG key 0x08B40D20:
Userid : "PostgreSQL RPM Repository <[email protected]>"
Fingerprint: D4BF 08AE 67A0 B4C7 A1DB CCD2 40BC A2B4 08B4 0D20
From : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL
PostgreSQL 17 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 4.4 MB/s | 834 kB 00:00
PostgreSQL 16 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 7.5 kB/s | 659 B 00:00
PostgreSQL 16 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 2.4 MB/s | 2.4 kB 00:00
Importing GPG key 0x08B40D20:
Userid : "PostgreSQL RPM Repository <[email protected]>"
Fingerprint: D4BF 08AE 67A0 B4C7 A1DB CCD2 40BC A2B4 08B4 0D20
From : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL
PostgreSQL 16 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 4.6 MB/s | 1.0 MB 00:00
PostgreSQL 15 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 7.1 kB/s | 659 B 00:00
PostgreSQL 15 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 2.4 MB/s | 2.4 kB 00:00
Importing GPG key 0x08B40D20:
Userid : "PostgreSQL RPM Repository <[email protected]>"
Fingerprint: D4BF 08AE 67A0 B4C7 A1DB CCD2 40BC A2B4 08B4 0D20
From : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL
PostgreSQL 15 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 4.8 MB/s | 1.3 MB 00:00
PostgreSQL 14 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 7.4 kB/s | 659 B 00:00
PostgreSQL 14 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 2.4 MB/s | 2.4 kB 00:00
Importing GPG key 0x08B40D20:
Userid : "PostgreSQL RPM Repository <[email protected]>"
Fingerprint: D4BF 08AE 67A0 B4C7 A1DB CCD2 40BC A2B4 08B4 0D20
From : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL
PostgreSQL 14 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 4.9 MB/s | 1.5 MB 00:00
Dependencies resolved.
==============================================================================================================================================================================================================================================
Package Architecture Version Repository Size
==============================================================================================================================================================================================================================================
Installing:
postgresql17-server x86_64 17.9-1PGDG.rhel9.7 pgdg17 6.9 M
Installing dependencies:
postgresql17 x86_64 17.9-1PGDG.rhel9.7 pgdg17 1.9 M
postgresql17-libs x86_64 17.9-1PGDG.rhel9.7 pgdg17 341 k
Transaction Summary
==============================================================================================================================================================================================================================================
Install 3 Packages
Total download size: 9.2 M
Installed size: 42 M
Downloading Packages:
(1/3): postgresql17-libs-17.9-1PGDG.rhel9.7.x86_64.rpm 776 kB/s | 341 kB 00:00
(2/3): postgresql17-17.9-1PGDG.rhel9.7.x86_64.rpm 553 kB/s | 1.9 MB 00:03
(3/3): postgresql17-server-17.9-1PGDG.rhel9.7.x86_64.rpm 1.7 MB/s | 6.9 MB 00:04
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 2.2 MB/s | 9.2 MB 00:04
PostgreSQL 17 for RHEL / Rocky Linux / AlmaLinux 9 - x86_64 2.4 MB/s | 2.4 kB 00:00
Importing GPG key 0x08B40D20:
Userid : "PostgreSQL RPM Repository <[email protected]>"
Fingerprint: D4BF 08AE 67A0 B4C7 A1DB CCD2 40BC A2B4 08B4 0D20
From : /etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : postgresql17-libs-17.9-1PGDG.rhel9.7.x86_64 1/3
Running scriptlet: postgresql17-libs-17.9-1PGDG.rhel9.7.x86_64 1/3
Installing : postgresql17-17.9-1PGDG.rhel9.7.x86_64 2/3
Running scriptlet: postgresql17-17.9-1PGDG.rhel9.7.x86_64 2/3
Running scriptlet: postgresql17-server-17.9-1PGDG.rhel9.7.x86_64 3/3
Installing : postgresql17-server-17.9-1PGDG.rhel9.7.x86_64 3/3
Running scriptlet: postgresql17-server-17.9-1PGDG.rhel9.7.x86_64 3/3
Verifying : postgresql17-17.9-1PGDG.rhel9.7.x86_64 1/3
Verifying : postgresql17-libs-17.9-1PGDG.rhel9.7.x86_64 2/3
Verifying : postgresql17-server-17.9-1PGDG.rhel9.7.x86_64 3/3
Installed:
postgresql17-17.9-1PGDG.rhel9.7.x86_64 postgresql17-libs-17.9-1PGDG.rhel9.7.x86_64 postgresql17-server-17.9-1PGDG.rhel9.7.x86_64
Complete!
Now:
- Binaries are installed in
/usr/pgsql-17/ - The
postgressystem user is created - A systemd service file is registered
Check PostgreSQL System User
After installation, PostgreSQL automatically creates a system user:
[root@dbadiscovery ~]# id postgres
uid=26(postgres) gid=26(postgres) groups=26(postgres)
Step 3 – Initialize the Database & Automatic Start
Initialize the Database Cluster
This is where the actual database structure is created.
Command:
sudo /usr/pgsql-17/bin/postgresql-17-setup initdb
[root@dbadiscovery ~]# sudo /usr/pgsql-17/bin/postgresql-17-setup initdb
Initializing database ... OK
[root@dbadiscovery ~]#
Enable PostgreSQL at Boot & Start
Enable PostgreSQL at Boot Command:
sudo systemctl enable postgresql-17
Start PostgreSQL Command:
sudo systemctl start postgresql-17
Sample Output
s[root@dbadiscovery ~]# sudo systemctl enable postgresql-17
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql-17.service → /usr/lib/systemd/system/postgresql-17.service.
[root@dbadiscovery ~]#
[root@dbadiscovery ~]# sudo systemctl start postgresql-17
[root@dbadiscovery ~]#
[postgres@dbadiscovery ~]$ systemctl status postgresql-17
● postgresql-17.service - PostgreSQL 17 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-17.service; enabled; preset: disabled)
Active: active (running) since Fri 2026-02-27 16:01:07 IST; 13min ago
Docs: https://www.postgresql.org/docs/17/static/
Process: 14073 ExecStartPre=/usr/pgsql-17/bin/postgresql-17-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 14078 (postgres)
Tasks: 7 (limit: 34585)
Memory: 22.0M
CPU: 432ms
CGroup: /system.slice/postgresql-17.service
├─14078 /usr/pgsql-17/bin/postgres -D /var/lib/pgsql/17/data/
├─14080 "postgres: logger "
├─14082 "postgres: checkpointer "
├─14083 "postgres: background writer "
├─14085 "postgres: walwriter "
├─14086 "postgres: autovacuum launcher "
└─14087 "postgres: logical replication launcher "
Verify Background Processes
>code>[root@dbadiscovery ~]# ps -ef | grep postgres
postgres 14078 1 0 16:01 ? 00:00:00 /usr/pgsql-17/bin/postgres -D /var/lib/pgsql/17/data/
postgres 14080 14078 0 16:01 ? 00:00:00 postgres: logger
postgres 14082 14078 0 16:01 ? 00:00:00 postgres: checkpointer
postgres 14083 14078 0 16:01 ? 00:00:00 postgres: background writer
postgres 14085 14078 0 16:01 ? 00:00:00 postgres: walwriter
postgres 14086 14078 0 16:01 ? 00:00:00 postgres: autovacuum launcher
postgres 14087 14078 0 16:01 ? 00:00:00 postgres: logical replication launcher
root 14203 9212 0 16:03 pts/0 00:00:00 grep --color=auto postgres
Connect to PostgreSQL
[root@dbadiscovery ~]# su - postgres
[postgres@dbadiscovery ~]$ psql
psql (17.9)
Type "help" for help.
postgres=#
Check List Databases
postgres=# \l
List of databases
Name | Owner | Encoding | Locale Provider | Collate | Ctype | Locale | ICU Rules | Access privileges
-----------+----------+----------+-----------------+-------------+-------------+--------+-----------+-----------------------
postgres | postgres | UTF8 | libc | en_US.UTF-8 | en_US.UTF-8 | | |
template0 | postgres | UTF8 | libc | en_US.UTF-8 | en_US.UTF-8 | | | =c/postgres +
| | | | | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | libc | en_US.UTF-8 | en_US.UTF-8 | | | =c/postgres +
| | | | | | | | postgres=CTc/postgres
(3 rows)
PostgreSQL 17 is successfully installed on RHEL 9 / Oracle Linux 9.
Alert: The information provided on this website is for educational purposes only. It has been tested internally, but there is no guarantee it will work in every environment. It is strongly recommended to first test the process in a non-production environment, such as a User Acceptance Testing (UAT) setup. This allows you to verify configurations, identify any issues, and ensure a smooth transition to production, minimizing the risk of disruptions in your live environment. Always conduct thorough testing before applying changes to production systems.
