Giter Club home page Giter Club logo

postgresql-patroni-setup's Introduction

postgresql-patroni-setup

Overview

This repo it helps you quickly spin up a 3-node cluster of PostgreSQL, managed by Patroni using Consul.

What's in the cluster?

When you start the cluster, you get 2 nodes (pg01 and pg02), each running:

  • PostgreSQL
  • Patroni
  • Consul agent

and a third node (pg03) running:

  • Consul (server)
  • HAProxy
  • pgBouncer

The connection/data path is the following:

  1. pgBouncer (where the app will connect)
  2. HAProxy
  3. PostgreSQL

All packages are from Ubuntu 16.04, except for PostgreSQL itself, which is at version 12.x.

The cluster is configured with a single primary and one asynchronous streaming replica.

Dependencies

  1. Virtualbox
  2. Vagrant
  3. git clone https://github.com/vtomasr5/postgresql-patroni-setup.git

Getting started

  1. On 3 separate windows:
  2. vagrant up pg03 && vagrant ssh pg03 # pg03 contains the consul server and it must start first
  3. vagrant up pg01 && vagrant ssh pg01
  4. vagrant up pg02 && vagrant ssh pg02

Viewing cluster status

Get patroni information from his members

  • patronictl -c /etc/patroni/patroni.yml list

Connecting to PostgreSQL

You should use the pgBouncer connection pool

  • 172.28.33.13:6432

But you can also connect via HAproxy using the balancing IP

  • 172.28.33.13:5000 (postgresql)
  • 172.28.33.13:7000 (HAProxy stats)

TODO

  • Add pgBouncer support
  • Test on a Windows host (tested on Linux and macOS hosts)
  • Improve documentation

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

References

postgresql-patroni-setup's People

Contributors

vtomasr5 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

kokpheng

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.