{"id":1813,"date":"2010-07-12T20:17:16","date_gmt":"2010-07-13T04:17:16","guid":{"rendered":"http:\/\/www.chesnok.com\/daily\/?p=1813"},"modified":"2012-03-26T02:55:37","modified_gmt":"2012-03-26T10:55:37","slug":"qa-about-hot-standby","status":"publish","type":"post","link":"https:\/\/www.chesnok.com\/daily\/2010\/07\/12\/qa-about-hot-standby\/","title":{"rendered":"Q&#038;A about Hot Standby"},"content":{"rendered":"<p><strong>Updated!<\/strong>: See below.<\/p>\n<p>Here are some questions that came up from trying to use the current <a href=\"http:\/\/www.postgresql.org\/docs\/9.0\/static\/hot-standby.html\">PostgreSQL hot standby<\/a> documentation: <\/p>\n<p><strong>Q: If you set <code>hot_standby = off<\/code> after having it on, what happens?<br \/>\n<\/strong><br \/>\nA: This change requires a database restart on the hot standby (or replica) server. The database goes into &#8220;warm standby&#8221; mode, and you can no longer issue queries against it. You can change this right back by setting the parameter to &#8216;on&#8217; and restarting again.<\/p>\n<p><strong>Q: Can you use hot standby with only a single schema or database?<br \/>\n<\/strong><br \/>\nA: No. Hot Standby is all-or-nothing for a particular PostgreSQL <a href=\"http:\/\/www.postgresql.org\/docs\/9.0\/static\/creating-cluster.html\">database cluster<\/a>. A cluster is made up of all the databases that live in a particular $PGDATA instance, and Hot Standby is currently not capable of distinguishing between changes occurring on different particular databases or schemas.<\/p>\n<p><strong>Q: Is the process for setting up hot standby any different for empty databases vs. populated databases?<br \/>\n<\/strong><br \/>\nA: No. The setup process is the same &#8211; you must create a <a href=\"http:\/\/www.postgresql.org\/docs\/9.0\/static\/continuous-archiving.html#BACKUP-BASE-BACKUP\">base backup<\/a>.<\/p>\n<p><strong>Q: How do I bring my hot standby out of standby mode?<br \/>\n<\/strong><br \/>\nA: If you&#8217;re using something like the following in your recovery.conf file:<br \/>\n<code><br \/>\nrestore_command = 'cp xxxx'<br \/>\nstandby_mode = 'on'<br \/>\n<\/code><\/p>\n<p>Change: <code>standby_mode = 'off'<\/code> and restart your hot standby postgresql instance.<\/p>\n<p><strong>Q: Where did my <code>recovery.conf<\/code> file go? (after your database came out of warm\/hot standby)<br \/>\n<\/strong><br \/>\nA: PostgreSQL automatically changes the name of the file to <code>recovery.done<\/code> when recovery completes. This helps prevent accidents.<\/p>\n<p><strong>Q: What happens if my <code>archive_timeout = 60<\/code> (which creates a 16mb file every minute) and I flood the database with so much activity that my standby falls behind?<br \/>\n<\/strong><br \/>\nA: This is possible, and you may be interested in trying <a href=\"http:\/\/www.postgresql.org\/docs\/9.0\/static\/warm-standby.html#STREAMING-REPLICATION\">Streaming Replication<\/a>. However, for the majority of users, a delay in restoring data is acceptable (and possibly desirable). Eventually the standby server will catch up.  You can monitor how delayed the server is using functions like   <code>txid_current_snapshot()<\/code>.<\/p>\n<p><strong>Q: Are schema changes (like CREATE TABLE or ALTER TABLE) replicated to the standby?<br \/>\n<\/strong><br \/>\nA: Yes! All changes to the database cluster are copied to the standby. This includes any DDL operations, new rows, the effects of autovacuum &#8212; any change to the data store on the master is copied to the standby.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Updated!: See below. Here are some questions that came up from trying to use the current PostgreSQL hot standby documentation: Q: If you set hot_standby = off after having it on, what happens? A: This change requires a database restart &hellip; <a href=\"https:\/\/www.chesnok.com\/daily\/2010\/07\/12\/qa-about-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":[328,182,647,624,327,326],"class_list":["post-1813","post","type-post","status-publish","format-standard","hentry","category-postgres","category-postgresql","tag-9-0","tag-hot-standby","tag-postgres","tag-postgresql","tag-qa","tag-quickstart"],"_links":{"self":[{"href":"https:\/\/www.chesnok.com\/daily\/wp-json\/wp\/v2\/posts\/1813","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=1813"}],"version-history":[{"count":10,"href":"https:\/\/www.chesnok.com\/daily\/wp-json\/wp\/v2\/posts\/1813\/revisions"}],"predecessor-version":[{"id":3984,"href":"https:\/\/www.chesnok.com\/daily\/wp-json\/wp\/v2\/posts\/1813\/revisions\/3984"}],"wp:attachment":[{"href":"https:\/\/www.chesnok.com\/daily\/wp-json\/wp\/v2\/media?parent=1813"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chesnok.com\/daily\/wp-json\/wp\/v2\/categories?post=1813"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chesnok.com\/daily\/wp-json\/wp\/v2\/tags?post=1813"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}