Install PostgreSQL 13 on CentOS 8 | RHEL 8

The
You can download this article in PDF format to support us through the following link.

Download the guide in PDF format

turn off
The

The
The

In this guide, we will discuss the installation of PostgreSQL 13 on CentOS 8. RHEL 8 Linux server. PostgreSQL is a powerful open source object-relational database system that can safely store and expand the most complex data workloads. The PostgreSQL database system is designed to ensure user reliability, data integrity, a powerful feature set, and scalability. There is a huge community behind its development to ensure innovation and a strong reputation.

Install PostgreSQL 13 on CentOS 8 | RHEL 8

At the time of this update, PostgreSQL 13 is only available in Beta and cannot be used to run production workloads. Please use it in the development environment and share feedback with the development team for bug fixes and improvements. Since the software package is available in the YUM repository officially supported by the PostgreSQL team, the installation process is simplified.

Before starting the installation, make sure you are running the latest version of CentOS 8. RHEL 8 Linux system. You can run the yum update command to get the latest updates.

sudo yum -y update
sudo systemctl reboot

After the system restarts, install PostgreSQL 13 on CentOS 8. RHEL 8 server.

Step 1: Add the PostgreSQL Yum repository

The YUM repository supports CentOS and RHEL series Linux distributions. Once added, it will provide automatic updates for all supported PostgreSQL versions throughout the PostgreSQL support lifecycle.

Run the following command to add the repository that provides the PostgreSQL package to the 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

When prompted, press ÿ The keys on the keyboard.

Dependencies resolved.
==================================================================================================================================================================
 Package                                     Architecture                      Version                              Repository                               Size
==================================================================================================================================================================
Installing:
 pgdg-redhat-repo                            noarch                            42.0-11                              @commandline                             11 k

Transaction Summary
==================================================================================================================================================================
Install  1 Package

Total size: 11 k
Installed size: 11 k
Is this ok [y/N]: y

Step 2: Install PostgreSQL 13 on CentOS 8 | RHEL 8

We need to disable the PostgreSQL AppStream repository on CentOS 8. RHEL 8 Linux includes other versions of PostgreSQL.

sudo dnf -qy module disable postgresql

Enable the PostgreSQL 13 test library.

sudo dnf -y install dnf-utils
sudo yum-config-manager --enable pgdg13-updates-testing

Confirm the list of enabled repositories.

# dnf repolist
repo id                                                        repo name
AppStream                                                      CentOS-8 - AppStream
BaseOS                                                         CentOS-8 - Base
extras                                                         CentOS-8 - Extras
pgdg-common                                                    PostgreSQL common RPMs for RHEL/CentOS 8 - x86_64
pgdg10                                                         PostgreSQL 10 for RHEL/CentOS 8 - x86_64
pgdg11                                                         PostgreSQL 11 for RHEL/CentOS 8 - x86_64
pgdg12                                                         PostgreSQL 12 for RHEL/CentOS 8 - x86_64
pgdg13-updates-testing                                         PostgreSQL 13 for RHEL/CentOS 8 - x86_64 - Updates testing
pgdg95                                                         PostgreSQL 9.5 for RHEL/CentOS 8 - x86_64
pgdg96                                                         PostgreSQL 9.6 for RHEL/CentOS 8 - x86_64

Check if there is PostgreSQL 13 software package in the repository.

$ sudo yum search postgresql13
Last metadata expiration check: 0:08:33 ago on Thu 09 Jul 2020 11:18:26 PM CEST.
=============================================================== Name Exactly Matched: postgresql13 ===============================================================
postgresql13.x86_64 : PostgreSQL client programs and libraries
=================================================================== Name Matched: postgresql13 ===================================================================
postgresql13-docs.x86_64 : Extra documentation for PostgreSQL
postgresql13-libs.x86_64 : The shared libraries required for any PostgreSQL clients
postgresql13-test.x86_64 : The test suite distributed with PostgreSQL
postgresql13-devel.x86_64 : PostgreSQL development header files and libraries
postgresql13-pltcl.x86_64 : The Tcl procedural language for PostgreSQL
postgresql13-plperl.x86_64 : The Perl procedural language for PostgreSQL
postgresql13-server.x86_64 : The programs needed to create and run a PostgreSQL server
postgresql13-contrib.x86_64 : Contributed source and binaries distributed with PostgreSQL
postgresql13-llvmjit.x86_64 : Just-in-time compilation support for PostgreSQL
postgresql13-plpython3.x86_64 : The Python3 procedural language for PostgreSQL

Now install the PostgreSQL 13 package on CentOS 8. RHEL 8 server-server and client.

sudo dnf install postgresql13-server

If you can, agree to install.

Dependencies resolved.
==================================================================================================================================================================
 Package                                  Architecture                Version                                   Repository                                   Size
==================================================================================================================================================================
Installing:
 postgresql13-server                      x86_64                      13-beta2_1PGDG.rhel8                      pgdg13-updates-testing                      6.1 M
Installing dependencies:
 libicu                                   x86_64                      60.3-2.el8_1                              BaseOS                                      8.8 M
 postgresql13                             x86_64                      13-beta2_1PGDG.rhel8                      pgdg13-updates-testing                      1.6 M
 postgresql13-libs                        x86_64                      13-beta2_1PGDG.rhel8                      pgdg13-updates-testing                      431 k

Transaction Summary
==================================================================================================================================================================
Install  4 Packages

Total download size: 17 M
Installed size: 65 M
Is this ok [y/N]: y

A GPG key repository is also required.

Total                                                                                                                              12 MB/s |  17 MB     00:01
warning: /var/cache/dnf/pgdg13-updates-testing-20e9d036368b4178/packages/postgresql13-13-beta2_1PGDG.rhel8.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
PostgreSQL 13 for RHEL/CentOS 8 - x86_64 - Updates testing                                                                        1.6 MB/s | 1.7 kB     00:00
Importing GPG key 0x442DF0F8:
 Userid     : "PostgreSQL RPM Building Project <[email protected]>"
 Fingerprint: 68C9 E2B9 1A37 D136 FE74 D176 1F16 D2E1 442D F0F8
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Is this ok [y/N]: y

Step 3: Initialize and start the database service

You must initialize the PostgreSQL database before you can use the database server.

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

The main database 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 startup.

$ 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 that 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.

Step 4: Set the password of the PostgreSQL administrator user

Update the PostgreSQL administrator user password.

$ sudo su - postgres 
]$ psql -c "alter user postgres with password 'StrongDBPassword'"
ALTER ROLE

Step 5: Enable remote database connection (optional)

Edit file /var/lib/pgsql/13/data/postgresql.conf And set the “listening address” to the server IP address or “*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

After saving the changes, restart the database service.

sudo systemctl restart postgresql-13

Use the psql command to test the connection, and provide the user name and (optional) database name.

$ psql -U  -h  -p 5432 

Step 6: Install pgAdmin 4 web interface

pgAdmin is a leading open source feature-rich PostgreSQL management and development platform that can run on Linux, Unix, Mac OS X and Windows. This is the link to install pgAdmin4 on CentOS.

How to install pgAdmin 4 on CentOS 8 Linux

Read the official documentation for more in-depth knowledge about the following PostgreSQL database management.

The
You can download this article in PDF format to support us through the following link.

Download the guide in PDF format

turn off
The

The
The

Sidebar