Installation of PostgreSQL Through YUM & RPM Methods
These are another two methods of installation of PostgreSQL in Linux systems:
1 – YUM Installation.
2 – RPM Installation
Installation of PostgreSQL through YUM package manager in Linux System:
If you are using a Linux system, one of the most common ways to install software packages is by using a package manager. In Red Hat-based systems, the default package manager is yum (“Yellow dog Updater, Modified”).
First go to the official website postgresql.org and select Linux / red hat distribution or click on the direct link: PostgreSQL: Linux downloads (Red Hat family)
Navigate through the yum repository, and fill the following steps:
1 – Select version >> 11/12/13/14/15.
2 – Select Platform:
To know your oracle version run the following command in your Linux terminal:
1 2 3 4 5 6 |
[root@postgres1 ~]# cat /etc/os-release NAME="Oracle Linux Server" VERSION="6.9" ID="ol" VERSION_ID="6.9" PRETTY_NAME="Oracle Linux Server 6.9" |
3 – Select architecture >> x86_64 (default)
Now copy the setup script to run each command in the Linux terminal.
1 2 3 4 5 6 7 8 |
[root@postgres1 ~]# sudo yum install –y https://download.postgresql.org/pub/repos/yum/reporpms/EL-6-x86_64/pgdg-redhat-repo-latest.noarch.rpm [root@postgres1 ~]# sudo yum install -y postgresql11-server Complete! [root@postgres1 ~]# sudo service postgresql-11 initdb Initializing database: [ OK ] [root@postgres1 ~]# sudo chkconfig postgresql-11 on [root@postgres1 ~]# sudo service postgresql-11 start Starting postgresql-11 service: [ OK ] |
To verify the PostgreSQL is installed in your Linux system run the following command:
1 2 3 4 5 6 7 8 9 10 11 |
[root@postgres1 ~]# ps –efa|grep postgres postgres 4894 1 0 21:47 ? 00:00:00 /usr/pgsql-11/bin/postmaster -D /var/lib/pgsql/11/data postgres 4896 4894 0 21:47 ? 00:00:00 postgres: logger postgres 4898 4894 0 21:47 ? 00:00:00 postgres: checkpointer postgres 4899 4894 0 21:47 ? 00:00:00 postgres: background writer postgres 4900 4894 0 21:47 ? 00:00:00 postgres: walwriter postgres 4901 4894 0 21:47 ? 00:00:00 postgres: autovacuum launcher postgres 4902 4894 0 21:47 ? 00:00:00 postgres: stats collector postgres 4903 4894 0 21:47 ? 00:00:00 postgres: logical replication launcher root 4917 3490 0 21:48 pts/1 00:00:00 grep postgres [root@postgres1 ~]# cd /usr/pgsql-11 |
List the contents of the directory to ensure that PostgreSQL is Installed:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
[root@postgres1 pgsql-11]# ll total 12 drwxr-xr-x. 2 root root 4096 Mar 25 21:45 bin drwxr-xr-x. 2 root root 4096 Mar 25 21:45 lib drwxr-xr-x. 7 root root 4096 Mar 25 21:45 share [root@postgres1 pgsql-11]# cd /var/lib/pgsql/ll/data [root@postgres1 data]# su – postgres the creation of user and data directly done by system automatically -bash-4.1$ psql -bash-4.1$ hostname server.oracle.com -bash-4.1$ psql -p 5432 -d postgres -U postgres Psql (8.4.20,server 11.16) Postgres=# create database hrms; CREATE DATABASE Postgres=# \q -bash-4.1$ psql -d hrms -U postgres hrms=# select current_user; hrms=# create user odxa with password ‘odxa’; hrms=# \q -bash-4.1$ psql -d hrms -U odxa Hrms=> select current_user; current_user odxa (1 row) |
RPM INSTALLATION:
Before you install the application, it is recommended to check few prerequisites.
To check the version of GNU Make installed on your system, run the following command in the terminal:
1 2 3 4 5 |
[root@postgres1 ~]# make -version GNU Make 3.81 This program built for x86_64-redhat-linux-gnu [root@postgres1 ~]# rpm -qa gcc gcc-4.4.7-23.0.1.el6.x86_64 |
There are also some Optional prerequisites that you may want to check:
1 2 3 4 |
[root@postgres1 ~]# rpm -qa readline readline-6.0-4.el6.x86_64 [root@postgres1 ~]# rpm -qa zlib zlib-1.2.3-29.el6.x86_64 |
Installation:
1 – Download the RPM Packages
Firstly, you should download the RPM packages from the official PostgreSQL Yum repository by the below steps:
- Navigate through official website https://yum.postgresql.org/rpmchart/
- Select the appropriate operating System and Architecture form the “Select version and OS” section.
As you have downloaded multiple RPM packages, you should install them in the following order:
- Postgresql-libs
- Postgresql
- Postgresql-server
- Postgresql-contrib
Now run the following commands in command line interface to download RPM packages in Linux System.
1 2 3 4 5 6 7 8 |
[root@postgres1 ~]# wget<a href="https://yum.postgresql.org/11/redhat/rhel-6-x86_64/pgresql11-libs-11.19-1PGDG.rhel6.x86_64.rpm"> https://yum.postgresql.org/11/redhat/rhel-6-x86_64/pgresql11-libs-11.19-1PGDG.rhel6.x86_64.rpm</a> 2023-03-25 20:45:56 (331 KB/s) - “postgresql11-libs-11.19-1PGDG.rhel6.x86_64.rpm” [root@postgres1 ~]# wget <a href="https://yum.postgresql.org/11/redhat/rhel-6-x86_64/postgresql11-11.19-1PGDG.rhel6.x86_64.rpm">https://yum.postgresql.org/11/redhat/rhel-6-x86_64/postgresql11-11.19-1PGDG.rhel6.x86_64.rpm</a> 2023-03-25 21:10:57 (344 KB/s) - “postgresql11-11.19-1PGDG.rhel6.x86_64.rpm” [root@postgres1 ~]# wget <a href="https://yum.postgresql.org/11/redhat/rhel-6-x86_64/postgresql11-server-11.19-1PGDG.rhel6.x86_64.rpm">https://yum.postgresql.org/11/redhat/rhel-6-x86_64/postgresql11-server-11.19-1PGDG.rhel6.x86_64.rpm </a>2023-03-25 21:26:10 (387 KB/s) - “postgresql11-server-11.19-1PGDG.rhel6.x86_64.rpm” [root@postgres1 ~]# wget <a href="https://yum.postgresql.org/11/redhat/rhel-6-x86_64/postgresql11-contrib-11.19-1PGDG.rhel6.x86_64.rpm">https://yum.postgresql.org/11/redhat/rhel-6-x86_64/postgresql11-contrib-11.19-1PGDG.rhel6.x86_64.rpm </a>2023-03-25 21:38:57 (329 KB/s) - “postgresql11-contrib-11.19-1PGDG.rhel6.x86_64.rpm” |
2 – Install the RPM Packages
After downloading the packages, you can install them using the rpm command as shown below:
1 2 3 4 |
[root@postgres1 ~]# rpm -ivh postgresql11-libs-11.19- 1PGDG.rhel6.x86_64.rpm [root@postgres1 ~]# rpm -ivh postgresql11-11.19-1PGDG.rhel6.x86_64.rpm [root@postgres1 ~]# rpm -ivh postgresql11-server-11.19-1PGDG.rhel6.x86_64.rpm [root@postgres1 ~]# rpm -ivh postgresql11-contrib-11.19-1PGDG.rhel6.x86_64.rpm |
3 – Verify the installation:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
[root@postgres1 ~]# cd /usr/pgsql-11/ [root@postgres1 pgsql-11]# pwd /usr/pgsql-11 List the contents of the directory to ensure that PostgreSQL is Installed: [root@postgres1 pgsql-11]# ll total 16 drwxr-xr-x. 2 root root 4096 Mar 25 21:45 bin drwxr-xr-x. 3 root root 4096 Mar 25 21:45 doc drwxr-xr-x. 2 root root 4096 Mar 25 21:45 lib drwxr-xr-x. 7 root root 4096 Mar 25 21:45 share [root@postgres1 bin]# ls -lrt psql -rwxr-xr-x. 1 root root 612112 Feb 9 15:54 psql [root@postgres1 bin]# sudo service postgresql-11 initdb Initializing database: [ OK ] [root@postgres1 bin]# sudo service postgresql-11 start Starting postgresql-11 service: [ OK ] Check the status of the PostgreSQL server by running the following command: [root@postgres1 bin]# ps -efa|grep postgres postgres 4894 1 0 21:47 ? 00:00:00 /usr/pgsql-11/bin/postmaster -D /var/lib/pgsql/11/data postgres 4896 4894 0 21:47 ? 00:00:00 postgres: logger postgres 4898 4894 0 21:47 ? 00:00:00 postgres: checkpointer postgres 4899 4894 0 21:47 ? 00:00:00 postgres: background writer postgres 4900 4894 0 21:47 ? 00:00:00 postgres: walwriter postgres 4901 4894 0 21:47 ? 00:00:00 postgres: autovacuum launche postgres 4902 4894 0 21:47 ? 00:00:00 postgres: stats collector postgres 4903 4894 0 21:47 ? 00:00:00 postgres: logical replication launcher root 4917 3490 0 21:48 pts/1 00:00:00 grep postgres To connect to the postgressql run the following command: [root@postgres1 bin]# su – postgres -bash-4.1$ psql psql (11.19) postgres=# CREATE DATABASE dbname; CREATE DATABASE postgres=# \1 List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges ------------------------------------------------------------------------------------- dbname | postgres | UTF8 postgres | en_US.UTF-8 | en_US.UTF-8 | postgres | postgres | UTF8 postgres | en_US.UTF-8 | en_US.UTF-8 | template0 | postgres | UTF8 postgres | en_US.UTF-8 | en_US.UTF-8 | =c/postgres postgres=CTc/postgres template1 | postgres | UTF8 postgres | en_US.UTF-8 | en_US.UTF-8 | =c/postgres postgres=CTc/postgres (4 rows) postgres=# \q -bash-4.1$ exit logout |
Author : Prudhvi Teja |
LinkedIn : http://linkedin.com/in/prudhvi-teja-nagabhyru-715052224
Thank you for giving your valuable time to read the above information. Please click here to subscribe for further updates
KTExperts is always active on social media platforms.
Facebook : https://www.facebook.com/ktexperts/
LinkedIn : https://www.linkedin.com/company/ktexperts/
Twitter : https://twitter.com/ktexpertsadmin
YouTube : https://www.youtube.com/c/ktexperts
Instagram : https://www.instagram.com/knowledgesharingplatform