2

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

subhojit_paul
  • 31
  • 1
  • 5
  • Not sure this is a stackoverflow question. More dba, I'd say. Anyway - it means that your new primary is "behind" the secondary. You will need to use pg_rewind on the secondary or take a new base-backup. – Richard Huxton May 10 '16 at 14:54
  • I am very new to postgres and sackoverflow has always been helpful so posted it here as well. I tried pg_basebackup but it says pg_basebackup: could not connect to server: FATAL: the database system is starting up – subhojit_paul May 11 '16 at 05:50
  • pg_rewind is not working as well. its saying "target server needs to use either data checksums or "wal_log_hints = on" i checked the data_checksums is off and wal_log_hints is on in postgresql.conf. Can you please help here. – subhojit_paul May 11 '16 at 06:14
  • I think your best bet is to ask on the postgresql mailing lists it sounds like you need more help than a single question/answer pair. The mailing lists are very good. – Richard Huxton May 11 '16 at 07:12

1 Answers1

0

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:

  1. Destroy it (delete the data directory);
  2. Join it as a slave.

If you want it to be master again you'll continue with the following:

  1. Let it run for awhile as a slave so that it can sync the data;
  2. Kill temporary master and failover to old master;
  3. 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.

Aleksandar Pesic
  • 668
  • 7
  • 18