My replication server will not start. I have followed the instructions here:
http://opensourcedbms.com/dbms/setup-replication-with-postgres-9-2-on-centos-6redhat-el6fedora/
As well as several other places including the Postgres Wiki as they all have the same information.
Here is what happens:
I do a full backup of the /9.2/data
folder and move it to the replication/slave server, untar it. I can start PostgreSQL as well as pgAdmin and access all data with no problems.
I then move to the instructions on editing the pg_hba.conf
and postgresql.conf
for the slave server. I attempt to start it, and it fails (error in red [fail]. I cannot find any logs anywhere to give me a hint as to why.
I even verified there was no postmaster.pid
in the data folder.
Also, I cannot find any log files. Do I need to "activate" a log file in the configuration?
So, if anyone wants to take a stab in the dark on my vague description, I'd love to hear any suggestions. I can put my conf files on pastebin if that will help.
Best Answer
Steps to set up the hot standby
First, determine the mount points of the Postgresql data directories and the
WAL
(Write Ahead Log) directories. For performance, the$PGDATA
andpg_xlog
directories should be on separate volumes.In the examples below, they are defined as follows:
archive_command
on the master. Ideally on a separate volume from $PGDATA.Assumptions:
On the slave, create the staging directory to hold the master's log files
On the master, edit the
$PGDATA/postgresql.conf
On the master, create the replication role, which will be copied to the slave via pg_basebackup. Set a password for the "replication" role
Modify the master $PGDATA/pg_hba.conf and enable the replication user for the IP of the slave
Restart the master cluster to pick up the changes to the postgresql.conf. This is done as the cluster superuser.
For example:
On the slave, from $HOME, issue the pg_basebackup command to start setting up the hot standby from the master.
On the slave, after pg_basebackup has successfully completed, edit $PGDATA/postgresql.conf
On the slave, create
$PGDATA/recovery.conf
:The slave should be ready to be started now. Start the cluster on the slave with whatever method works best.
The following are the commands I run when recreating a standby over and over for test. I add them to a script called /root/recreate_standby.sh. Runs as root, but that is not necessary - if you run as postgres, removed the "sudo su - postgres -c" command.
For more in-depth details, current Postgresql docs: