top of page
Search
  • Writer's pictureSudipta Bhaskar

Install PostgreSQL 13 using yum/dnf in redhat linux 8

Updated: May 5, 2021

This post will explain the installation process of PostgreSQL 13 in redhat linux 8


We are following the yum/dnf method of installation here.


  1. Create a VM in Local Machine using Virtualbox/Vmware/Hyper V or create a ec2-instance/VM in cloud. Here I am using a local VM using Virtualbox.


2. We need to download the repo first.

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

3. We can check the repolist by running the following command.

dnf repolist       

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

dnf -qy module disable postgresql

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

dnf search postgresql13

6. Now, install postgresql13

[root@basevm ~]# dnf install postgresql13 postgresql13-server
Updating Subscription Management repositories.
Last metadata expiration check: 1:12:46 ago on Sun 04 Apr 2021 07:19:34 PM IST.
Dependencies resolved.
=========================================================================================================================================
 Package                                Architecture              Version                                Repository                 Size
=========================================================================================================================================
Installing:
 postgresql13                           x86_64                    13.2-1PGDG.rhel8                       pgdg13                    1.4 M
 postgresql13-server                    x86_64                    13.2-1PGDG.rhel8                       pgdg13                    5.5 M
Installing dependencies:
 postgresql13-libs                      x86_64                    13.2-1PGDG.rhel8                       pgdg13                    411 k

Transaction Summary
=========================================================================================================================================
Install  3 Packages

Total download size: 7.4 M
Installed size: 31 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): postgresql13-libs-13.2-1PGDG.rhel8.x86_64.rpm                                                     240 kB/s | 411 kB     00:01
(2/3): postgresql13-13.2-1PGDG.rhel8.x86_64.rpm                                                          730 kB/s | 1.4 MB     00:02
(3/3): postgresql13-server-13.2-1PGDG.rhel8.x86_64.rpm                                                   2.2 MB/s | 5.5 MB     00:02
-----------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                    2.9 MB/s | 7.4 MB     00:02
warning: /var/cache/dnf/pgdg13-e81daebfc8b779ec/packages/postgresql13-13.2-1PGDG.rhel8.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
PostgreSQL 13 for RHEL/CentOS 8 - x86_64                                                                 1.6 MB/s | 1.7 kB     00:00
Importing GPG key 0x442DF0F8:
 Userid     : "PostgreSQL RPM Building Project <pgsqlrpms-hackers@pgfoundry.org>"
 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
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                 1/1
  Installing       : postgresql13-libs-13.2-1PGDG.rhel8.x86_64                                                                       1/3
  Running scriptlet: postgresql13-libs-13.2-1PGDG.rhel8.x86_64                                                                       1/3
  Installing       : postgresql13-13.2-1PGDG.rhel8.x86_64                                                                            2/3
  Running scriptlet: postgresql13-13.2-1PGDG.rhel8.x86_64                                                                            2/3
  Running scriptlet: postgresql13-server-13.2-1PGDG.rhel8.x86_64                                                                     3/3
  Installing       : postgresql13-server-13.2-1PGDG.rhel8.x86_64                                                                     3/3
  Running scriptlet: postgresql13-server-13.2-1PGDG.rhel8.x86_64                                                                     3/3
  Verifying        : postgresql13-13.2-1PGDG.rhel8.x86_64                                                                            1/3
  Verifying        : postgresql13-libs-13.2-1PGDG.rhel8.x86_64                                                                       2/3
  Verifying        : postgresql13-server-13.2-1PGDG.rhel8.x86_64                                                                     3/3
Installed products updated.

Installed:
  postgresql13-13.2-1PGDG.rhel8.x86_64     postgresql13-libs-13.2-1PGDG.rhel8.x86_64     postgresql13-server-13.2-1PGDG.rhel8.x86_64

Complete!

7. We need to install and start database now.

[root@basevm ~]# /usr/pgsql-13/bin/postgresql-13-setup initdb
Initializing database ... OK

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


[root@basevm ~]# systemctl enable --now postgresql-13

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

9. Check the service status to confirm it is running.


[root@basevm ~]# systemctl status postgresql-13

10. Let's connect to database and run basic commands.



[postgres@basevm ~]$ psql
psql (13.2)
Type "help" for help.

postgres=# select datname from pg_database;
  datname
-----------
 postgres
 template1
 template0
(3 rows)

postgres=# create database test identified by test;
ERROR:  syntax error at or near ";"
LINE 1: create database test identified by test;
                                               ^
postgres=# create database test;
CREATE DATABASE
postgres=#
postgres=# select datname from pg_database;
  datname
-----------
 postgres
 test
 template1
 template0
(4 rows)

postgres=# \c test
You are now connected to database "test" as user "postgres".
test=#
test=#


[postgres@basevm ~]$ ps -ef | grep postgres
postgres    2506       1  0 20:46 ?        00:00:00 /usr/pgsql-13/bin/postmaster -D /var/lib/pgsql/13/data/
postgres    2507    2506  0 20:46 ?        00:00:00 postgres: logger
postgres    2509    2506  0 20:46 ?        00:00:00 postgres: checkpointer
postgres    2510    2506  0 20:46 ?        00:00:00 postgres: background writer
postgres    2511    2506  0 20:46 ?        00:00:00 postgres: walwriter
postgres    2512    2506  0 20:46 ?        00:00:00 postgres: autovacuum launcher
postgres    2513    2506  0 20:46 ?        00:00:00 postgres: stats collector
postgres    2514    2506  0 20:46 ?        00:00:00 postgres: logical replication launcher
root        2520    1909  0 20:55 pts/0    00:00:00 su - postgres
postgres    2521    2520  0 20:55 pts/0    00:00:00 -bash
postgres    2593    2521  0 21:03 pts/0    00:00:00 ps -ef
postgres    2594    2521  0 21:03 pts/0    00:00:00 grep --color=auto postgres

378 views0 comments

Recent Posts

See All

ORA-00845: MEMORY_TARGET not supported on this system

srvctl start asm fails with the following error. [oracle@sbstandby ~]$ srvctl start asm PRCR-1079 : Failed to start resource ora.asm CRS-2674: Start of 'ora.LISTENER.lsnr' on 'sbstandby' failed CRS-50

Post: Blog2_Post
bottom of page