Re: Postgres replication

From: John Scalia <jayknowsunix(at)gmail(dot)com>
To: "Gone, Sajan" <SGone(at)lb(dot)com>
Cc: Samed YILDIRIM <samed(at)reddoc(dot)net>, "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Postgres replication
Date: 2017-04-19 15:53:53
Message-ID: CABzCKRC-1X4py2zjetkXyy=qRs5jK2gv-ywtJ3k2zrGH-d34vQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

My usual way of doing this, is to 1) stop the master, 2) stop the replica,
3) restart the master, and finally 40 restart the replica.Slaves don't try
to reconnect, they only attempt on startup. Your problem may now be that
some WAL logs on the master may have disappeared by now, so the slave will
not be able to catch up. Your only choice then is to rebuild it. Not really
a problem, as all you need to do is run a pg_basebackup against the master.

On Wed, Apr 19, 2017 at 11:00 AM, Gone, Sajan <SGone(at)lb(dot)com> wrote:

> Hi,
>
> The replication worked fine until the server re-start on Master we did
> recently this morning. After the restart of the linux server, I have
> started the database backup on Master however when I logged on to the slave
> server I saw the replication is terminated between the master and the slave.
>
> Here is the status of the slave when I queried pg_stat_replication table:
>
> postgres=# select * from pg_stat_replication ;
> pid | usesysid | usename | application_name | client_addr |
> client_hostname | client_port | backend_start | backend_xmin | state
> | sent_location | write_location | flush_location | replay_location |
> sync_priority | sync_state
> -----+----------+---------+------------------+-------------+
> -----------------+-------------+---------------+--------------+-------
> +---------------+----------------+----------------+---------
> --------+---------------+------------
> (0 rows)
>
> Does we have to re-initiate the replication every time on postgres if
> we restart either the Master/Slave Server. If so how can I re-initiate the
> replication.
>
> Please let me know your thoughts on this.
>
> Thank You,
> Sajan Gone
> Database Administrator
> L Brands
> Mobile #: 517-990-5282 <(517)%20990-5282>
> Office #: 614-577-7622 <(614)%20577-7622>
>
> From: Samed YILDIRIM <samed(at)reddoc(dot)net>
> Date: Friday, April 14, 2017 at 10:34 AM
> To: Sajan Gone <sgone(at)lb(dot)com>, "pgsql-admin(at)postgresql(dot)org" <
> pgsql-admin(at)postgresql(dot)org>
> Subject: Re: [ADMIN] Postgres replication
>
> Hi Sajan,
>
> You can use following query.
>
> select * from pg_stat_replication;
>
> Best regards.
> Samed YILDIRIM
>
>
>
> 14.04.2017, 17:20, "Gone, Sajan" <sgone(at)lb(dot)com>:
>
> Hi Samed,
>
> Thanks for sending out the weblink. I was able to successfully set the
> replication up (Master/Slave, Hot stand by).
>
> I really appreciate your help on this.
>
> My background is mostly on MySQL so my next question would be on how to
> look at the replication status. Like MySQL “Show slave status \G” command
> is there any command on postgres to look at the slave current status(or
> replication status).
>
> Thank You,
> Sajan Gone.
> *From: *Samed YILDIRIM <samed(at)reddoc(dot)net>
> *Date: *Thursday, April 13, 2017 at 4:27 PM
> *To: *Sajan Gone <sgone(at)lb(dot)com>, "pgsql-admin(at)postgresql(dot)org" <
> pgsql-admin(at)postgresql(dot)org>
> *Subject: *Re: [ADMIN] Postgres replication
>
> Hi Sajan,
>
> You can take a look following document. It is good for a start point.
>
> https://www.digitalocean.com/community/tutorials/how-to-
> set-up-master-slave-replication-on-postgresql-on-an-ubuntu-12-04-vps
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__www.digitalocean.com_community_tutorials_how-2Dto-2Dset-2Dup-2Dmaster-2Dslave-2Dreplication-2Don-2Dpostgresql-2Don-2Dan-2Dubuntu-2D12-2D04-2Dvps&d=DwMGaQ&c=spYp1tZ3AQD6dfuI6rqaeg&r=7n1bLwXDzepgjKSNziw-ng&m=fHbva-Ii918KntE6AvrhZBUaeKjC9nKfhVNdqTAkYU8&s=GAJTCqC_l4UPTLi3vPPGwcbfSz80O79T1x6GJGA_JTU&e=>
>
> Best regards.
>
> 22:25, 13 Nisan 2017, "Gone, Sajan" <sgone(at)lb(dot)com>:
>
>
>
>
>
>
> Hello,
>
>
>
> Good afternoon everyone.
>
>
>
>
> This is Sajan Gone, I am trying to setup a Standard Master/Salve
> replication between two postgres instances. I am pretty much new to
> postgres and not exactly sure how replication works and what is an
> architecture behind
> it. As of now I am following the standard postgres documentation @
> https://www.postgresql.org/docs/current/static/warm-
> standby.html#PREPARING-MASTER-FOR-STANDBY
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__www.postgresql.org_docs_current_static_warm-2Dstandby.html-23PREPARING-2DMASTER-2DFOR-2DSTANDBY&d=DwMGaQ&c=spYp1tZ3AQD6dfuI6rqaeg&r=7n1bLwXDzepgjKSNziw-ng&m=Vi2JxqEOxr992ibCDezMAd_sbdja65aRxMh4oM6WYpo&s=Qb_JJynxAr1X-KEpv8g-FVJ4Ac4wuqLr6fR3IfEVNpo&e=>
> ,
> however it is slightly difficult for me to understand.
>
>
>
>
> It would be very helpful if any one could guide me in a proper way on
> setting up Master/Slave replication on postgres. Any recommendations on
> good documentation
> or study materials on postgres replication would be highly appreciated.
>
>
>
>
> Many Thanks in advance.
>
>
>
>
>
> Thank You,
>
> Sajan Gone
>
>
>
>
>
>
> ------------------------------
>
>
>
> Notice: This communication may contain privileged and/or confidential
> information. If you are not the intended recipient, please notify the
> sender by email, and immediately delete the message and any attachments
> without copying or disclosing them. LB may, for
> any reason, intercept, access, use, and disclose any information that is
> communicated by or through, or which is stored on, its networks,
> applications, services, and devices.
>
>
>
>
>
>
> ------------------------------
>
> Notice: This communication may contain privileged and/or confidential
> information. If you are not the intended recipient, please notify the
> sender by email, and immediately delete the message and any attachments
> without copying or disclosing them. LB may, for any reason, intercept,
> access, use, and disclose any information that is communicated by or
> through, or which is stored on, its networks, applications, services, and
> devices.
>
>
> ------------------------------
>
> Notice: This communication may contain privileged and/or confidential
> information. If you are not the intended recipient, please notify the
> sender by email, and immediately delete the message and any attachments
> without copying or disclosing them. LB may, for any reason, intercept,
> access, use, and disclose any information that is communicated by or
> through, or which is stored on, its networks, applications, services, and
> devices.
>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Николай Симитчийски 2017-04-20 11:03:56 Restore whole server
Previous Message Gone, Sajan 2017-04-19 15:00:27 Postgres replication