Install and Configure PostgreSQL 9.4 on CentOS 7/6/5 Linux Systems

undefined

In this article we will install and configure postgresql 9.4 on Linux systems (RPM Family “Redhat /CentOS /Scientific Linux  releases 7/6/5  and Fedora 21/20/19”). We will setup the required repositories then install and configure the postgresql service.

PostgreSQL is an open source object-relational, highly scalable, SQL compliant database management system. PostgreSQL is developed at the University of California at Berkeley Computer Science Department. This article will help you for installing PostgreSQL on CentOS, RHEL releases 7/6/5 and Fedora 21/20/19 Linux systems.

Step 1: Adding PostgreSQL Yum Repository

First step is to install PostgreSQL repository in your system, Use one of below commands as per your system architecture and operating system.

CentOS/RHEL 7
# rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-1.noarch.rpm

CentOS/RHEL 6
# rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-redhat94-9.4-1.noarch.rpm

CentOS/RHEL 5
# rpm -Uvh http://yum.postgresql.org/9.4/redhat/rhel-5-x86_64/pgdg-redhat94-9.4-1.noarch.rpm

Fedora 21:
# rpm -Uvh http://yum.postgresql.org/9.4/fedora/fedora-21-x86_64/pgdg-fedora94-9.4-2.noarch.rpm

Fedora 20
# rpm -Uvh http://yum.postgresql.org/9.4/fedora/fedora-20-x86_64/pgdg-fedora94-9.4-1.noarch.rpm

Fedora 19
# rpm -Uvh http://yum.postgresql.org/9.4/fedora/fedora-19-x86_64/pgdg-fedora94-9.4-1.noarch.rpm

For more details visit PostgreSQL repositories link page where you can get repository package rpm for various operating systems.

Step 2: Installing PostgreSQL Server

After enabling PostgreSQL yum repository in your system use following command to install PostgreSQL 9.4.X on your system with yum package manager.

# yum install postgresql94-server postgresql94

Step 3: Initializing PGDATA

After installing PostgreSQL server, It’s required to initialize it before using first time. To initialize database use below command.

# /usr/pgsql-9.4/bin/postgresql94-setup initdb

Above command will take some time to initialize PostgreSQL first time. PGDATA environment variable contains the path of data directory.

PostgreSQL data directory Path: /var/lib/pgsql/9.4/data/

Step 4: Start PostgreSQL Server

To start PostgreSQL service using following command as per your operating systems. Also enable PostgreSQL service to auto start on system boot.

  • For CentOS/RHEL 7 and Fedora 21
# systemctl start postgresql-9.4
# systemctl enable postgresql-9.4
  • For CentOS/RHEL 6/5 and Fedora 20/19
# service  postgresql-9.4 start
# chkconfig postgresql-9.3 on

Step 5: Verify PostgreSQL Installation

After completing above steps, you have installed PostgreSQL 9.4 on your server, Let’s login to postfix to verify that installation completed successfully.

# su - postgres

Use psql command to access PostgreSQL prompt with admin privileges.

$ psql


psql (9.4.1)
Type "help" for help.

postgres=#

You may create password for user postgres for security purpose.

postgres=# password postgres

Congratulation’s! You have successfully installed PostgreSQL 9.4 Server on RPM family Linux systems.

Summary

In this article we have explained the installation and configuration steps for installing postgresql 9.4 database server on RPM family of Linux systems. We first installed the needed repositories on Linux systems (RPM Family “Redhat /CentOS /Scientific Linux  releases 7/6/5  and Fedora 21/20/19”) then installed and configured the postgresql 9.4 server. We enabled and started the postgresql service and finally we set the password for postgres database’s user.

I hope this article is good enough for you.
See you in other articles.

If You Appreciate What We Do Here On Mimastech, You Should Consider:

  1. Stay Connected to: Facebook | Twitter | Google+
  2. Support us via PayPal Donation
  3. Subscribe to our email newsletters.
  4. Tell other sysadmins / friends about Us - Share and Like our posts and services

We are thankful for your never ending support.

Leave a Reply

Your email address will not be published. Required fields are marked *