CyberKeeda In Social Media

How to Install PostgreSQL Relational Database on CentOS



PostgreSQL is a powerful, open source object-relational database system with over 30 years of active development that has earned it a strong reputation for reliability, feature robustness, and performance.
Official link : Here 

Let's know how to install PostgreSQL on CentOS 7.
  Note :   Video Tutorial at the bottom of the blog post

Method 1

Install from CentOS repository.
For the time being CentOS 7 repositories ship with PostgreSQL version 9.2.15
To install from the CentOS repositories, simply run:
 sudo yum install postgresql-server postgresql-contrib
Now lets Initialize your Postgres database and start PostgreSQL and configure it to start on Boot
#  sudo postgresql-setup initdb 
#  sudo systemctl start postgresql
#  sudo systemctl enable postgresql

Method 2.

Install the latest stable version of PostgreSQL from Postgres Repository
Official repository link :  Here

Note : Currently official repositiry provides packages based on RPM distribution ( Redhat/CentOS/Fedora...)

Select the version you wish to install from the Postgres Yum repositories.
Locate the CentOS 7 link for your chosen version and download it to your Centos 7 host.
For the time being, I'm selecting Postgresql 9.6.3, choose as per your requirement.

#  wget https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
Install the downloaded postgres rpm package and install centos epel too.
#  rpm -ivh pgdg-centos96-9.6-3.noarch.rpm
#  yum install epel-release
Now we are almost all set to install PostgreSQL.

Update Yum to apply your changes and install PostgreSQL.
When installing Postgres manually, you will have to specify the version, we will be installaing postgresql-9.6
#  sudo yum update
#  sudo yum install postgresql96-server postgresql96-contrib
Important Point to notice.
When Postgres is installed using above method 2, the version number is included in its configuration directories. For example, /var/lib/pgsql becomes /var/lib/pgsql/9.6. 
This is also the case with systemd units
systemctl status postgresql becomes systemctl status postgresql-9.6
Now lets Initialize your Postgres database and start PostgreSQL and configure it to start on Boot.
#  sudo /usr/pgsql-9.6/bin/postgresql96-setup initdb
#  sudo systemctl start postgresql-9.6
#  sudo systemctl enable postgresql-9.6
And we are done..

In case you are looking for the Installation Video Tutorial, below is the stuff.





No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...
Designed By Kunal Saha