问题
I was doing a streaming replication between 3 nodes of postgresql-9.5 . 1 master and 2 slaves I was trying to configure auto failover but when i switched back to my original master, and restarted the postgres service, I am getting the following error:-
highest timeline 1 of the primary is behind recovery timeline 11
Can somebody please help. Thanx in advance
回答1:
I'm not sure what you exactly mean by "when i switched back to my original master", but it looks that you are doing the wrongest possible thing in PostgreSQL streaming replication - introducing the second master.
The most important thing you should know about PostgreSQL replication is that once the failover is performed, you cannot simply "switch back to original master" - there's now a new master in cluster, and existence of two masters will make damage.
After a slave is promoted to master, the only way for you to re-join the old master is to:
- Destroy it (delete the data directory);
- Join it as a slave.
If you want it to be master again you'll continue with the following:
- Let it run for awhile as a slave so that it can sync the data;
- Kill temporary master and failover to old master;
- Rejoin temporary master again as a slave.
You cannot simply switch master servers! Master can be created ONLY by failover (promoting a slave)
You should also know that whenever you are performing failover (whenever the master is changed), all slaves (except for the one that is promoted) need to be reconfigured to target the new master.
I suggest you reading this tutorial - it'll help.
来源:https://stackoverflow.com/questions/37140598/primary-lagging-behind-recovery-in-postgres-streaming-replication