In this article we will discuss about PostgreSQL installation on Linux flavor OS Like RHEL, Fedora, CentOS 7. To install PostgreSQL on RHEL is very simple. You can install any version of PostgreSQL like 9.5, 9.6, 10, 11, 12 using below method. Only you have to select the required PostgreSQL Version from the PostgreSQL Download website.
Steps to Install PostgreSQL on Linux from repository.
STEP 1: Create postgres user and change home directory permission.
Create postgres user if not already present. It is better to create custom postgres home directory for installation. By default postgres user is created during installation but it is better to create postgres user so that you can grant permissions to the postgres home directory.
Create PostgreSQL home directory and grant 755 permission and ownership to postgres user.
[root@orahowdb /]# useradd postgres
[root@orahowdb /]# passwd postgres
[root@orahowdb /]# groupadd postgres
[root@orahowdb /]# usermod -g postgres postgres
[root@orahowdb /]# mkdir -p /scratch/postgres/postgres_db/db_home/
[root@orahowdb /]# cd /scratch/postgres/postgres_db/db_home/
[root@orahowdb db_home]# pwd
/scratch/postgres/postgres_db/db_home/
[root@orahowdb db_home]# chmod -R 755 /scratch/postgres/postgres_db/db_home/
[root@orahowdb db_home]# chown -R postgres:postgres /scratch/postgres/postgres_db/db_home/
STEP 2: Check Linux Version to download recommended PostgreSQL Version.
[root@orahowdb ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.10 (Santiago)
STEP 3: Remove any previous version of Postgres that might be present as default.
[root@orahowdb ~]# yum erase postgres*
Loaded plugins: fastestmirror, refresh-packagekit, security, ulninfo, versionlock
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package postgresql12.x86_64 0:12.1-1PGDG.rhel6 will be erased
---> Package postgresql12-contrib.x86_64 0:12.1-1PGDG.rhel6 will be erased
---> Package postgresql12-debuginfo.x86_64 0:12.1-1PGDG.rhel6 will be erased
---> Package postgresql12-devel.x86_64 0:12.1-1PGDG.rhel6 will be erased
---> Package postgresql12-docs.x86_64 0:12.1-1PGDG.rhel6 will be erased
---> Package postgresql12-libs.x86_64 0:12.1-1PGDG.rhel6 will be erased
---> Package postgresql12-odbc.x86_64 0:12.00.0000-1PGDG.rhel6 will be erased
---> Package postgresql12-plperl.x86_64 0:12.1-1PGDG.rhel6 will be erased
---> Package postgresql12-plpython.x86_64 0:12.1-1PGDG.rhel6 will be erased
---> Package postgresql12-pltcl.x86_64 0:12.1-1PGDG.rhel6 will be erased
---> Package postgresql12-server.x86_64 0:12.1-1PGDG.rhel6 will be erased
---> Package postgresql12-test.x86_64 0:12.1-1PGDG.rhel6 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================
Package Arch Version Repository Size
Removing:
postgresql12 x86_64 12.1-1PGDG.rhel6 @pgdg12 7.7 M
postgresql12-contrib x86_64 12.1-1PGDG.rhel6 @pgdg12 1.9 M
postgresql12-debuginfo x86_64 12.1-1PGDG.rhel6 @pgdg12 43 M
postgresql12-devel x86_64 12.1-1PGDG.rhel6 @pgdg12 9.8 M
postgresql12-docs x86_64 12.1-1PGDG.rhel6 @pgdg12 35 M
postgresql12-libs x86_64 12.1-1PGDG.rhel6 @pgdg12 1.2 M
postgresql12-odbc x86_64 12.00.0000-1PGDG.rhel6 @pgdg12 1.0 M
postgresql12-plperl x86_64 12.1-1PGDG.rhel6 @pgdg12 174 k
postgresql12-plpython x86_64 12.1-1PGDG.rhel6 @pgdg12 337 k
postgresql12-pltcl x86_64 12.1-1PGDG.rhel6 @pgdg12 98 k
postgresql12-server x86_64 12.1-1PGDG.rhel6 @pgdg12 19 M
postgresql12-test x86_64 12.1-1PGDG.rhel6 @pgdg12 11 M
Transaction Summary
Remove 12 Package(s)
Installed size: 131 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Erasing : postgresql12-contrib-12.1-1PGDG.rhel6.x86_64 1/12
Erasing : postgresql12-test-12.1-1PGDG.rhel6.x86_64 2/12
Erasing : postgresql12-devel-12.1-1PGDG.rhel6.x86_64 3/12
Erasing : postgresql12-pltcl-12.1-1PGDG.rhel6.x86_64 4/12
Erasing : postgresql12-plpython-12.1-1PGDG.rhel6.x86_64 5/12
Erasing : postgresql12-odbc-12.00.0000-1PGDG.rhel6.x86_64 6/12
Erasing : postgresql12-plperl-12.1-1PGDG.rhel6.x86_64 7/12
Erasing : postgresql12-debuginfo-12.1-1PGDG.rhel6.x86_64 8/12
Erasing : postgresql12-server-12.1-1PGDG.rhel6.x86_64 9/12
Erasing : postgresql12-12.1-1PGDG.rhel6.x86_64 10/12
Erasing : postgresql12-libs-12.1-1PGDG.rhel6.x86_64 11/12
Erasing : postgresql12-docs-12.1-1PGDG.rhel6.x86_64 12/12
Verifying : postgresql12-devel-12.1-1PGDG.rhel6.x86_64 1/12
Verifying : postgresql12-server-12.1-1PGDG.rhel6.x86_64 2/12
Verifying : postgresql12-12.1-1PGDG.rhel6.x86_64 3/12
Verifying : postgresql12-plperl-12.1-1PGDG.rhel6.x86_64 4/12
Verifying : postgresql12-libs-12.1-1PGDG.rhel6.x86_64 5/12
Verifying : postgresql12-plpython-12.1-1PGDG.rhel6.x86_64 6/12
Verifying : postgresql12-contrib-12.1-1PGDG.rhel6.x86_64 7/12
Verifying : postgresql12-odbc-12.00.0000-1PGDG.rhel6.x86_64 8/12
Verifying : postgresql12-pltcl-12.1-1PGDG.rhel6.x86_64 9/12
Verifying : postgresql12-docs-12.1-1PGDG.rhel6.x86_64 10/12
Verifying : postgresql12-test-12.1-1PGDG.rhel6.x86_64 11/12
Verifying : postgresql12-debuginfo-12.1-1PGDG.rhel6.x86_64 12/12
Removed:
postgresql12.x86_64 0:12.1-1PGDG.rhel6 postgresql12-contrib.x86_64 0:12.1-1PGDG.rhel6 postgresql12-debuginfo.x86_64 0:12.1-1PGDG.rhel6
postgresql12-devel.x86_64 0:12.1-1PGDG.rhel6 postgresql12-docs.x86_64 0:12.1-1PGDG.rhel6 postgresql12-libs.x86_64 0:12.1-1PGDG.rhel6
postgresql12-odbc.x86_64 0:12.00.0000-1PGDG.rhel6 postgresql12-plperl.x86_64 0:12.1-1PGDG.rhel6 postgresql12-plpython.x86_64 0:12.1-1PGDG.rhel6
postgresql12-pltcl.x86_64 0:12.1-1PGDG.rhel6 postgresql12-server.x86_64 0:12.1-1PGDG.rhel6 postgresql12-test.x86_64 0:12.1-1PGDG.rhel6
Complete!
[root@orahowdb ~]#
STEP 4: List all the available PostgreSQL packages.
[root@orahowdb postgres_db]# yum list postgres*
Loaded plugins: fastestmirror, refresh-packagekit, security, ulninfo, versionlock
Loading mirror speeds from cached hostfile
Available Packages
postgresql-unit94.x86_64 2.0-1.rhel6 pgdg94
postgresql-unit94-debuginfo.x86_64 2.0-1.rhel6 pgdg94
postgresql-unit95.x86_64 1.0-1.rhel6 pgdg95
postgresql-unit95-debuginfo.x86_64 1.0-1.rhel6 pgdg95
postgresql-unit96.x86_64 2.0-1.rhel6 pgdg96
postgresql-unit96-debuginfo.x86_64 2.0-1.rhel6 pgdg96
postgresql10.x86_64 10.10-1PGDG.rhel6 pgdg10
postgresql10-contrib.x86_64 10.10-1PGDG.rhel6 pgdg10
postgresql10-debuginfo.x86_64 10.10-1PGDG.rhel6 pgdg10
postgresql10-devel.x86_64 10.10-1PGDG.rhel6 pgdg10
postgresql10-docs.x86_64 10.10-1PGDG.rhel6 pgdg10
postgresql10-libs.x86_64 10.10-1PGDG.rhel6 pgdg10
postgresql10-odbc.x86_64 12.00.0000-1PGDG.rhel6 pgdg10
postgresql10-plperl.x86_64 10.10-1PGDG.rhel6 pgdg10
postgresql10-plpython.x86_64 10.10-1PGDG.rhel6 pgdg10
postgresql10-pltcl.x86_64 10.10-1PGDG.rhel6 pgdg10
postgresql10-server.x86_64 10.10-1PGDG.rhel6 pgdg10
postgresql10-tcl.x86_64 2.4.0-1.rhel6 pgdg10
postgresql10-tcl-debuginfo.x86_64 2.3.1-1.rhel6 pgdg10
postgresql10-test.x86_64 10.10-1PGDG.rhel6 pgdg10
postgresql11.x86_64 11.5-1PGDG.rhel6 pgdg11
postgresql11-contrib.x86_64 11.5-1PGDG.rhel6 pgdg11
postgresql11-debuginfo.x86_64 11.5-1PGDG.rhel6 pgdg11
postgresql11-devel.x86_64 11.5-1PGDG.rhel6 pgdg11
postgresql11-docs.x86_64 11.5-1PGDG.rhel6 pgdg11
postgresql11-libs.x86_64 11.5-1PGDG.rhel6 pgdg11
postgresql11-odbc.x86_64 12.00.0000-1PGDG.rhel6 pgdg11
postgresql11-plperl.x86_64 11.5-1PGDG.rhel6 pgdg11
postgresql11-plpython.x86_64 11.5-1PGDG.rhel6 pgdg11
postgresql11-pltcl.x86_64 11.5-1PGDG.rhel6 pgdg11
postgresql11-server.x86_64 11.5-1PGDG.rhel6 pgdg11
postgresql11-tcl.x86_64 2.4.0-2.rhel6.1 pgdg11
postgresql11-test.x86_64 11.5-1PGDG.rhel6 pgdg11
postgresql12.x86_64 12.0-1PGDG.rhel6 pgdg12
postgresql12-contrib.x86_64 12.0-1PGDG.rhel6 pgdg12
postgresql12-debuginfo.x86_64 12.0-1PGDG.rhel6 pgdg12
postgresql12-devel.x86_64 12.0-1PGDG.rhel6 pgdg12
postgresql12-docs.x86_64 12.0-1PGDG.rhel6 pgdg12
postgresql12-libs.x86_64 12.0-1PGDG.rhel6 pgdg12
postgresql12-odbc.x86_64 12.00.0000-1PGDG.rhel6 pgdg12
postgresql12-plperl.x86_64 12.0-1PGDG.rhel6 pgdg12
postgresql12-plpython.x86_64 12.0-1PGDG.rhel6 pgdg12
postgresql12-pltcl.x86_64 12.0-1PGDG.rhel6 pgdg12
postgresql12-server.x86_64 12.0-1PGDG.rhel6 pgdg12
postgresql12-test.x86_64 12.0-1PGDG.rhel6 pgdg12
postgresql94.x86_64 9.4.24-1PGDG.rhel6 pgdg94
postgresql94-contrib.x86_64 9.4.24-1PGDG.rhel6 pgdg94
postgresql94-debuginfo.x86_64 9.4.24-1PGDG.rhel6 pgdg94
postgresql94-devel.x86_64 9.4.24-1PGDG.rhel6 pgdg94
postgresql94-docs.x86_64 9.4.24-1PGDG.rhel6 pgdg94
postgresql94-jdbc.x86_64 9.3.1101-1PGDG.rhel6 pgdg94
postgresql94-jdbc.noarch 9.4.1207-1.rhel6 pgdg95
postgresql94-jdbc-debuginfo.x86_64 9.3.1101-1PGDG.rhel6 pgdg94
postgresql94-jdbc-javadoc.noarch 9.4.1207-1.rhel6 pgdg95
postgresql94-libs.x86_64 9.4.24-1PGDG.rhel6 pgdg94
postgresql94-odbc.x86_64 12.00.0000-1PGDG.rhel6 pgdg94
postgresql94-odbc-debuginfo.x86_64 09.03.0400-1PGDG.rhel6 pgdg94
postgresql94-plperl.x86_64 9.4.24-1PGDG.rhel6 pgdg94
postgresql94-plpython.x86_64 9.4.24-1PGDG.rhel6 pgdg94
postgresql94-pltcl.x86_64 9.4.24-1PGDG.rhel6 pgdg94
postgresql94-server.x86_64 9.4.24-1PGDG.rhel6 pgdg94
postgresql94-tcl.x86_64 2.4.0-1.rhel6 pgdg94
postgresql94-tcl-debuginfo.x86_64 2.3.1-1.rhel6 pgdg94
postgresql94-test.x86_64 9.4.24-1PGDG.rhel6 pgdg94
postgresql95.x86_64 9.5.19-1PGDG.rhel6 pgdg95
postgresql95-contrib.x86_64 9.5.19-1PGDG.rhel6 pgdg95
postgresql95-debuginfo.x86_64 9.5.19-1PGDG.rhel6 pgdg95
postgresql95-devel.x86_64 9.5.19-1PGDG.rhel6 pgdg95
postgresql95-docs.x86_64 9.5.19-1PGDG.rhel6 pgdg95
postgresql95-libs.x86_64 9.5.19-1PGDG.rhel6 pgdg95
postgresql95-odbc.x86_64 12.00.0000-1PGDG.rhel6 pgdg95
postgresql95-odbc-debuginfo.x86_64 09.03.0400-1PGDG.rhel6 pgdg95
postgresql95-plperl.x86_64 9.5.19-1PGDG.rhel6 pgdg95
postgresql95-plpython.x86_64 9.5.19-1PGDG.rhel6 pgdg95
postgresql95-pltcl.x86_64 9.5.19-1PGDG.rhel6 pgdg95
postgresql95-server.x86_64 9.5.19-1PGDG.rhel6 pgdg95
postgresql95-tcl.x86_64 2.4.0-1.rhel6 pgdg95
postgresql95-tcl-debuginfo.x86_64 2.3.1-1.rhel6 pgdg95
postgresql95-test.x86_64 9.5.19-1PGDG.rhel6 pgdg95
postgresql96.x86_64 9.6.15-1PGDG.rhel6 pgdg96
postgresql96-contrib.x86_64 9.6.15-1PGDG.rhel6 pgdg96
postgresql96-debuginfo.x86_64 9.6.15-1PGDG.rhel6 pgdg96
postgresql96-devel.x86_64 9.6.15-1PGDG.rhel6 pgdg96
postgresql96-docs.x86_64 9.6.15-1PGDG.rhel6 pgdg96
postgresql96-libs.x86_64 9.6.15-1PGDG.rhel6 pgdg96
postgresql96-odbc.x86_64 12.00.0000-1PGDG.rhel6 pgdg96
postgresql96-plperl.x86_64 9.6.15-1PGDG.rhel6 pgdg96
postgresql96-plpython.x86_64 9.6.15-1PGDG.rhel6 pgdg96
postgresql96-pltcl.x86_64 9.6.15-1PGDG.rhel6 pgdg96
postgresql96-server.x86_64 9.6.15-1PGDG.rhel6 pgdg96
postgresql96-tcl.x86_64 2.4.0-1.rhel6 pgdg96
postgresql96-tcl-debuginfo.x86_64 2.3.1-1.rhel6 pgdg96
postgresql96-test.x86_64 9.6.15-1PGDG.rhel6 pgdg96
postgresql_anonymizer10.noarch 0.3.0-1.rhel6 pgdg10
postgresql_anonymizer10.x86_64 0.4.1-2.rhel6 pgdg10
postgresql_anonymizer10-debuginfo.x86_64 0.4.1-2.rhel6 pgdg10
postgresql_anonymizer11.noarch 0.3.0-1.rhel6 pgdg11
postgresql_anonymizer11.x86_64 0.4.1-2.rhel6 pgdg11
postgresql_anonymizer11-debuginfo.x86_64 0.4.1-2.rhel6 pgdg11
postgresql_anonymizer12.noarch 0.3.1-1.rhel6 pgdg12
postgresql_anonymizer12.x86_64 0.4.1-2.rhel6 pgdg12
postgresql_anonymizer12-debuginfo.x86_64 0.4.1-2.rhel6 pgdg12
postgresql_anonymizer95.noarch 0.3.0-1.rhel6 pgdg95
postgresql_anonymizer95.x86_64 0.4.1-2.rhel6 pgdg95
postgresql_anonymizer95-debuginfo.x86_64 0.4.1-2.rhel6 pgdg95
postgresql_anonymizer96.noarch 0.3.0-1.rhel6 pgdg96
postgresql_anonymizer96.x86_64 0.4.1-2.rhel6 pgdg96
postgresql_anonymizer96-debuginfo.x86_64 0.4.1-2.rhel6 pgdg96
STEP 5: Install Postgres Repository RPM using PostgreSQL Yum Repository.
PostgreSQL provides repository of packages of all the supported version(PostgreSQL 9.4, 9.5, 9.6, 10, 11, 12) for almost all the Linux and windows distribution. Please select the required PostgreSQL version, operating system and architecture to install the RPM repository. To download Repository: https://www.postgresql.org/download/
Steps to Download PostgreSQL RPM: https://orahow.com/postgresql-download/
[root@orahowdb postgres_db]# yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-6-x86_64/pgdg-redhat-repo-latest.noarch.rpm
Loaded plugins: fastestmirror, refresh-packagekit, security, ulninfo, versionlock
Setting up Install Process
pgdg-redhat-repo-latest.noarch.rpm | 5.9 kB 00:00
Examining /var/tmp/yum-root-SjWTAL/pgdg-redhat-repo-latest.noarch.rpm: pgdg-redhat-repo-42.0-6.noarch
Marking /var/tmp/yum-root-SjWTAL/pgdg-redhat-repo-latest.noarch.rpm as an update to pgdg-redhat-repo-42.0-5.noarch
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package pgdg-redhat-repo.noarch 0:42.0-5 will be updated
---> Package pgdg-redhat-repo.noarch 0:42.0-6 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================
Package Arch Version Repository Size
Updating:
pgdg-redhat-repo noarch 42.0-6 /pgdg-redhat-repo-latest.noarch 7.5 k
Transaction Summary
Upgrade 1 Package(s)
Total size: 7.5 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : pgdg-redhat-repo-42.0-6.noarch 1/2
Cleanup : pgdg-redhat-repo-42.0-5.noarch 2/2
Verifying : pgdg-redhat-repo-42.0-6.noarch 1/2
Verifying : pgdg-redhat-repo-42.0-5.noarch 2/2
Updated:
pgdg-redhat-repo.noarch 0:42.0-6
Complete!
[root@den01dsu postgres_db]# pwd
/scratch/postgres/postgres_db
Note: You can also first download the package and then install using below command.
[root@orahowdb postgres_db]# wget https://download.postgresql.org/pub/repos/yum/reporpms/EL-6-x86_64/pgdg-redhat-repo-latest.noarch.rpm
[root@orahowdb postgres_db]# yum install pgdg-redhat-repo-latest.noarch.rpm
STEP 6: Install PostgrSQL from the Repository.
[root@orahowdb postgres_db]# pwd
/scratch/postgres/postgres_db
[root@den01dsu postgres_db]# yum install postgresql12*
Loaded plugins: fastestmirror, refresh-packagekit, security, ulninfo, versionlock
Setting up Install Process
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package postgresql12.x86_64 0:12.1-1PGDG.rhel6 will be installed
---> Package postgresql12-contrib.x86_64 0:12.1-1PGDG.rhel6 will be installed
---> Package postgresql12-debuginfo.x86_64 0:12.1-1PGDG.rhel6 will be installed
---> Package postgresql12-devel.x86_64 0:12.1-1PGDG.rhel6 will be installed
---> Package postgresql12-docs.x86_64 0:12.1-1PGDG.rhel6 will be installed
---> Package postgresql12-libs.x86_64 0:12.1-1PGDG.rhel6 will be installed
---> Package postgresql12-odbc.x86_64 0:12.00.0000-1PGDG.rhel6 will be installed
---> Package postgresql12-plperl.x86_64 0:12.1-1PGDG.rhel6 will be installed
---> Package postgresql12-plpython.x86_64 0:12.1-1PGDG.rhel6 will be installed
---> Package postgresql12-pltcl.x86_64 0:12.1-1PGDG.rhel6 will be installed
---> Package postgresql12-server.x86_64 0:12.1-1PGDG.rhel6 will be installed
---> Package postgresql12-test.x86_64 0:12.1-1PGDG.rhel6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================
Package Arch Version Repository Size
Installing:
postgresql12 x86_64 12.1-1PGDG.rhel6 pgdg12 1.6 M
postgresql12-contrib x86_64 12.1-1PGDG.rhel6 pgdg12 531 k
postgresql12-debuginfo x86_64 12.1-1PGDG.rhel6 pgdg12 10 M
postgresql12-devel x86_64 12.1-1PGDG.rhel6 pgdg12 2.2 M
postgresql12-docs x86_64 12.1-1PGDG.rhel6 pgdg12 11 M
postgresql12-libs x86_64 12.1-1PGDG.rhel6 pgdg12 337 k
postgresql12-odbc x86_64 12.00.0000-1PGDG.rhel6 pgdg12 313 k
postgresql12-plperl x86_64 12.1-1PGDG.rhel6 pgdg12 56 k
postgresql12-plpython x86_64 12.1-1PGDG.rhel6 pgdg12 89 k
postgresql12-pltcl x86_64 12.1-1PGDG.rhel6 pgdg12 36 k
postgresql12-server x86_64 12.1-1PGDG.rhel6 pgdg12 5.4 M
postgresql12-test x86_64 12.1-1PGDG.rhel6 pgdg12 1.9 M
Transaction Summary
Install 12 Package(s)
Total download size: 34 M
Installed size: 131 M
Is this ok [y/N]: y
Downloading Packages:
(1/12): postgresql12-12.1-1PGDG.rhel6.x86_64.rpm | 1.6 MB 00:02
(2/12): postgresql12-contrib-12.1-1PGDG.rhel6.x86_64.rpm | 531 kB 00:00
(3/12): postgresql12-debuginfo-12.1-1PGDG.rhel6.x86_64.rpm | 10 MB 00:13
(4/12): postgresql12-devel-12.1-1PGDG.rhel6.x86_64.rpm | 2.2 MB 00:02
(5/12): postgresql12-docs-12.1-1PGDG.rhel6.x86_64.rpm | 11 MB 00:14
(6/12): postgresql12-libs-12.1-1PGDG.rhel6.x86_64.rpm | 337 kB 00:00
(7/12): postgresql12-odbc-12.00.0000-1PGDG.rhel6.x86_64.rpm | 313 kB 00:00
(8/12): postgresql12-plperl-12.1-1PGDG.rhel6.x86_64.rpm | 56 kB 00:00
(9/12): postgresql12-plpython-12.1-1PGDG.rhel6.x86_64.rpm | 89 kB 00:00
(10/12): postgresql12-pltcl-12.1-1PGDG.rhel6.x86_64.rpm | 36 kB 00:00
(11/12): postgresql12-server-12.1-1PGDG.rhel6.x86_64.rpm | 5.4 MB 00:07
(12/12): postgresql12-test-12.1-1PGDG.rhel6.x86_64.rpm | 1.9 MB 00:02
Total 734 kB/s | 34 MB 00:47
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : postgresql12-libs-12.1-1PGDG.rhel6.x86_64 1/12
Installing : postgresql12-12.1-1PGDG.rhel6.x86_64 2/12
Installing : postgresql12-server-12.1-1PGDG.rhel6.x86_64 3/12
Installing : postgresql12-devel-12.1-1PGDG.rhel6.x86_64 4/12
Installing : postgresql12-test-12.1-1PGDG.rhel6.x86_64 5/12
Installing : postgresql12-plperl-12.1-1PGDG.rhel6.x86_64 6/12
Installing : postgresql12-plpython-12.1-1PGDG.rhel6.x86_64 7/12
Installing : postgresql12-pltcl-12.1-1PGDG.rhel6.x86_64 8/12
Installing : postgresql12-contrib-12.1-1PGDG.rhel6.x86_64 9/12
Installing : postgresql12-odbc-12.00.0000-1PGDG.rhel6.x86_64 10/12
Installing : postgresql12-debuginfo-12.1-1PGDG.rhel6.x86_64 11/12
Installing : postgresql12-docs-12.1-1PGDG.rhel6.x86_64 12/12
Verifying : postgresql12-devel-12.1-1PGDG.rhel6.x86_64 1/12
Verifying : postgresql12-server-12.1-1PGDG.rhel6.x86_64 2/12
Verifying : postgresql12-12.1-1PGDG.rhel6.x86_64 3/12
Verifying : postgresql12-plperl-12.1-1PGDG.rhel6.x86_64 4/12
Verifying : postgresql12-libs-12.1-1PGDG.rhel6.x86_64 5/12
Verifying : postgresql12-plpython-12.1-1PGDG.rhel6.x86_64 6/12
Verifying : postgresql12-contrib-12.1-1PGDG.rhel6.x86_64 7/12
Verifying : postgresql12-odbc-12.00.0000-1PGDG.rhel6.x86_64 8/12
Verifying : postgresql12-pltcl-12.1-1PGDG.rhel6.x86_64 9/12
Verifying : postgresql12-docs-12.1-1PGDG.rhel6.x86_64 10/12
Verifying : postgresql12-test-12.1-1PGDG.rhel6.x86_64 11/12
Verifying : postgresql12-debuginfo-12.1-1PGDG.rhel6.x86_64 12/12
Installed:
postgresql12.x86_64 0:12.1-1PGDG.rhel6 postgresql12-contrib.x86_64 0:12.1-1PGDG.rhel6 postgresql12-debuginfo.x86_64 0:12.1-1PGDG.rhel6
postgresql12-devel.x86_64 0:12.1-1PGDG.rhel6 postgresql12-docs.x86_64 0:12.1-1PGDG.rhel6 postgresql12-libs.x86_64 0:12.1-1PGDG.rhel6
postgresql12-odbc.x86_64 0:12.00.0000-1PGDG.rhel6 postgresql12-plperl.x86_64 0:12.1-1PGDG.rhel6 postgresql12-plpython.x86_64 0:12.1-1PGDG.rhel6
postgresql12-pltcl.x86_64 0:12.1-1PGDG.rhel6 postgresql12-server.x86_64 0:12.1-1PGDG.rhel6 postgresql12-test.x86_64 0:12.1-1PGDG.rhel6
Complete!
[root@den01dsu postgres_db]#
STEP 7: switch to Postgres user and now initialize the Database Server.
[root@orahowdb postgres_db]# su - postgres
bash-4.1$ id
uid=54323(postgres) gid=54323(postgres) groups=54323(postgres)
bash-4.1$ pwd
/scratch/postgres/postgres_db/db_home
bash-4.1$ ls -lrt
total 0
bash-4.1$ /usr/pgsql-12/bin/initdb -D /scratch/postgres/postgres_db/db_home
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /scratch/postgres/postgres_db/db_home … ok
creating subdirectories … ok
selecting dynamic shared memory implementation … posix
selecting default max_connections … 100
selecting default shared_buffers … 128MB
selecting default time zone … PST8PDT
creating configuration files … ok
running bootstrap script … ok
performing post-bootstrap initialization … ok
syncing data to disk … ok
initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
Success. You can now start the database server using:
/usr/pgsql-12/bin/pg_ctl -D /scratch/postgres/postgres_db/db_home -l logfile start
bash-4.1$
STEP 8: Login as root user and change the below directory permission.
[root@orahowdb postgres_db]# chown -R postgres:postgres /var/lib/pgsql/
[root@orahowdb postgres_db]# exit
STEP 9: Login as Postgres and Start PostgreSQL Server
bash-4.1$ id
uid=54323(postgres) gid=54323(postgres) groups=54323(postgres)
bash-4.1$ /usr/pgsql-12/bin/pg_ctl -D /scratch/postgres/postgres_db/db_home/ -l logfile start
waiting for server to start…. done
server started
bash-4.1$ ps -ef|grep postgres
root 61010 60903 0 01:32 pts/0 00:00:00 su - postgres
postgres 61011 61010 0 01:32 pts/0 00:00:00 -bash
postgres 61080 61011 0 01:32 pts/0 00:00:00 bash
postgres 63471 1 0 01:39 ? 00:00:00 /usr/pgsql-12/bin/postgres -D /scratch/postgres/postgres_db/db_home
postgres 63472 63471 0 01:39 ? 00:00:00 postgres: logger
postgres 63474 63471 0 01:39 ? 00:00:00 postgres: checkpointer
postgres 63475 63471 0 01:39 ? 00:00:00 postgres: background writer
postgres 63476 63471 0 01:39 ? 00:00:00 postgres: walwriter
postgres 63477 63471 0 01:39 ? 00:00:00 postgres: autovacuum launcher
postgres 63478 63471 0 01:39 ? 00:00:00 postgres: stats collector
postgres 63479 63471 0 01:39 ? 00:00:00 postgres: logical replication launcher
postgres 63587 61080 2 01:39 pts/0 00:00:00 ps -ef
postgres 63588 61080 0 01:39 pts/0 00:00:00 grep postgres
STEP 10: Login to Postgres and create database and Users.
bash-4.1$ psql
psql (12.1)
Type "help" for help.
postgres=#
bash-4.1$ createdb pgdb
PostgreSQL Create User - To Create User in postgreSQL
https://orahow.com/create-user-in-postgresql/
How to check all database running in Postgres?
That’s all about PostgreSQL Installation. Please check PostgreSQL Categories for more articles on Postgres.