Quick start on Hot Standby

Updated.

We could have some better end-user documentation around creating a warm or hot standby system for basic postgresql replication.

To this end, I created a Quick Start doc on the wiki, but it could use more help. Maybe we should create some setup recipes for common situations?

Also – I wrote the following script during a hot standby bugbash PDXPUG had today:


#!/bin/sh

BINPATH=/usr/local/pg90/bin
CP=/bin/cp
PGCTL=${BINPATH}/pg_ctl
PSQL=${BINPATH}/psql
INITDB=${BINPATH}/initdb

sudo mkdir -p /var/tmp/archive
sudo chown ${USER} /var/tmp/archive

${INITDB} hotstandby1

echo 'wal_level = hot_standby' >> hotstandby1/postgresql.conf
echo 'archive_mode = on' >> hotstandby1/postgresql.conf
echo "archive_command = 'cp %p /var/tmp/archive/%f'" >> hotstandby1/postgresql.conf
echo "archive_timeout = 60" >> hotstandby1/postgresql.conf
echo "port = 6543" >> hotstandby1/postgresql.conf

${PGCTL} -D hotstandby1 start -l hotstandby1.log
sleep 5

${PSQL} -p 6543 postgres -c "select pg_start_backup('backup')"
${CP} -pR hotstandby1/ hotstandby2
${PSQL} -p 6543 postgres -c "select pg_stop_backup()"
rm hotstandby2/postmaster.pid
rm hotstandby2/pg_xlog/*

echo 'hot_standby = on' >> hotstandby2/postgresql.conf
echo 'port = 6544' >> hotstandby2/postgresql.conf
echo "standby_mode = 'on'" >> hotstandby2/recovery.conf
echo "restore_command = 'cp -i /var/tmp/archive/%f %p'" >> hotstandby2/recovery.conf

${PGCTL} -D hotstandby2 start -l hotstandby2.log

* Added port specification in case you’ve already got postgres running. Added a BINPATH for custom install directories.

Weekly tweet digest for 2010-07-11

Weekly tweet digest for 2010-07-11

twittering on 2010-07-11

  • "Blythe disregard for what others say is not possible." YES! #hackers #
  • Interested in finding any studies of FOSS and geo relationships of founders and core devs. #
  • Ping me if you want to come with me to #devnation this morning. (downtown, at the cleaners!) #
  • My slides from this morning about making software community: http://chesnok.com/devnation.pdf #devnation #
  • best: "Work with the guy with the funny accent in the office" RT @kartar: @selenamarie Thanks for the rewrite help – http://bit.ly/cjroPr #
  • At home. Chillin' in the back yard. Stop by if you're in the neighborhood! :) #
  • Home sweet home http://flic.kr/p/8hv51u #

twittering on 2010-07-11

  • "Blythe disregard for what others say is not possible." YES! #hackers #
  • Interested in finding any studies of FOSS and geo relationships of founders and core devs. #
  • Ping me if you want to come with me to #devnation this morning. (downtown, at the cleaners!) #
  • My slides from this morning about making software community: http://chesnok.com/devnation.pdf #devnation #
  • best: "Work with the guy with the funny accent in the office" RT @kartar: @selenamarie Thanks for the rewrite help – http://bit.ly/cjroPr #
  • At home. Chillin' in the back yard. Stop by if you're in the neighborhood! :) #
  • Home sweet home http://flic.kr/p/8hv51u #

Weekly tweet digest for 2010-07-04

  • Learned a new word today: sledging #foocamp #
  • crazy tired. so happy to have met so many people at #foocamp #
  • My brain is exploding with ideas. #foocamp #
  • Forgetting: Logging as an ethical choice http://bit.ly/anfN26 #foocamp #
  • Forgetting: Logging as an ethical choice http://bit.ly/anfN26 #foocamp #design #consequences #
  • Reviewing @LuciousPear's suggestions for educating my coworkers in Nashville on modern metal this Friday. #
  • Getting ready for @osbridge core team wrapup meeting tonight. #
  • OH: THERE WAS A MNEUMONIC! it went south to north from bottom floor to top. #osbridge #
  • Um. I need to pack. #
  • Made the cashier blush by buying the rolling stone with lady gaga and that runaway general article. #
  • And next week is postgresql's birthday. Thinking I need to do something special. #
  • At the grande ole opry http://flic.kr/p/8fxMxb #
  • Travis Mann band http://flic.kr/p/8fwW7P #