How To Set Up A Postgresql 9.0 Hot Standby Streaming Replication Server With Repmgr On OpenSUSE 11.4

There are tons of tutorials about how to setup streaming replication on postgresql 9.0, and detailed documentation on repmgr, the SR manager program from 2ndQuadrant. Like they said on repmgr homepage:

"PostgreSQL 9.0 allow you to have replicated hot standby servers which you can query and/or use for high availability. While the main components of the feature are included with PostgreSQL, the user is expected to manage the high availability parts. repmgr allows you to monitor and manage your replicated PostgreSQL databases as a single cluster."

This is a tutorial how to set up a postgresql replicated hot standby server with streaming replication, and we also set up the repmgr to monitor and manage the replication cluster. Unlike most tutorials that copy the database file from master to slave (or standby) in the middle of running pg_start_backup() and pg_end_backup(), repmgr is used to simplify the whole procedure. (But I still think that procedure helps you a lot to understand how postgresql warm standby, pitr, and hot standby replication work.)

I would like to give most of the credits to postgresql community and all the contributors like 2ndQuadrant. You guys did a wonderful job for the SR hot standby features on postgresql database. The work I did on this tutorial is just make postgresql SR hot standby replication works on opensuse 11.4.

I wish this tutorial could help more people start to use postgresql, the most advanced database, also Opensuse, my favorite OS like Debian.

[email protected],

Jun 20th 2011

In this tutorial I will run 2 OpenSUSE 11.4 32-bit bare bone servers under VMware Workstation, both servers were built from OpenSUSE 11.4 network installation iso, which you can download from

pgmaster: (master database server)
pgslave: (slave database server, or standby)
And modify /etc/hosts in both servers to have above 2 records.


Step 1. Install postgresql on both master and slave server

zypper install postgresql postgresql-contrib postgresql-server

And then start postgresql server to make sure it works:

/etc/init.d/postgresql start


Step 2. Set up trusted copy between servers (on both master and slave)

repmgr program will copy database with rsync and ssh for user postgres, so we need to set up ssh login with password between master and slave server:

passwd postgres

su - postgres
ssh-keygen -t rsa

ssh-copy-id -i ~/.ssh/ pgslave

Test if we can ssh to pgslave from pgmaster with password:

ssh pgslave

And do the same step on the slave:

su - postgres
ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/ pgmaster
ssh pgmaster

Make sure you log out from the remote ssh server after your test.


Step 3. Change postgresql configuration files (pg_ha.conf, postgresql.conf), and restart postgresql (master server only)

Make sure the following lines are changed in postgresql.conf on master server only:

listen_addresses = "*"
wal_level = hot_standby
archive_command='cd .'

And in pg_hba.conf on master server only:

host all all trust
host replication all trust

Now restart postgresql, and create a test database for replication use.

/etc/init.d/postgresql restart

We create a test database and generate some data on master database:

su - postgres
createdb pgbench
pgbench -i -s 10 pgbench


Step 4. Stop postgresql server, and remove all content in the data directory (slave server only)

/etc/init.d/postgresql stop
cd /var/lib/pgsql/data
rm -rf *

Now test the remote postgresql connection to pgmaster:

psql -h pgmaster -d pgbench

Now postgresql has been installed correctly on both the master and slave server. Time to install the repmgr management program. You need to download the source code from 2ndQuadrant website, and compile it yourself.

Share this page:

3 Comment(s)

Add comment

Please register in our forum first to comment.


By: Bill

Thank you for the informative step-by-step tutorial.  I found it very helpful in setting up and understanding repmgr and what postgres configuration variables are pertinent to streaming replication.  One think I would note about your postgresql.conf settings is the the `wal_keep_segments` value you are proposing seems to be excessively high.


Before fully understanding the implications of that configuration variable, I set it to 5000 on our production database.  The result was that the pg_xlog eventually used up all of the available disk space on and brought the server down.  I changed the value to 




as is recommended in, and the PostgresQL documentation itself.  The pg_xlog went from consuming 47GB to only 7GB afterwards, and the slave continues to sync with no problems.



By: Anonymous


hot_standby ignored on a master server.

By: Xiao

Your post helped me a lot. Thanks!