*Note rpm for Postgres16 install does not appear to be available as standard for RHEL 7
1. Install the repository RPM
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
output:
Updating Subscription Management repositories.
Last metadata expiration check: 2:19:56 ago on Fri 29 Dec 2023 14:28:16 GMT.
pgdg-redhat-repo-latest.noarch.rpm 37 kB/s | 13 kB 00:00
Dependencies resolved.
Package Architecture Version Repository Size
Installing:
pgdg-redhat-repo noarch 42.0-35PGDG @commandline 13 k
Transaction Summary
Install 1 Package
Total size: 13 k
Installed size: 15 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-35PGDG.noarch 1/1
Verifying : pgdg-redhat-repo-42.0-35PGDG.noarch 1/1
Installed products updated.
Installed:
pgdg-redhat-repo-42.0-35PGDG.noarch
Complete!
2. Disable the built-in PostgreSQL module
sudo dnf -qy module disable postgresql
output:
[root@dhome01 ~]# dnf -qy module disable postgresql
Importing GPG key 0x442DF0F8:
Userid : “PostgreSQL RPM Building Project pgsql-pkg-yum@postgresql.org”
Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Importing GPG key 0x442DF0F8:
Userid : “PostgreSQL RPM Building Project pgsql-pkg-yum@postgresql.org”
Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Importing GPG key 0x442DF0F8:
Userid : “PostgreSQL RPM Building Project pgsql-pkg-yum@postgresql.org”
Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Importing GPG key 0x442DF0F8:
Userid : “PostgreSQL RPM Building Project pgsql-pkg-yum@postgresql.org”
Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Importing GPG key 0x442DF0F8:
Userid : “PostgreSQL RPM Building Project pgsql-pkg-yum@postgresql.org”
Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Importing GPG key 0x442DF0F8:
Userid : “PostgreSQL RPM Building Project pgsql-pkg-yum@postgresql.org”
Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Importing GPG key 0x442DF0F8:
Userid : “PostgreSQL RPM Building Project pgsql-pkg-yum@postgresql.org”
Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
3. Install PostgreSQL:
sudo dnf install -y postgresql16-server
output:
Updating Subscription Management repositories.
Last metadata expiration check: 0:03:30 ago on Fri 29 Dec 2023 16:49:40 GMT.
Dependencies resolved.
Package Architecture Version Repository Size
Installing:
postgresql16-server x86_64 16.1-4PGDG.rhel8 pgdg16 6.7 M
Installing dependencies:
postgresql16 x86_64 16.1-4PGDG.rhel8 pgdg16 1.9 M
postgresql16-libs x86_64 16.1-4PGDG.rhel8 pgdg16 327 k
Transaction Summary
Install 3 Packages
Total download size: 8.9 M
Installed size: 39 M
Downloading Packages:
(1/3): postgresql16-libs-16.1-4PGDG.rhel8.x86_64.rpm 369 kB/s | 327 kB 00:00
(2/3): postgresql16-16.1-4PGDG.rhel8.x86_64.rpm 965 kB/s | 1.9 MB 00:02
(3/3): postgresql16-server-16.1-4PGDG.rhel8.x86_64.rpm 1.1 MB/s | 6.7 MB 00:06
Total 1.4 MB/s | 8.9 MB 00:06
PostgreSQL 16 for RHEL / Rocky 8 – x86_64 1.6 MB/s | 1.7 kB 00:00
Importing GPG key 0x442DF0F8:
Userid : “PostgreSQL RPM Building Project pgsql-pkg-yum@postgresql.org”
Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : postgresql16-libs-16.1-4PGDG.rhel8.x86_64 1/3
Running scriptlet: postgresql16-libs-16.1-4PGDG.rhel8.x86_64 1/3
Installing : postgresql16-16.1-4PGDG.rhel8.x86_64 2/3
Running scriptlet: postgresql16-16.1-4PGDG.rhel8.x86_64 2/3
Running scriptlet: postgresql16-server-16.1-4PGDG.rhel8.x86_64 3/3
Installing : postgresql16-server-16.1-4PGDG.rhel8.x86_64 3/3
Running scriptlet: postgresql16-server-16.1-4PGDG.rhel8.x86_64 3/3
Verifying : postgresql16-16.1-4PGDG.rhel8.x86_64 1/3
Verifying : postgresql16-libs-16.1-4PGDG.rhel8.x86_64 2/3
Verifying : postgresql16-server-16.1-4PGDG.rhel8.x86_64 3/3
Installed products updated.
Installed:
postgresql16-16.1-4PGDG.rhel8.x86_64 postgresql16-libs-16.1-4PGDG.rhel8.x86_64 postgresql16-server-16.1-4PGDG.rhel8.x86_64
Complete!
4. Optionally initialize the database and enable automatic start:
sudo /usr/pgsql-16/bin/postgresql-16-setup initdb
output:
Initializing database … OK
sudo systemctl enable postgresql-16
output:
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql-16.service → /usr/lib/systemd/system/postgresql-16.service.
sudo systemctl start postgresql-16
5. Optionally Install postgresql contrib extension
sudo dnf install -y postgresql16-contrib
Updating Subscription Management repositories.
Last metadata expiration check: 2:22:02 ago on Fri 29 Dec 2023 22:13:21 GMT.
Dependencies resolved.
Package Architecture Version Repository Size
Installing:
postgresql16-contrib x86_64 16.1-4PGDG.rhel8 pgdg16 758 k
Transaction Summary
Install 1 Package
Total download size: 758 k
Installed size: 2.7 M
Downloading Packages:
postgresql16-contrib-16.1-4PGDG.rhel8.x86_64.rpm 1.5 MB/s | 758 kB 00:00
Total 1.5 MB/s | 758 kB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : postgresql16-contrib-16.1-4PGDG.rhel8.x86_64 1/1
Running scriptlet: postgresql16-contrib-16.1-4PGDG.rhel8.x86_64 1/1
Verifying : postgresql16-contrib-16.1-4PGDG.rhel8.x86_64 1/1
Installed products updated.
Installed:
postgresql16-contrib-16.1-4PGDG.rhel8.x86_64
Complete!