What to do after PostgreSQL failover

In the article on http://community.cloud66.com/articles/postgresql-failover-procedure it explains the procedure for a failover properly. But I was wondering, what you should do after the failover happened.

If I understand correctly, after the failover, you’ll end up with the following environment variables: POSTGRESQL_ADDRESS = {{POSTGRESQL_SLAVE_ADDRESSES_INT}} POSTGRESQL_SLAVE_ADDRESSES = {{POSTGRESQL_SLAVE_ADDRESSES_INT}}

At what point, if at all, should this be moved back to POSTGRESQL_ADDRESS = {{POSTGRESQL_ADDRESS_INT}} POSTGRESQL_SLAVE_ADDRESSES = {{POSTGRESQL_SLAVE_ADDRESSES_INT}}

Hi Tim,

Thanks for your question. The article you reference there describes the manual way of conducting a PostgreSQL failover, and you’d need to update the relevant environment variables yourself in order to point your application at the new master.

Typically, your application will use the POSTGRESQL_ADDRESS environment variable to connect to your database. If you conduct a manual failover, you will need to insert the IP address of the new master database so that the connection can be established.

With that said, we also have a toolbelt function to promote a slave to a master, which automatically updates those environment variables for you. Using one over the other depends on your situation - in an emergency, it may indeed be quicker (but more manual) to do the manual failover. In any case, I’d suggest trying this in a staging environment so that you’re familiar with the procedure in case you need to run it in the future.

I hope this answers your question.

You must be logged in to answer this question