Hacker News new | past | comments | ask | show | jobs | submit login

Question for PG happy users.

How do you manage failover and replication? At my previous job this was done by a consultant. Is this doable on a self hosted setup?

Thank you in advance.




PostgreSQL has replication built in now. I set it up at work, and it replicates reliably, in a fraction of a second. I've never had to fail over, but it seems straightforward to do so. The only hard part was following Postgres's documentation in setting it all up. It seemed to me a bit scattered to me. I had to jump around to different sections before I put it all together in my mind.


What do you use? Are there some instructions/articles that you'd recommend reading? Is it anything like Galera?

I know of BDR, but there hasn't much news about it lately, especially with more recent versions of Pg.

We like Galera for our simple needs: we use keepalived to do health checks, and if they pass the node participates in the VRRP cluster. If one node goes down/bad, another takes over.


If you want multi master in Postgres, I think BDR is going to be your best option, but the version for PG 10+ isn't open source so you'll have to pay for it. We're using the open source version on PG 9.4 currently in production, it's worked fine so far.

If you're just looking for a hot standby and dont need a multi master setup, you can set those up just with pg. https://www.postgresql.org/docs/9.4/hot-standby.html



We've been doing replication for 3+ years with zolando patroni. It works great. We run pg in docker and patroni too. First it was patroni with consul and right now its patroni with kubernes store (it store leader in endpoint). Highly recommend. There are other popular tools for this, it just a preference.


One option for automated health monitoring and failover is pglookout: https://github.com/aiven/pglookout


We use this, pgbouncer, and a bash script to link the two, for completely automated failover.

Queries done through pgbouncer just pause as if the query is really really slow when the db goes down, then when pglookout does the failover, the bash script switches pgbouncer's config and those pending queries are sent immediately.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: