How to failover from Primary to Standby and Set the old Primary as a new Standby

From: "ascot(dot)moss(at)gmail(dot)com" <ascot(dot)moss(at)gmail(dot)com>
To: pgsql-general general <pgsql-general(at)postgresql(dot)org>
Cc: ascot(dot)moss(at)gmail(dot)com
Subject: How to failover from Primary to Standby and Set the old Primary as a new Standby
Date: 2013-09-19 15:31:16
Message-ID: B0337069-7F51-41C0-A1DA-47CC75A6E59F@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Set the 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message fburgess 2013-09-19 15:34:18 Upgrading from postgreSQL 9.1.6 to 9.3
Previous Message Dave Cramer 2013-09-19 15:26:17 Re: reading cvs logs with pgadmin queries