Building PostgreSQL 9.6

aborkar-ibm edited this page Mar 13, 2018 · 10 revisions

Building PostgreSQL

Below versions of PostgreSQL are available in respective distributions at the time of creation of these build instructions:

  • RHEL 6.9 has 8.4.20
  • RHEL (7.1, 7.2, 7.3, 7.4) has 9.2.23
  • SLES (11-SP4, 12 SP1, 12 SP2) has 9.4.9
  • SLES 12 has 9.4.6
  • Ubuntu 16.04 has 9.5+173
  • Ubuntu 17.04 has 9.6+179

The instructions provided below specify the steps to build PostgreSQL version 9.6.5 on Linux on IBM Z for

  • RHEL(6.9, 7.1, 7.2, 7.3, 7.4)
  • SLES (11 SP4, SLES 12, 12 SP1, 12 SP2)
  • Ubuntu 16.04

General Notes:

  • When following the steps below please use a standard permission user unless otherwise specified.
  • A directory /<source_root>/ will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it.

Step 1: Building and installing PostgreSQL

1.1) Install dependencies

  • RHEL (6.9, 7.1, 7.2, 7.3, 7.4)

    sudo yum install git wget build-essential gcc gcc-c++ make readline-devel zlib-devel bison flex 
  • SLES 11 SP4

    sudo zypper install git gcc  gcc-c++ make readline-devel  zlib-devel bison flex awk
  • SLES (12, 12 SP1, 12 SP2)

    sudo zypper install git gcc  gcc-c++ make readline-devel  zlib-devel bison flex
  • Ubuntu 16.04

    sudo apt-get update
    sudo apt-get install bison flex wget build-essential git gcc make zlib1g-dev libreadline6 libreadline6-dev

1.2) Create postgres user, group and home directory

sudo groupadd -r postgres
sudo useradd -r -m -g postgres postgres
sudo passwd postgres

Note: Password for SLES11 SP4 should be up to 7 characters. Please note that /usr/sbin is available in PATH environment variable.

1.3) Download PostgreSQL source code from github

su postgres -s /bin/bash
cd /<source_root>/
git clone git://
cd postgres/
git checkout REL9_6_5

Note: Login as postgres user and download the source in postgres home directory.

1.4) Build and install PostgreSQL

cd /<source_root>/postgres
make check
sudo make install

Note: Before you run make check make sure LANG environment variable is not set. unset LANG if it is already set.

1.5) Update the PATH variable

export PATH=$PATH:/usr/local/pgsql/bin

Step 2: Set up PostgreSQL server (Optional)

2.1) Create PostgreSQL data directory to store data and make postgres user as the owner

sudo mkdir /usr/local/pgsql/data
sudo chown postgres:postgres /usr/local/pgsql/data

2.2) Initialize PostgreSQL data directory as postgres user

su postgres -s /bin/bash
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data/

Note: Please make sure the directory /usr/local/ has sufficient read and execute permissions when initializing.

2.3) Start the PostgreSQL server

/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data


Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.