Question

Help with PostgreSQL replication

The master and slave servers are set up as per the tutorial https://www.digitalocean.com/community/tutorials/how-to-set-up-master-slave-replication-on-postgresql-on-an-ubuntu-12-04-vps and both servers are Ubuntu 12.04 x64 and are running PostgreSQL 9.1

below are the commands I am running and the errors I am getting, any help will be appreciated.

MASTER SERVER

$ sudo su - postgres
$ psql -c "select pg_start_backup('initial_backup');"
$ rsync -cva --inplace --exclude=*pg_xlog* /var/lib/postgresql/9.1/main/ MAS.TER.SER.VER:/var/lib/postgresql/9.1/main/
$ psql -c "select pg_stop_backup();"
$ psql -c "select pg_stop_backup();"
NOTICE:  pg_stop_backup cleanup done, waiting for required WAL segments to be archived
WARNING:  pg_stop_backup still waiting for all required WAL segments to be archived (60 seconds elapsed)
HINT:  Check that your archive_command is executing properly.  pg_stop_backup can be canceled safely, but the database backup will not be usable without all the WAL segments.
WARNING:  pg_stop_backup still waiting for all required WAL segments to be archived (120 seconds elapsed)
HINT:  Check that your archive_command is executing properly.  pg_stop_backup can be canceled safely, but the database backup will not be usable without all the WAL segments.
^CCancel request sent
ERROR:  canceling statement due to user request

SLAVE SERVER

After running the above on the master I then set up the recovery.conf as per the tutorial and attempt to start the slave server.

$ sudo su - postgres
$ nano /etc/postgresql/9.1/main/recovery.conf

Edit as per tutorial

$ service postgresql start
 * Starting PostgreSQL 9.1 database server                                                                                                                            * Removed stale pid file.
The PostgreSQL server failed to start. Please check the log output:
2014-07-21 22:31:12 BST LOG:  database system was interrupted; last known up at 2014-07-21 22:21:43 BST
2014-07-21 22:31:12 BST LOG:  could not open file "pg_xlog/000000010000000000000018" (log file 0, segment 24): No such file or directory
2014-07-21 22:31:12 BST LOG:  invalid checkpoint record
2014-07-21 22:31:12 BST FATAL:  could not locate required checkpoint record
2014-07-21 22:31:12 BST HINT:  If you are not restoring from a backup, try removing the file "/var/lib/postgresql/9.1/main/backup_label".
2014-07-21 22:31:12 BST LOG:  startup process (PID 8274) exited with exit code 1
2014-07-21 22:31:12 BST LOG:  aborting startup due to startup process failure

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

In the command:

rsync -cva --inplace --exclude=*pg_xlog* /var/lib/postgresql/9.1/main/ MAS.TER.SER.VER:/var/lib/postgresql/9.1/main/

I assume MAS.TER.SER.VER is the IP address of the master postgres server? If so, that should actually be the IP of the slave server.