Re: [ADMIN] Replication mode Master-Slave - maintenance question.

From: John Scalia <jayknowsunix(at)gmail(dot)com>
To: czezz <czezz(at)o2(dot)pl>
Cc: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: [ADMIN] Replication mode Master-Slave - maintenance question.
Date: 2017-03-23 18:05:54
Message-ID: CABzCKRAsh9uBXnQtodHnPmtS8OFi-2hbV2oshJASjYjFqTcoYg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

You did not indicate whether you're Master-Slave setup is synchronous or
asynchronous, but yes, what you described should work. The slave should
have a recovery.conf file and the presence of that will cause that slave to
wind through all WAL files present before it resumes further processing. At
least this is what happens in synchronous streaming mode. Your problem
might be if the slave is off for an extended period of time or if one of
the WAL files disappears. At that point the slave would not have all the
transactions for consistency.

Again,to your question near the end. It depends on how you're set up.
Generally though slaves do make the request to their master.

On Thu, Mar 23, 2017 at 1:47 PM, czezz <czezz(at)o2(dot)pl> wrote:

> Hi,
> I have set my Postgres into replication mode Master-Slave and it works
> good.
> Though, I have some question about maintaining it.
>
> Let me start from the beginning. How I set it up (briefly):
> 1. Stand Alone postgres (future MASTER) has been set to archive data to:
> /datastore/WAL (archive_command = 'cp %p /datastore/WAL/%f && gzip
> /datastore/WAL/%f ')
> 2. I have shared /datastore/WAL over NFS
> 3. I prepared SLAVE machine and created initial database out of MASTER's
> WAL-archival (over NFS) by preparing following file:
>
> $ vi /var/lib/pgsql/9.2/data/recovery.conf
> restore_command = 'gunzip -c /datastore/WAL/%f > %p'
> standby_mode = 'on'
> primary_conninfo = 'host=MASTER_IP_ port=5432 user=rep
> password=password'
> trigger_file = '/var/lib/pgsql/MASTER.trigger'
>
> 4. One last thing - I keep archive_mode = off on the SLAVE.
>
> The above works perfect.
>
> Now, here I need your help to understand what is happening in case
> following scenario.
>
> SCENARIO:
> I turn off SLAVE for some time (and MASTER receives a lot of new data) and
> later I turn SLAVE on.
> Is it true/correct:
> - SLAVE restores missing data/delta over NFS (from MASTER's archival).
> This is due to existing /var/lib/pgsql/9.2/data/recovery.conf and entry:
> restore_command = 'gunzip -c /datastore/WAL/%f > %p'
> - Once restore is done, SLAVE will keep replicate new data from MASTER
> (btw. it is SLAVE who request replication, correct?)
>
> Can anyone please confirm that my above assumption is correct and if not
> correct it?
>
> Best regards,
> czezz
>

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Kris Deugau 2017-03-23 18:30:02 Re: unable to find data folder postgres9.4
Previous Message czezz 2017-03-23 17:47:24 [ADMIN] Replication mode Master-Slave - maintenance question.