How to Install PostgreSQL 10 on CentOS/RHEL and Fedora

Channel: PostgreSQL Linux
Abstract: --------------- On 32-Bit RHEL/CentOS 6 and Scientific Linux/Oracle Linux 6 ------------------------------ On RHEL/CentOS 7 and Scientific Linux/Oracl

PostgreSQL is a powerful, highly scalable, open source and cross-platform object-relational database system that runs on Unix-like operating systems including Linux and Windows OS. It is an enterprise level database system which is highly reliable and offers data integrity and correctness to users.

In this article, we will explain how to install latest version of PostgreSQL 10 on CentOS, RHEL, Oracle Enterprise Linux, Scientific Linux and Fedora using official PostgreSQL Yum repository.

Add PostgreSQL Yum Repository

This official PostgreSQL Yum repository will combine with your Linux system and offers automatic updates for all supported versions of PostgreSQL on RedHat based distributions such as CentOS, Scientific Linux and Scientific Linux, as well as current versions of Fedora.

Note that due to the shorter Fedora support cycle, not all versions are available and we suggest that do not use Fedora for server deployments.

To use the yum repository, follow these steps:

--------------- On RHEL/CentOS 7 and Scientific Linux/Oracle Linux 7 --------------- 
# yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-redhat10-10-1.noarch.rpm

--------------- On 64-Bit RHEL/CentOS 6 and Scientific Linux/Oracle Linux 6 --------------- 
# yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-6-x86_64/pgdg-redhat10-10-1.noarch.rpm

--------------- On 32-Bit RHEL/CentOS 6 and Scientific Linux/Oracle Linux 6 --------------- 
# yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-6-i386/pgdg-redhat10-10-1.noarch.rpm

--------------- On Fedora 26 --------------- 
# dnf install https://download.postgresql.org/pub/repos/yum/10/fedora/fedora-26-x86_64/pgdg-fedora10-10-2.noarch.rpm

--------------- On Fedora 25 --------------- 
# dnf install https://download.postgresql.org/pub/repos/yum/10/fedora/fedora-25-x86_64/pgdg-fedora10-10-3.noarch.rpm

--------------- On Fedora 24 --------------- 
# dnf install https://download.postgresql.org/pub/repos/yum/10/fedora/fedora-24-x86_64/pgdg-fedora10-10-3.noarch.rpm
Enable PostgreSQL Yum Repository Install PostgreSQL Server

After adding PostgreSQL yum repository in your respective Linux distribution, use the following command to install PostgreSQL server and client packages.

# yum install postgresql10-server postgresql10   [On RedHat based Distributions]
# dnf install postgresql10-server postgresql10   [On Fedora Linux]
Install PostgreSQL Server

Important: PostgreSQL data directory /var/lib/pgsql/10/data/ contains all of the data files for the database.

Initialize PostgreSQL Database

Due to some policies for Red Hat based distributions, the PostgreSQL installation will not be active for automatic start or have the database initialized automatically. To complete your database installation, you need to initialize your database before using it for first time.

# /usr/pgsql-10/bin/postgresql-10-setup initdb
Initialize PostgreSQL Database Start and Enable PostgreSQL Server

After database initialize completes, start PostgreSQL service and enable PostgreSQL service to auto start on system boot.

--------------- On SystemD --------------- 
# systemctl start postgresql-10
# systemctl enable postgresql-10
# systemctl status postgresql-10 

--------------- On SysVinit --------------- 
# service postgresql-10 start
# chkconfig postgresql-10 on
# service postgresql-10 status
Start PostgreSQL Server Verify PostgreSQL Installation

After installing PostgreSQL 10 on your server, verify its installation by connecting to postgres database server.

# su - postgres
$ psql

psql (10.0)
Type "help" for help.

If you want you can create a password for user postgres for security purpose.

postgres=# \password postgres
Set PostgreSQL User Password

You can find more information at the PostgreSQL Homepage: https://www.postgresql.org/

Also check out these articles about popular database management systems:

  1. How to Install and Secure MariaDB 10 in CentOS 7
  2. How to Install and Secure MariaDB 10 in CentOS 6
  3. Install MongoDB Community Edition 3.2 on Linux Systems

That’s all! Hope you find this article useful. If you have any questions or thoughts to share, use the comment section below.

Ref From: tecmint
Channels: postgresql

Related articles