Replication - PostgreSQL Unable To Run Repmgr Cloned Database - Database Administrators Stack Exchange
Replication - PostgreSQL Unable To Run Repmgr Cloned Database - Database Administrators Stack Exchange
database
I searched around and realized that the problem was due to not enabling
hot_standby on the standby server. I wrote a corrected, updated and simplified
version of the above article as an odt for future personal reference. Here is the
text in its entirety (converted to html from odt using openoffice.org) for those
who are interested in setting up a single read-only clone of a database using
repmgr:
Introduction
This guide aims to quickly help you configure a PostgreSQL 9.1 server with a
database, and have it replicated to a slave that can be used for read-only queries.
There is no concept of failover involved here, and the slave will only have a read-
only copy of the master's data.
1. Tools Needed
3. postgresql
4. postgresql-client
5. postgresql-contrib
6. postgresql-server
7. postgresql-server-dev
8. 2 workstations – a master that runs the primary database and a slave that
runs the replicated read-only database (for the purpose of this document,
their respective IP addresses have been replaced with pgmaster and
pgslave so make those changes in /etc/hosts of both machines if you want
to follow the following instructions word for word)
4. Run sudo passwd postgres on both systems and type a new Unix password
for both.
2. su postgres
5. ssh pgslave and see if you are able to login without password
7. su postgres
8. sh-keygen -t rsa
9. ssh-copy-id -i ~/ssh/id_rsa.pubaster
10. ssh pgmaster and see if you are able to login without password
11. Make sure you log out from the remote machine after you finish checking
connectivity
You need to make the following changes in the file postgresql.conf that resides in
the configuration directory inside /etc/postgresql/ on your machine pgmaster:
• listen_addresses = '*'
• wal_level = hot_standby
• checkpoint_segments=30
• archive_mode=on
• archive_command='cd .'
• max_wal_senders=2
• wal_keep_segments=5000
You need to make the following change in the file postgresql.conf that resides in
the configuration directory inside /etc/postgresql/ on machine pgslave:
• hot_standby=on
6. Editing pg_hba.conf on pgmastger
You need to make the following changes in the file pg_hba.conf that resides in
the configuration directory inside /etc/postgresql/ on machine pgmaster:
There are a bunch of nifty postgresql utilities we will be using here, so lets set the
PATH variable so that it knows where to find them
3. Excluding final word pgbench, copy the above path and add it to your path
variable.
7. You may need to log out and login (or open a new shell) for changes to take
effect.
2. We create a test database and load it with some dummy data with the
following commands:
1. su postgres
2. createdb pgbench
3. pgbench -i -s 10 pgbench
3. make
4. gcc
5. postgresql-devel
6. libxslt-devel
7. pam-devel
8. libopenssl-devel
9. krb5-devel
Extract the downloaded archive and enter the source code folder.
repmgr --version
repmgrd --version
4. Also note that 5432 is the default port PostgreSQL runs in.
5. When the command finishes executing (it is going to take several seconds
to finish if you had used pgbench to insert random data) you may start
PostgreSQL on pgslave with /etc/init.d/postgresql start
Conclusion