Showing posts with label PostgreSQL. Show all posts
Showing posts with label PostgreSQL. Show all posts

Friday, June 18, 2021

Install PostgreSQL on RHEL/OL/CentOS 6/7/8

There are many ways to install PostgreSQL on Linux box. Here, I am going to use yum to install different version of PostgreSQL on Red Hat Enterprise Linux (RHEL) 7/8, it also works for Oracle Linux (OL) / CentOS 7/8.

1. Install yum repository for PostgreSQL

Depends on version of OS, run one of following commands
  * RHEL/OL/CentOS 8
  yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm

  * RHEL/OL/CentOS 7
  yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

  * RHEL/OL/CentOS 6
  yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-6-x86_64/pgdg-redhat-repo-latest.noarch.rpm

2. Validate yum repository list with following command

  yum repolist

The command lists all configured repositories, example output on RHEL 8 
repo id                repo name
pgdg-common            PostgreSQL common RPMs for RHEL/CentOS 8 - x86_64
pgdg10                 PostgreSQL 10 for RHEL/CentOS 8 - x86_64
pgdg11                 PostgreSQL 11 for RHEL/CentOS 8 - x86_64
pgdg12                 PostgreSQL 12 for RHEL/CentOS 8 - x86_64
pgdg13                 PostgreSQL 13 for RHEL/CentOS 8 - x86_64
pgdg96                 PostgreSQL 9.6 for RHEL/CentOS 8 - x86_64

It configured PostgreSQL 9.6, 10, 11, 12, 13 repositories on RHEL 8. Therefore, I can install any or all of these version PostgreSQL. Note, available version PostgreSQL is different for different OS version.

3. Install PostgreSQL

Depends on which version you want to install, run one of following command,

  * Install PostgreSQL 13
  yum install -y postgresql13-server

  * Install PostgreSQL 12
  yum install -y postgresql12-server

  * Install PostgreSQL 11
  yum install -y postgresql11-server

  * Install PostgreSQL 10
  yum install -y postgresql10-server

  * Install PostgreSQL 96
  yum install -y postgresql96-server

4. Install package postgresql-contrib

This package contains various extension modules that are included in the PostgreSQL distribution. Depends on the version of PostgreSQL installed, run one of following command to install contrib package,

  * PostgreSQL 13
  yum install -y postgresql13-contrib

  * PostgreSQL 12
  yum install -y postgresql12-contrib

  * PostgreSQL 11
  yum install -y postgresql11-contrib

  * PostgreSQL 10
  yum install -y postgresql10-contrib

  * PostgreSQL 96
  yum install -y postgresql96-contrib