Monday 2 December 2013

Failover on Postgresql 9.1 and above

The previous post allowed you to create a server in HOT standby mode. As mentioned earlier, you can only use this to do readonly queries. Now let us say that the primary server goes down, following are the steps you'll need to promote the standby server and make it your primary.
Open a shell on the standby server with the postgres user and type:
pg_ctl promote -D /var/lib/pgsql/9.2/data/
And that is it! Your standby server has now become a primary instance, ie, you can do inserts, deletes and updates now.
Please note that if the standby server fails, we quickly need to bring that back as well. To detect failure, on a daily basis, you should do a count on the audit log table on both primary and standby and make sure they are equal. If the standby fails, it is best to kill that database and redo the steps from the previous post.

No comments:

Post a Comment