Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gocardless/our-postgresql-setup
PostgreSQL clustering with corosync/pacemaker test environment
https://github.com/gocardless/our-postgresql-setup
cluster pacemaker pgbouncer postgresql-cluster
Last synced: 3 months ago
JSON representation
PostgreSQL clustering with corosync/pacemaker test environment
- Host: GitHub
- URL: https://github.com/gocardless/our-postgresql-setup
- Owner: gocardless
- Archived: true
- Created: 2015-10-27T09:50:11.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2022-12-19T20:06:44.000Z (almost 2 years ago)
- Last Synced: 2024-06-03T09:45:05.219Z (5 months ago)
- Topics: cluster, pacemaker, pgbouncer, postgresql-cluster
- Language: Shell
- Homepage:
- Size: 35.2 KB
- Stars: 125
- Watchers: 79
- Forks: 11
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
our-postgresql-setup
====================**ARCHIVED**: This configuration is no longer used by GoCardless, see the replacement at https://github.com/gocardless/stolon-pgbouncer
# Overview
This repo is an extracted version of how we run PostgreSQL clusters at GoCardless.
It helps you quickly spin up a 3-node cluster of PostgreSQL, managed by Pacemaker, and proxied by PgBouncer.
It's intended as a playground for us, and a learning resource that we wanted to share with the community.
You can hear more about how the cluster works in our talk - [Zero-downtime Postgres upgrades](https://www.youtube.com/watch?v=SAkNBiZzEX8).
# What's in the cluster?
When you start the cluster, you get 3 nodes, each running:
- PostgreSQL
- Pacemaker
- PgBouncerAll packages are from Ubuntu 14.04, except for PostgreSQL itself, which is at version 9.4.
The cluster is configured with a single primary, one synchronous replica, and one asynchronous replica.
# Dependencies
1. [Virtualbox](https://www.virtualbox.org/wiki/Downloads)
2. [Vagrant](http://www.vagrantup.com/downloads.html)
3. ` git clone https://github.com/gocardless/our-postgresql-setup.git`
4. [Recommended] [tmux](https://tmux.github.io)# Getting started
## With tmux (recommended)
1. `./tmux-session.sh start`## By hand
1. On 3 separate windows:
2. `vagrant up pg01 && vagrant ssh pg01`
3. `vagrant up pg02 && vagrant ssh pg02`
4. `vagrant up pg03 && vagrant ssh pg03`# Viewing cluster status
You can run `crm_mon -Afr` on any node to see the current state of the cluster and all resources in it. Press `^c` to quit.
# Connecting to PostgreSQL
Once the cluster is up, you have two options:
- Connect directly to Postgres on the PostgresqlVIP at 172.28.33.10
- Connect via PgBouncer at 172.28.33.9*Note*: The migrator.py script will only give you zero-downtime migrations if you connect via PgBouncer.
# Running a zero-downtime migration
1. Ensure clients are connected to the PgBouncerVIP.
2. Run `/vagrant/migrator.py` on the node that has the PgBouncerVIP (you can find out where the PgBouncerVIP is by viewing the cluster status).
3. Follow the prompts.
1. It is safe to ignore the `Make sure you have the following command ready...` prompt. This is aimed at cases where you'd want to quickly re-enable traffic, and doesn't matter when running locally.
4. Assuming everything went well, the primary will migrate to the synchronous replica, and the clients won't have received any connection resets.# I have a question!
We're happy to receive questions as issues on this repo, so don't be shy!
It's hard to know exactly what documentation/guidance is useful to people, so we'll use the questions we answer to improve this README and link out to more places you can read up on the technologies we're using.
# Further reading
* [Pacemaker CRM shell Quick Reference](https://github.com/ClusterLabs/pacemaker/blob/master/doc/pcs-crmsh-quick-ref.md)# References
* [PostgreSQL](https://www.postgresql.org)
* [tmux](https://tmux.github.io)
* [Vagrant](http://vagrantup.com)
* [VirtualBox](http://www.virtualbox.org)