We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – How To Install PostgreSQL 15 on CentOS 7 / RHEL 7

Learn how to – How To Install PostgreSQL 15 on CentOS 7 / RHEL 7.

In this short article we shall perform the installation of PostgreSQL 15 on CentOS 7 / RHEL 7. PostgreSQL is an open-source database management system that holds a high reputation in robustness, reliability, and data integrity. PostgreSQL was first developed in 1986 as part of the Postgres project at the University of California at Berkeley. It has been in active development for over 30 years resulting in high resilience and performance with notable levels of data integrity.

PostgreSQL 15 key features:

  • Logging and Configuration Enhancements: It introduces a new logging format known as jsonlog. This outputs the log data using a defined JSON structure, thus allowing the logs to be processed in structured logging systems.
  • Improved Sort Performance and Compression: There has been an improvement in in-memory and on-disk sorting algorithms as viewed form benchmarks.
  • Expressive Developer Features: It includes the SQL standard MERGE command that lets users write conditional SQL statements that can include INSERTUPDATE, and DELETE actions within a single statement. It alos allows users to create views that query data using the permissions of the caller, not the view creator.
  • More Options with Logical Replication: It is more flexible when managing logical replication. New row filtering and column lists for publishers have been introduced, allowing users to replicate a subset of data from a table.
  • New built-in extension known as pg_walinspect: that lets users inspect the contents of write-ahead log files directly from a SQL interface.
  • PostgreSQL 15 removes both the long-deprecated “exclusive backup” mode and support for Python 2 from PL/Python.
  • It introduces ICU collation the default collation for a cluster or an individual database.

Use the steps below to install PostgreSQL 15 on CentOS 7 / RHEL 7 Linux system.

Step 1: Add the PostgreSQL Repository

Run the following commands to add PostgreSQL RPM repository on your CentOS / RHEL 7 system.

sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

Confirm the repository has been added and working

$ sudo yum -y repolist
...
repo id                                                                         repo name                                                                                                       status
base/7/x86_64                                                                   CentOS-7 - Base                                                                                                 10,072
extras/7/x86_64                                                                 CentOS-7 - Extras                                                                                                  515
pgdg-common/7/x86_64                                                            PostgreSQL common RPMs for RHEL / CentOS 7 - x86_64                                                                383
pgdg10/7/x86_64                                                                 PostgreSQL 10 for RHEL / CentOS 7 - x86_64                                                                       1,153
pgdg11/7/x86_64                                                                 PostgreSQL 11 for RHEL / CentOS 7 - x86_64                                                                       1,383
pgdg12/7/x86_64                                                                 PostgreSQL 12 for RHEL / CentOS 7 - x86_64                                                                         989
pgdg13/7/x86_64                                                                 PostgreSQL 13 for RHEL / CentOS 7 - x86_64                                                                         736
pgdg14/7/x86_64                                                                 PostgreSQL 14 for RHEL / CentOS 7 - x86_64                                                                         465
pgdg15/7/x86_64                                                                 PostgreSQL 15 for RHEL / CentOS 7 - x86_64                                                                         177
updates/7/x86_64                                                                CentOS-7 - Updates                                                                                               4,425
repolist: 20,298

Step 2: Install PostgreSQL 15 on CentOS 7 / RHEL 7

The next step after adding the repository is updating your system.

sudo yum -y update

Then add EPEL repository which has dependencies required by PostgreSQL 15.

sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

After the upgrade you can begin the installation of PostgreSQL 15 on CentOS 7 / RHEL 7.

sudo yum -y install postgresql15-server

The commands we executed will install both the server and client packages. If everything ran as expected, you should get a message at the end similar to one below.

...
Complete!

Run the commands below to check version of PostgreSQL installed on the system.

$ psql -V
psql (PostgreSQL) 15.3

Step 3: Initialize PostgreSQL 15 on CentOS 7 / RHEL 7

The initdb has to be initialized before you can use PostgreSQL 15 on CentOS 7 / RHEL 7. To perform this operation use the commands:

$ sudo /usr/pgsql-15/bin/postgresql-15-setup initdb
Initializing database ... OK

Now start and enable the PostgreSQL 15 service:

sudo systemctl enable --now postgresql-15

Confirm status of your PostgreSQL 15 service.

$ systemctl status postgresql*
● postgresql-15.service - PostgreSQL 15 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-15.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2022-12-12 19:49:36 UTC; 9s ago
     Docs: https://www.postgresql.org/docs/15/static/
  Process: 1872 ExecStartPre=/usr/pgsql-15/bin/postgresql-15-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
 Main PID: 1878 (postmaster)
   CGroup: /system.slice/postgresql-15.service
           ├─1878 /usr/pgsql-15/bin/postmaster -D /var/lib/pgsql/15/data/
           ├─1880 postgres: logger
           ├─1881 postgres: checkpointer
           ├─1882 postgres: background writer
           ├─1884 postgres: walwriter
           ├─1885 postgres: autovacuum launcher
           └─1886 postgres: logical replication launcher

Dec 12 19:49:36 cent7.mylab.io systemd[1]: Starting PostgreSQL 15 database server...
Dec 12 19:49:36 cent7.mylab.io postmaster[1878]: 2022-12-12 19:49:36.751 UTC [1878] LOG:  redirecting log output to logging collector process
Dec 12 19:49:36 cent7.mylab.io postmaster[1878]: 2022-12-12 19:49:36.751 UTC [1878] HINT:  Future log output will appear in directory "log".
Dec 12 19:49:36 cent7.mylab.io systemd[1]: Started PostgreSQL 15 database server.

Step 4: Set postgres user Password

As a root or user with sudo privileges set password for postgres user.

$ sudo passwd postgres
Changing password for user postgres.
New password: <NEW-PASSWORD>
Retype new password: <CONFIRM-PASSWORD>
passwd: all authentication tokens updated successfully.

Test access to user’s shell using password set above.

$ su - postgres
Password:
Last login: Mon Dec 12 19:53:17 UTC 2022 on pts/0

Update postgres database user password as well

psql -c "ALTER USER postgres WITH PASSWORD 'StrongPassw0rd';"

Expected output:

ALTER ROLE

To drop into PostgreSQL management interface run psql command.

$ psql
psql (15.1)
Type "help" for help.

postgres=#

Conclusion

PostgreSQL is applied in many areas where high performance is key requirement in choosing a relational database management system. Some of the main applications of PostgreSQL is in storing data for web, analytic, mobile and desktop applications. We hope this article was helpful and we than you for visiting our website.

Recommended books:

Cart

Your Cart is Empty

Back To Shop