Install PostgreSQL 13 on CentOS 8 | RHEL 8

In this guide we will explore the installation of PostgreSQL 13 on CentOS 8 | RHEL 8 Linux server. PostgreSQL is a powerful, open source object-relational database system that safely store and scale the most complicated data workloads. The PostgreSQL database system is designed to assure users reliability, data integrity, robust feature set and extensibility. There is a large community behind its development to ensure innovation and strong reputation.

As of this article update PostgreSQL 13 is available running production workloads. All the software packages are available in the YUM repository supported officially by PostgreSQL team the installation process is simplified.

Before you start the installation ensure you’re running the latest release of CentOS 8 | RHEL 8 Linux system. You can run the yum update command to pull the latest updates.

sudo yum -y update

sudo systemctl reboot

Once the system is rebooted begin installation of PostgreSQL 13 on CentOS 8 | RHEL 8 server.

The YUM repository supports both CentOS and RHEL family of Linux distributions. Once it is added, it will provide automatic updates for all supported versions of PostgreSQL throughout the support lifetime of PostgreSQL.

Run the following commands to add the repository that provides PostgreSQL packages to your CentOS / RHEL 8 server.

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

Accept installation when prompted by pressing the y key in your keyboard.

ependencies resolved.

==================================================================================================================================================================

Package Architecture Version Repository Size

==================================================================================================================================================================

Installing:

pgdg-redhat-repo noarch 42.0-14 @commandline 11 k



Transaction Summary

==================================================================================================================================================================

Install 1 Package



Total size: 11 k

Installed size: 11 k

Is this ok [y/N]: y

We need to disable the PostgreSQL AppStream repository on CentOS 8 | RHEL 8 Linux which contains some other version of PostgreSQL.

sudo dnf -qy module disable postgresql

Confirm the list of enabled repositories.

$ sudo dnf repolist

....

pgdg-common PostgreSQL common RPMs for RHEL / Rocky 8 - x86_64

pgdg10 PostgreSQL 10 for RHEL / Rocky 8 - x86_64

pgdg11 PostgreSQL 11 for RHEL / Rocky 8 - x86_64

pgdg12 PostgreSQL 12 for RHEL / Rocky 8 - x86_64

pgdg13 PostgreSQL 13 for RHEL / Rocky 8 - x86_64

pgdg14 PostgreSQL 14 for RHEL / Rocky 8 - x86_64

Check to see if PostgreSQL 13 packages are available on the repository.

$ sudo yum search postgresql13

Last metadata expiration check: 0:11:06 ago on Thu 05 May 2022 11:57:30 PM EAT.

============================================================================== Name Exactly Matched: postgresql13 ==============================================================================

postgresql13.x86_64 : PostgreSQL client programs and libraries

================================================================================== Name Matched: postgresql13 ==================================================================================

postgresql13-contrib.x86_64 : Contributed source and binaries distributed with PostgreSQL

postgresql13-devel.x86_64 : PostgreSQL development header files and libraries

postgresql13-docs.x86_64 : Extra documentation for PostgreSQL

postgresql13-libs.x86_64 : The shared libraries required for any PostgreSQL clients

postgresql13-llvmjit.x86_64 : Just-in-time compilation support for PostgreSQL

postgresql13-odbc.x86_64 : PostgreSQL ODBC driver

postgresql13-plperl.x86_64 : The Perl procedural language for PostgreSQL

postgresql13-plpython3.x86_64 : The Python3 procedural language for PostgreSQL

postgresql13-pltcl.x86_64 : The Tcl procedural language for PostgreSQL

postgresql13-server.x86_64 : The programs needed to create and run a PostgreSQL server

postgresql13-test.x86_64 : The test suite distributed with PostgreSQL

Now install PostgreSQL 13 packages on your CentOS 8 | RHEL 8 server — both server and client.

sudo dnf install postgresql13 postgresql13-server

Agree to install if you’re okay with it.

Dependencies resolved.

================================================================================================================================================================================================

Package Architecture Version Repository Size

================================================================================================================================================================================================

Installing:

postgresql13 x86_64 13.6-1PGDG.rhel8 pgdg13 1.5 M

postgresql13-server x86_64 13.6-1PGDG.rhel8 pgdg13 5.5 M

Installing dependencies:

postgresql13-libs x86_64 13.6-1PGDG.rhel8 pgdg13 415 k



Transaction Summary

================================================================================================================================================================================================

Install 3 Packages



Total download size: 7.4 M

Installed size: 31 M

Is this ok [y/N]: y

GPG key repository is also required.

PostgreSQL database initialization is required before you can use the database server.

$ sudo /usr/pgsql-13/bin/postgresql-13-setup initdb

Initializing database ... OK

The database main configuration file is /var/lib/pgsql/13/data/postgresql.conf

$ ls  /var/lib/pgsql/13/data/

base pg_commit_ts pg_ident.conf pg_notify pg_snapshots pg_subtrans PG_VERSION postgresql.auto.conf

global pg_dynshmem pg_logical pg_replslot pg_stat pg_tblspc pg_wal postgresql.conf

log pg_hba.conf pg_multixact pg_serial pg_stat_tmp pg_twophase pg_xact

Start the PostgreSQL database server and set it to start at boot.

$ sudo systemctl enable --now postgresql-13

Created symlink /etc/systemd/system/multi-user.target.wants/postgresql-13.service → /usr/lib/systemd/system/postgresql-13.service.

Check the service status to confirm it is running.

$ systemctl status postgresql-13

● postgresql-13.service - PostgreSQL 13 database server

Loaded: loaded (/usr/lib/systemd/system/postgresql-13.service; enabled; vendor preset: disabled)

Active: active (running) since Thu 2020-07-09 23:35:30 CEST; 37s ago

Docs: https://www.postgresql.org/docs/13/static/

Process: 1860 ExecStartPre=/usr/pgsql-13/bin/postgresql-13-check-db-dir $PGDATA (code=exited, status=0/SUCCESS)

Main PID: 1865 (postmaster)

Tasks: 8 (limit: 12210)

Memory: 17.3M

CGroup: /system.slice/postgresql-13.service

├─1865 /usr/pgsql-13/bin/postmaster -D /var/lib/pgsql/13/data/

├─1867 postgres: logger

├─1869 postgres: checkpointer

├─1870 postgres: background writer

├─1871 postgres: walwriter

├─1872 postgres: autovacuum launcher

├─1873 postgres: stats collector

└─1874 postgres: logical replication launcher



Jul 09 23:35:30 centos-01.computingforgeeks.com systemd[1]: Starting PostgreSQL 13 database server...

Jul 09 23:35:30 centos-01.computingforgeeks.com postmaster[1865]: 2020-07-09 23:35:30.180 CEST [1865] LOG: redirecting log output to logging collector process

Jul 09 23:35:30 centos-01.computingforgeeks.com postmaster[1865]: 2020-07-09 23:35:30.180 CEST [1865] HINT: Future log output will appear in directory "log".

Jul 09 23:35:30 centos-01.computingforgeeks.com systemd[1]: Started PostgreSQL 13 database server.

Update the PostgreSQL admin user password.

$ sudo su - postgres 

]$ psql -c "alter user postgres with password 'StrongDBPassword'"

ALTER ROLE

Edit the file /var/lib/pgsql/13/data/postgresql.conf and set Listen address to your server IP address or “*” for all interfaces.

$ sudo vi /var/lib/pgsql/13/data/postgresql.conf

# line 59

listen_addresses = '192.168.10.10'

Also set PostgreSQL to accept remote connections

$ sudo vi /var/lib/pgsql/13/data/pg_hba.conf



# Accept from anywhere (not recommended)

host all all 0.0.0.0/0 md5



# Accept from trusted subnet (Recommended setting)

host all all 192.168.18.0/24 md5

Restart the database service after saving the changes.

sudo systemctl restart postgresql-13

Test connection using the psql command while providing username and optionally database name.

$ psql -U  -h  -p 5432

pgAdmin is the leading Open Source feature-rich PostgreSQL administration and development platform that runs on Linux, Unix, Mac OS X, and Windows. Here is the link for the installation of pgAdmin4 on CentOS.

How To Install pgAdmin 4 on CentOS 8 Linux

https://www.computingpost.com/install-postgresql-13-on-centos-8-rhel-8/?feed_id=1646&_unique_id=632d4e66e2543

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
ComputingPost

ComputingPost — Linux Howtos, Tutorials, Guides, News, Tips and Tricks.