{"id":1808,"date":"2010-07-12T19:48:12","date_gmt":"2010-07-13T03:48:12","guid":{"rendered":"http:\/\/www.chesnok.com\/daily\/?p=1808"},"modified":"2012-03-26T02:55:38","modified_gmt":"2012-03-26T10:55:38","slug":"quick-start-on-hot-standby","status":"publish","type":"post","link":"https:\/\/www.chesnok.com\/daily\/2010\/07\/12\/quick-start-on-hot-standby\/","title":{"rendered":"Quick start on Hot Standby"},"content":{"rendered":"<p><strong>Updated.<\/strong><\/p>\n<p>We could have some better end-user documentation around creating a warm or hot standby system for basic postgresql replication. <\/p>\n<p>To this end, I created a <a href=\"http:\/\/wiki.postgresql.org\/wiki\/Hot_Standby#Quick_Start\">Quick Start<\/a> doc on the wiki, but it could use more help.  Maybe we should create some setup recipes for common situations?<\/p>\n<p>Also &#8211; I wrote the following script during a <a href=\"http:\/\/archives.postgresql.org\/pdxpug\/2010-07\/msg00002.php\">hot standby bugbash<\/a> <a href=\"http:\/\/pugs.postgresql.org\/pdx\">PDXPUG<\/a> had today:<\/p>\n<p><code><br \/>\n#!\/bin\/sh<\/p>\n<p>BINPATH=\/usr\/local\/pg90\/bin<br \/>\nCP=\/bin\/cp<br \/>\nPGCTL=${BINPATH}\/pg_ctl<br \/>\nPSQL=${BINPATH}\/psql<br \/>\nINITDB=${BINPATH}\/initdb<\/p>\n<p>sudo mkdir -p \/var\/tmp\/archive<br \/>\nsudo chown ${USER} \/var\/tmp\/archive<\/p>\n<p>${INITDB} hotstandby1<\/p>\n<p>echo 'wal_level = hot_standby' >> hotstandby1\/postgresql.conf<br \/>\necho 'archive_mode = on' >> hotstandby1\/postgresql.conf<br \/>\necho \"archive_command = 'cp %p \/var\/tmp\/archive\/%f'\" >> hotstandby1\/postgresql.conf<br \/>\necho \"archive_timeout = 60\" >> hotstandby1\/postgresql.conf<br \/>\necho \"port = 6543\" >> hotstandby1\/postgresql.conf<\/p>\n<p>${PGCTL} -D hotstandby1 start -l hotstandby1.log<br \/>\nsleep 5<\/p>\n<p>${PSQL} -p 6543 postgres -c \"select pg_start_backup('backup')\"<br \/>\n${CP} -pR hotstandby1\/ hotstandby2<br \/>\n${PSQL} -p 6543 postgres -c \"select pg_stop_backup()\"<br \/>\nrm hotstandby2\/postmaster.pid<br \/>\nrm hotstandby2\/pg_xlog\/*<\/p>\n<p>echo 'hot_standby = on' >> hotstandby2\/postgresql.conf<br \/>\necho 'port = 6544' >> hotstandby2\/postgresql.conf<br \/>\necho \"standby_mode = 'on'\" >> hotstandby2\/recovery.conf<br \/>\necho \"restore_command = 'cp -i \/var\/tmp\/archive\/%f %p'\" >> hotstandby2\/recovery.conf<\/p>\n<p>${PGCTL} -D hotstandby2 start -l hotstandby2.log<br \/>\n<\/code><\/p>\n<p>* Added port specification in case you&#8217;ve already got postgres running. Added a BINPATH for custom install directories.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &hellip; <a href=\"https:\/\/www.chesnok.com\/daily\/2010\/07\/12\/quick-start-on-hot-standby\/\">Continue reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[97,9],"tags":[182,629,647,624,326,325,183],"class_list":["post-1808","post","type-post","status-publish","format-standard","hentry","category-postgres","category-postgresql","tag-hot-standby","tag-pdxpug","tag-postgres","tag-postgresql","tag-quickstart","tag-recipe","tag-replication"],"_links":{"self":[{"href":"https:\/\/www.chesnok.com\/daily\/wp-json\/wp\/v2\/posts\/1808","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.chesnok.com\/daily\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.chesnok.com\/daily\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.chesnok.com\/daily\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.chesnok.com\/daily\/wp-json\/wp\/v2\/comments?post=1808"}],"version-history":[{"count":7,"href":"https:\/\/www.chesnok.com\/daily\/wp-json\/wp\/v2\/posts\/1808\/revisions"}],"predecessor-version":[{"id":3985,"href":"https:\/\/www.chesnok.com\/daily\/wp-json\/wp\/v2\/posts\/1808\/revisions\/3985"}],"wp:attachment":[{"href":"https:\/\/www.chesnok.com\/daily\/wp-json\/wp\/v2\/media?parent=1808"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chesnok.com\/daily\/wp-json\/wp\/v2\/categories?post=1808"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chesnok.com\/daily\/wp-json\/wp\/v2\/tags?post=1808"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}