Install Postgres 9.5 and Slony1 2.2 on CentOS 7 or CentOS 6

Installing postgresql 9.5

Install the official PostgreSQL yum repository from the list of repositories at http://yum.postgresql.org/repopackages.php

For installing postgresql 9.5 on centos 7 use the following command

yum install https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm

For CentOS6 this is

yum install https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-6-x86_64/pgdg-centos95-9.5-2.noarch.rpm
  

Once done install the required postgresql packages such as server, contrib, etc.

Naming convention of packages is postgresql[version]-[package]

To install server and contrib postgresql packages from 9.5

yum install postgresql95-server postgresql95-contrib

Once installation is complete initialize the database server

/usr/pgsql-9.5/bin/postgresql95-setup initdb

In CentOS6 this is

service postgresql-9.5 initdb
  

When initialization is done enable postgres on server restart

systemctl enable postgresql-9.5.service

In CentOS6 this is

chkconfig postgresql-9.5 on
  

Finally start the postgres server

systemctl start postgresql-9.5.service

In CentOS6 this is

service postgresql-9.5 start
  

Congratulations you have a functional postgresql 9.5 server!


Installing Slony1 2.2

Download the slony 2.2 source from the slony.info site.

For slony 2.2.4

wget http://main.slony.info/downloads/2.2/source/slony1-2.2.4.tar.bz2

Decompress and untar the downloaded file.

tar -xvjf slony1-2.2.4.tar.bz2

If an error that looks like

tar (child): bzip2: Cannot exec: No such file or directory
  

occurs install bzip2 using

yum install bzip2
  

Then run the tar command as before.

Once the files have been extracted cd into the slony-[version] directory.

Locate the pg_config file on your system

find / -type f -name 'pg_config'

Which will give an output similar to /usr/pgsql-9.5/bin/pg_config

Configure the slony source code (based on the directory which includes the pg_config file)

./configure --with-perltools --with-pgconfigdir=/usr/pgsql-9.5/bin

If an error that looks like

configure: error: no acceptable C compiler found in $PATH
  

occurs install a c compiler

yum install gcc
  

Once the c compiler has finished installing

Run the ./configure command as before.


If an error that looks like

checking for PQunescapeBytea in -lpq... no
./configure: line 410: test: which: integer expression expected
configure: error: requires
./configure: line 299: return: which: numeric argument required
./configure: line 309: exit: which: numeric argument required
  

Install libpq library through the postgresql95-devel package.

yum install postgresql95-devel
  

Once the postgresql95-devel package finishes installing

Run the ./configure command as before.

Build the configured slony source code.

gmake all

Install the built slony package

gmake install

Locate the slon binary directory

find / -type f -name 'slon'

example output : /usr/pgsql-9.5/bin/slon

Add the slon directory to the PATH variable

echo 'pathmunge /usr/pgsql-9.5/bin' > /etc/profile.d/slon.sh
chmod +x /etc/profile.d/slon.sh
. /etc/profile

Thats it. Congratulations you have a functional postgresql 9.5 server and slony1 2.2 installation!


Check versions using the following commands

Check Postgresql Server Version

pg_config --version

Check Slony1 Version

slon -v