Postgresql 10 replication mode error

3/6/2018

I'm trying to setup a basic master slave configuration using streaming replication for postgres 10 and docker

Since the official docker image provides a docker-entrypoint-initdb.d folder for placing initialization scripts i thought it would be a swell idea to start placing my preparation code here.

What i'm trying to do is automate the way the database is restored before starting the slave in standby mode, so i run

rm -rf /var/lib/postgresql/data/* && pg_basebackup 'host=postgres-master port=5432 user=foo password=foo' -D /var/lib/postgresql/data/

and this succeeds.

Then the server is shutdown and restarted as per the docker initialization script, which pops up a message saying

database system identifier differs between the primary and standby

Now I've been sitting online for a while now, and the only 2 explanations i got is that I either have a misconfigured recovery.conf file, which looks like this

standby_mode = 'on'
primary_conninfo = 'host=postgres-master port=5432 user=foo password=foo'
trigger_file = '/tmp/postgresql.trigger'

Where the connection string is the same one i used for the base backup.

The second solution circulating is that the backup command could be messed up, but the only thing i add to the data folder after backup is the recovery.conf file.

Anyone have any idea where i'm messing up?

Should i just go for repmgr and call it a day?

Thanks in advance

-- omu_negru
database-replication
docker
kubernetes
postgresql
replication

1 Answer

4/24/2018

To give an answer to my own question, the issue lied in how the dockerfile entrypoint scripts were called. Rather, they would end up starting the instance as a master or slave according to variables that were not properly set by me.

-- omu_negru
Source: StackOverflow