In this guide we are going to install Postgresql 17 in Rocky Linux 9.
Ensure the server is up to date
Before proceeding, let us ensure that our server has up to date packages. Use this command to update the packages:
Installing and starting Postgres Server
Install the repository RPM:
1
| sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm
|
Disable the built-in PostgreSQL module:
1
| sudo dnf -qy module disable postgresql
|
Install PostgreSQL
1
| sudo dnf install -y postgresql17-server
|
Let’s also install the Contrib package which provides several additional features for the PostgreSQL database system:
1
| sudo dnf install -y postgresql17-contrib
|
Once the installation is complete, initialize the PostgreSQL database with the following command:
1
2
3
| $ sudo /usr/pgsql-17/bin/postgresql-17-setup initdb
Initializing database ... OK
|
Start the postgres service with this command:
1
| sudo systemctl start postgresql-17
|
Then enable the service so it starts when the server reboots.
1
| sudo systemctl enable postgresql-17
|
Confirm that Postgres is running:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| $ sudo 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 Mon 2025-01-27 08:15:19 UTC; 40s ago
Docs: https://www.postgresql.org/docs/17/static/
Main PID: 57858 (postgres)
Tasks: 7 (limit: 22434)
Memory: 17.6M
CPU: 59ms
CGroup: /system.slice/postgresql-17.service
├─57858 /usr/pgsql-17/bin/postgres -D /var/lib/pgsql/17/data/
├─57859 "postgres: logger "
├─57860 "postgres: checkpointer "
├─57861 "postgres: background writer "
├─57863 "postgres: walwriter "
├─57864 "postgres: autovacuum launcher "
└─57865 "postgres: logical replication launcher "
Jan 27 08:15:19 lab.citizix.com systemd[1]: Starting PostgreSQL 17 database server...
Jan 27 08:15:19 lab.citizix.com postgres[57858]: 2025-01-27 08:15:19.539 UTC [57858] LOG: redirecting log output to logging collector process
Jan 27 08:15:19 lab.citizix.com postgres[57858]: 2025-01-27 08:15:19.539 UTC [57858] HINT: Future log output will appear in directory "log".
Jan 27 08:15:19 lab.citizix.com systemd[1]: Started PostgreSQL 17 database server.
|
The Active: active (running)
shows that the service is up and running.
Next, let us verify that the installation was successful by connecting to the PostgreSQL database server and printing its version:
1
| sudo -u postgres psql -c "SELECT version();"
|
Output:
1
2
3
4
5
| $ sudo -u postgres psql -c "SELECT version();"
version
----------------------------------------------------------------------------------------------------------
PostgreSQL 17.2 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 11.5.0 20240719 (Red Hat 11.5.0-2), 64-bit
(1 row)
|