I have a postgres database (version 9.4) with streaming replication (master, slave configuration). Lets call master db A and slave db B.
The server running A failed and we had to do a switchover, where we promoted B to be the new master. Until now it is all good and working fine.
Now I have recovered the broken server and want to set up again the replication so A can be the new slave. So, I take a backup from B, put it in server A, set up the recovery file and start it. The problem here is that it doesn't really work any more, as it says they are in two different time lines.
Here are the messages from A (new slave):
2015-10-30 14:28:04 LOG: database system was shut down in recovery at 2015-10-30 14:27:28 CET
2015-10-30 14:28:04 LOG: entering standby mode
2015-10-30 14:28:04 LOG: redo starts at 1A/5802B1A8
2015-10-30 14:28:04 LOG: consistent recovery state reached at 1A/581FA248
2015-10-30 14:28:04 LOG: record with zero length at 1A/581FA248
2015-10-30 14:28:04 LOG: database system is ready to accept read only connections
2015-10-30 14:28:05 LOG: started streaming WAL from primary at 1A/58000000 on timeline 2
2015-10-30 14:28:07 ERROR: requested starting point 19/FE000000 on timeline 1 is not in this server's history
2015-10-30 14:28:07 DETAIL: This server's history forked from timeline 1 at 19/FDCF9BA0.
2015-10-30 14:28:12 ERROR: requested starting point 19/FE000000 on timeline 1 is not in this server's history
2015-10-30 14:28:12 DETAIL: This server's history forked from timeline 1 at 19/FDCF9BA0.
my recovery file looks like:
standby_mode = 'on'
primary_conninfo = 'host=serverB port=5432 user=replication-user'
restore_command = 'copy "Z:\\pg_xlog\\%f" "%p"'
archive_cleanup_command = '"C:\\Program Files\\PostgreSQL\\9.4\\bin\\pg_archivecleanup" "Z:\\pg_xlog" "%r"'
trigger_file = 'Z:\\trigger\\pgsql.trigger.sekasto021'
recovery_target_timeline = 'latest'
Googling I found almost the same question here but with no answers. Found a page from Michael Paquier who does describes what is happening to me (although he says it is a no issue from version 9.3). He says:
FATAL: timeline 2 of the primary does not match recovery target timeline 1This can only be solved by copying the WAL segments from the master node or using a WAL archive.
But sadly I don't know what he means by copying the wal segments from the master using wall archive.
Any help/guidance is welcomed. Thanks
Update: I posted this question on stackoverflow and was asked to put it here instead