0

I am very new to postgres and being new I got stuck at a point and need some help, please pardon if you find it silly.

I am doing a pgpool HA and at postgres level i have 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:

  • slave 1-highest timeline 1 of the primary is behind recovery timeline 11
  • slave 2-highest timeline 1 of the primary is behind recovery timeline 10
  • slave 3-highest timeline 1 of the primary is behind recovery timeline 3

I tried deleting pg_xlog files in slaves and copying all the files from master pg_xlog into the slaves and then did a rsync. i also did a pg_rewind but it says:

target server needs to use either data checksums or wal_log_hints = on

(I have wal_log_hints = on set in postgresql.conf already) I've tried doing a pg_basebackup but since the data base server in slaves are still starting up its not able to connect to the server

Is there any way to bring the master and the slave at a same timeline?

3 Answers 3

1

In my case, it happened because ( experimentally ), I updated the standby database tables and again when I simulate the master-standby streaming replication I got the same errors. So once again I cleaned the whole standby database directory and migrate the master database using cmd like

"pg_basebackup -P -R -X stream -c fast -h 10.10.40.105 -U postgres -D standby/"

0

I think something is wrong in your pgpool configuration. What tool you have been using for manement of replication and master-slave control? Is it post master or repmgr?

I was trying to configure pgpool with 3 data nodes using a tutorial from http://jensd.be/591/linux/setup-a-redundant-postgresql-database-with-repmgr-and-pgpool and have done it correctly.

Also you can lean auto failover here.

0

(These question is obviously duplicate of this one, so I'll repeat the answer also.)

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.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.