/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