How to failover from Primary to Standby and Set the old Primary as a new Standby - Mailing list pgsql-general

From ascot.moss@gmail.com
Subject How to failover from Primary to Standby and Set the old Primary as a new Standby
Date
Msg-id B0337069-7F51-41C0-A1DA-47CC75A6E59F@gmail.com
Whole thread Raw
In response to Re: Query plan for currently executing query?  (Rowan Collins <rowan.collins@gmail.com>)
Responses Re: How to failover from Primary to Standby and Set the old Primary as a new Standby  (Vick Khera <vivek@khera.org>)
List pgsql-general
Hi,

I use PG 9.2.4 with streaming replication.  What will be the manual procedure to failover from Primary to Standby and
Setthe old Primary as a new standby? 


step 1:  standby's recovery.conf :
# Specifies a trigger file whose presence should cause streaming replication to end (i.e., failover).
trigger_file = '/var/lib/postgresql/main/trigger'

step 2:  To trigger a smart failover, create a trigger file containing the word smart, or just create it and leave it
empty.(e.g.  
vi  /var/lib/postgresql/main/trigger
smart

step 3: wait until the failover is completed, the server is brought up after applying all WAL files available in the
archive. 
How to check if the failover is completed and the new Primary is ready?

step 4: if the failover is done
Do I need to edit the new primary's postgresql.conf and restart postgresql? e.g. comment out the hot_standy = on

step 5: how to quickly set the old primary as a new standby?
    SELECT pg_start_backup('replbackup');
    tar cfP /home/postgres/pg_backup.tar $PG_DATA
    SELECT pg_stop_backup();
    send  /home/postgres/pg_backup.tar to the old primary
    unzip the tar file to $PG_DATA & delete postmaster.pid
    create the recovery.conf
    edit the postgresql.conf to enable "hot_standby = on"
    start postgresql
if the PG_DATA has 600GB data, is there a quicker way to set the old primary as a new standby?


regards

pgsql-general by date:

Previous
From: Dave Cramer
Date:
Subject: Re: reading cvs logs with pgadmin queries
Next
From:
Date:
Subject: Upgrading from postgreSQL 9.1.6 to 9.3