(file) Return to dcs_warmstandby.txt CVS log (file) (dir) Up to [Development] / JSOC / doc

File: [Development] / JSOC / doc / dcs_warmstandby.txt (download)
Revision: 1.1, Mon Apr 12 16:49:53 2010 UTC (12 years, 8 months ago) by production
Branch: MAIN
CVS Tags: Ver_LATEST, Ver_DRMSLATEST, Ver_9-5, Ver_9-41, Ver_9-4, Ver_9-3, Ver_9-2, Ver_9-1, Ver_9-0, Ver_8-8, Ver_8-7, Ver_8-6, Ver_8-5, Ver_8-4, Ver_8-3, Ver_8-2, Ver_8-12, Ver_8-11, Ver_8-10, Ver_8-1, Ver_8-0, Ver_7-1, Ver_7-0, Ver_6-4, Ver_6-3, Ver_6-2, Ver_6-1, Ver_6-0, Ver_5-9, Ver_5-14, Ver_5-13, Ver_5-12, Ver_5-11, Ver_5-10, NetDRMS_Ver_LATEST, NetDRMS_Ver_9-9, NetDRMS_Ver_9-5, NetDRMS_Ver_9-41, NetDRMS_Ver_9-4, NetDRMS_Ver_9-3, NetDRMS_Ver_9-2, NetDRMS_Ver_9-1, NetDRMS_Ver_9-0, NetDRMS_Ver_8-8, NetDRMS_Ver_8-7, NetDRMS_Ver_8-6, NetDRMS_Ver_8-5, NetDRMS_Ver_8-4, NetDRMS_Ver_8-3, NetDRMS_Ver_8-2, NetDRMS_Ver_8-12, NetDRMS_Ver_8-11, NetDRMS_Ver_8-10, NetDRMS_Ver_8-1, NetDRMS_Ver_8-0, NetDRMS_Ver_7-1, NetDRMS_Ver_7-0, NetDRMS_Ver_6-4, NetDRMS_Ver_6-3, NetDRMS_Ver_6-2, NetDRMS_Ver_6-1, NetDRMS_Ver_6-0, NetDRMS_Ver_2-7, NetDRMS_Ver_2-5, NetDRMS_Ver_2-4, NetDRMS_Ver_2-3, HEAD
initial

			/home/production/cvs/JSOC/doc/dcs_warmstandby.txt

NOTICE: This isn't blind step-by-step procedures. You must understand
what is being done so that you can interpret the directions for what
exactly you want to do!

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

!!!BEGIN: To set up warm-standby for dcs0 on dcs2::
Assumes no DB for dcs0 running on dcs2. If so, 
pg_ctl -D /var/lib/pgsql/dcs0_data/ stop -m fast
Make sure no /tmp/pgsql.trigger.5430 on dcs2

Login to dcs0 as postgres
> ls -1 / | grep WALarchive | wc -l
1

NOTE: the original dcs0 will return 1. Orig dcs2 converted to dcs0 returns 0.

If (0) then
  cp configfiles/postgresql.conf.dcs0.0 dcs0_data/postgresql.conf
  rm -f  /data/WALarchive/5430/*

if (1) then
  cp configfiles/postgresql.conf.dcs0.1 dcs0_data/postgresql.conf
  rm -f  /WALarchive/5430/*

Restart the dcs0 database to create WAL archives:
> pg_ctl -D /var/lib/pgsql/dcs0_data -m fast stop
> pg_ctl -D /var/lib/pgsql/dcs0_data/ start

Begin the backup process on dcs0:
> psql -p 5430 -c "select pg_start_backup('2010-03-15')"

Create a tar archive of the system data directory:
> tar -czvf dcs0_backup.tar.gz dcs0_data/

Stop the backup process on dcs0:
> psql -p 5430 -c "select pg_stop_backup()"

Copy the archive file from dcs0 to dcs2:
> scp dcs0_backup.tar.gz postgres@dcs2:/var/lib/pgsql/

Now login to dcs2 as postgres:
> rm -rf dcs0_data
> rm -rf dcs1_data  (NOT if just doing warm-standby for dcs0??)

Uncompress the archive file:
> tar -xzvf dcs0_backup.tar.gz

> ls -1 / | grep WALarchive | wc -l
0

if(0) then
  cp configfiles/recovery.conf.dcs0.0 dcs0_data/recovery.conf
  cp configfiles/postgresql.conf.dcs0.ws dcs0_data/postgresql.conf
if(1) then
  cp configfiles/recovery.conf.dcs0.1 dcs0_data/recovery.conf
  cp configfiles/postgresql.conf.dcs0.ws dcs0_data/postgresql.conf

Remove the postmaster.pid file:
> rm dcs0_data/postmaster.pid

> chmod 700 /var/lib/pgsql/dcs0_data/

Start the dcs0 warm standby server, execute the command:
> pg_ctl -D /var/lib/pgsql/dcs0_data/ start

The server should go into recovery mode and stay there.
After everything looks good, remove the tar file from dcs2:
> rm dcs0_backup.tar.gz
!!!END: To set up warm-standby for dcs0 on dcs2::
==========================================================================


!!!BEGIN: To set up warm-standby for dcs1 on dcs2::
Assumes no DB for dcs1 running on dcs2. If so, 
pg_ctl -D /var/lib/pgsql/dcs1_data/ stop -m fast
Make sure no /tmp/pgsql.trigger.5431 on dcs2

Login to dcs1 as postgres
> ls -1 / | grep WALarchive | wc -l
1

NOTE: the original dcs0 will return 1. Orig dcs2 converted to dcs0 returns 0.

If (0) then
  cp configfiles/postgresql.conf.dcs1.0 dcs1_data/postgresql.conf
  rm -f  /data/WALarchive/5431/*

if (1) then
  cp configfiles/postgresql.conf.dcs1.1 dcs1_data/postgresql.conf
  rm -f  /WALarchive/5431/*

Restart the dcs1 database to create WAL archives:
> pg_ctl -D /var/lib/pgsql/dcs1_data -m fast stop
> pg_ctl -D /var/lib/pgsql/dcs1_data/ start

Begin the backup process on dcs1:
> psql -p 5431 -c "select pg_start_backup('2010-03-15')"

Create a tar archive of the system data directory:
> tar -czvf dcs1_backup.tar.gz dcs1_data/

Stop the backup process on dcs0:
> psql -p 5431 -c "select pg_stop_backup()"

Copy the archive file from dcs1 to dcs2:
> scp dcs1_backup.tar.gz postgres@dcs2:/var/lib/pgsql/

Now login to dcs2 as postgres:
> rm -rf dcs1_data

Uncompress the archive file:
> tar -xzvf dcs1_backup.tar.gz

> ls -1 / | grep WALarchive | wc -l
0

if(0) then
  cp configfiles/recovery.conf.dcs1.0 dcs1_data/recovery.conf
  cp configfiles/postgresql.conf.dcs1.ws dcs1_data/postgresql.conf
if(1) then
  cp configfiles/recovery.conf.dcs1.1 dcs1_data/recovery.conf
  cp configfiles/postgresql.conf.dcs1.ws dcs1_data/postgresql.conf

Remove the postmaster.pid file:
> rm dcs1_data/postmaster.pid

> chmod 700 /var/lib/pgsql/dcs1_data/

Start the dcs1 warm standby server, execute the command:
> pg_ctl -D /var/lib/pgsql/dcs1_data/ start

The server should go into recovery mode and stay there.
After everything looks good, remove the tar file from dcs2:
> rm dcs1_backup.tar.gz
!!!END: To set up warm-standby for dcs1 on dcs2::
==========================================================================

!!!BEGIN: dcs0 fails. Switch over to warm-standby on dcs2:
Ensure that the database on the dcs0 server is down:
> pg_ctl -D /var/lib/pgsql/dcs0_data -m fast stop

Login to dcs2 as postgres.
Make sure no dcs1 warm-standby is running:
> pg_ctl -D /var/lib/pgsql/dcs1_data/ stop -m fast

To bring the dcs0 warm standby out of recovery mode and make it live:
NOTE: run psql -p 5430 -l before and after this to see the db come online
> touch /tmp/pgsql.trigger.5430

!!TBD find out when to rm /tmp/pgsql.trigger.5430

Now make dcs2 the new dcs0. Run as root: 
(MAKE sure old dcs0 is down. Do not bring it up again with 2 dcs0's)
> /etc/sysconfig/network/AIA-up

To restore to dcs2 again:
> /etc/sysconfig/network/MYSELF-up


As user production on the new dcs0:
> vncserver -geometry 1280x1024
On j0:
j0:/home/production> vncviewer
answer dcs0.jsoc.Stanford.EDU:1

Apply crontab -e from /home/production/crontab.dcs0


Karen Tian
Powered by
ViewCVS 0.9.4