PostgreSQL is available on RHEL/Cent OS by default as AppStream. As per RHEL documentation, RHEL/CentOS comes with a new feature called Application Streams (AppStreams), in which multiple versions of packages are provided, with a known period of support.
These modules can be thought of as package groups that represent an application, a set of tools, or runtime languages.
We can see the list of modules available modules to us after a fresh installation of RHEL 9 using the below command
yum module list
Table of Contents
How to install default version of PostgreSQL using AppStream?
RHEL/Cent OS 9 provides PostgreSQL 13 as the initial version of this Application Stream, which can be installed with
dnf install postgresql-server
[root@pghelp01 ~]# dnf install postgresql-server
Last metadata expiration check: 0:13:17 ago on Saturday 06 April 2024 07:06:21 PM.
Dependencies resolved.
=======================================================================================================================================
Package Architecture Version Repository Size
=======================================================================================================================================
Installing:
postgresql-server x86_64 13.14-1.el9 appstream 5.8 M
Installing dependencies:
postgresql x86_64 13.14-1.el9 appstream 1.6 M
postgresql-private-libs x86_64 13.14-1.el9 appstream 133 k
Transaction Summary
=======================================================================================================================================
Install 3 Packages
Total download size: 7.5 M
Installed size: 29 M
Is this ok [y/N]:
Additional PostgreSQL versions are provided as modules with a shorter life cycle in minor releases of RHEL 9/Cent OS 9. To see the list of modules run the below command
dnf module list postgresql
[root@pghelp01 ~]# dnf module list postgresql
Last metadata expiration check: 0:12:55 ago on Saturday 06 April 2024 07:06:21 PM.
CentOS Stream 9 - AppStream
Name Stream Profiles Summary
postgresql 15 [x] client, server [d] PostgreSQL server and client module
postgresql 16 [x] client, server [d] PostgreSQL server and client module
Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
You can notice both postgresql 15 and postgresql 16 are disabled [x] under Stream.
Before installing any module, let’s understand how to install a module in Cent OS 9.
Here is an example that we can break down to show all the options.
# dnf module install module:version/profile
module
defines which module we are going to install.:version
specifies which stream we are going to use for the specified module./profile
tells us which profile to use. If no profile is specified, the default one is used. As per the above example., server is the default module.
How to install user specified version of PostgreSQL using AppStream?
To install PostgreSQL 16, for example., run the below command
dnf module install postgresql:16
To install PostgreSQL 16 client run the below command
dnf module install postgresql:16/client
How to make PostgreSQL 16 as the default version of module installation?
List the available module
[root@pghelp01 ~]# dnf module list postgresql
Last metadata expiration check: 0:32:20 ago on Saturday 06 April 2024 07:06:21 PM.
CentOS Stream 9 - AppStream
Name Stream Profiles Summary
postgresql 15 [x] client, server [d] PostgreSQL server and client module
postgresql 16 [x] client, server [d] PostgreSQL server and client module
Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
Enable PostgreSQL 16 module
[root@pghelp01 ~]# dnf module enable postgresql:16
Last metadata expiration check: 0:32:29 ago on Saturday 06 April 2024 07:06:21 PM.
Dependencies resolved.
=======================================================================================================================================
Package Architecture Version Repository Size
=======================================================================================================================================
Enabling module streams:
postgresql 16
Transaction Summary
=======================================================================================================================================
Is this ok [y/N]: y
Complete!
[root@pghelp01 ~]#
Check again to notice [e] for Version 16 under stream
[root@pghelp01 ~]# dnf module list postgresql
Last metadata expiration check: 0:32:35 ago on Saturday 06 April 2024 07:06:21 PM.
CentOS Stream 9 - AppStream
Name Stream Profiles Summary
postgresql 15 client, server [d] PostgreSQL server and client module
postgresql 16 [e] client, server [d] PostgreSQL server and client module
Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
Putting everything together to install PostgreSQL 16 and initializing PostgreSQL on Cent OS 9
Install the PostgreSQL server packages:
dnf install postgresql-server
Initialize the database cluster:
postgresql-setup --initdb
Start the postgresql
service:
systemctl start postgresql.service
Enable the postgresql
service to start at boot:
systemctl enable postgresql.service
Check the current status of the service
systemctl status postgresql.service
[root@pghelp01 ~]# systemctl status postgresql.service
● postgresql.service - PostgreSQL database server
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; preset: disabled)
Active: active (running) since Sat 2024-04-06 19:43:00 IST; 10s ago
Main PID: 3774 (postgres)
Tasks: 7 (limit: 22817)
Memory: 17.5M
CPU: 41ms
CGroup: /system.slice/postgresql.service
├─3774 /usr/bin/postgres -D /var/lib/pgsql/data
├─3775 "postgres: logger "
├─3776 "postgres: checkpointer "
├─3777 "postgres: background writer "
├─3779 "postgres: walwriter "
├─3780 "postgres: autovacuum launcher "
└─3781 "postgres: logical replication launcher "
Apr 06 19:43:00 pghelp01 systemd[1]: Starting PostgreSQL database server...
Apr 06 19:43:00 pghelp01 postgres[3774]: 2024-04-06 19:43:00.967 IST [3774] LOG: redirecting log output to logging collector process
Apr 06 19:43:00 pghelp01 postgres[3774]: 2024-04-06 19:43:00.967 IST [3774] HINT: Future log output will appear in directory "log".
Apr 06 19:43:00 pghelp01 systemd[1]: Started PostgreSQL database server.
If the installation is from PostgreSQL repository, the installation should look like this
More details can be found here
Words from postgreshelp
Thank you for giving your valuable time to read the above information. I hope the content served your purpose in reaching out the blog.
Suggestions for improvement of the blog are highly appreciable. Please contact us for any information/suggestion/feedback.
If you want to be updated with all our articles