GithubHelp home page GithubHelp logo

jason810496 / postgresql-primary-replica-auto-setup Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 477 KB

Automate the configuration of a primary-replica architecture for PostgreSQL under Docker Compose using a Makefile and shell script.

License: MIT License

Makefile 3.44% Shell 96.56%
automation docker-compose makefile postgresql shell-script primary-replica

postgresql-primary-replica-auto-setup's Introduction

Postgresql Priamry-Replica Auto-Setup

License: MIT DB : postgresql


architecture


Automate the configuration of a primary-replica architecture for PostgreSQL under Docker Compose using a Makefile and shell script.

Demo

demo

Click image to watch demo video on YouTube ☝️

Usage

make all
# wait input of `pg_basebackup` command with `REPLICA_PASSWORD` password authentication input

REPLICA_PASSWORD is the password of the REPLICA_USER user in the primary container.
REPLICA_PASSWORD can be set in the db.env file.

Project Structure

.
├── Makefile
├── README.md
├── db_volumes
│   ├── primary
│   ├── primary_copy
│   └── replica
├── docker-compose.yml
└── primary-replica
    ├── db.env
    ├── pg_hba.conf
    ├── postgresql.conf
    ├── reset.sh
    ├── setup.sh
    └── test.sh

5 directories, 9 files
  • db.env - Environment variables for the Docker Compose env_file directive and the *.sh scripts.
  • pg_hba.conf

    PostgreSQL host-based authentication configuration file.
    We use this to allow the replica to connect to the primary.
    Will be copied to the primary container.

  • postgresql.conf - PostgreSQL configuration file.

db.env

POSTGRES_PASSWORD=postgresql_password
POSTGRES_USER=postgresql_user
POSTGRES_DB=postgresql_db

REPLICA_USER=repluser
REPLICA_PASSWORD=replpass

db_volumes

  • primary - PostgreSQL data directory for the primary container.
  • replica - PostgreSQL data directory for the replica container.
  • primary_copy - Volume for copying the primary data directory to the replica data directory.

Requirements

  • Docker Compose
  • Make
  • Bash

References

Issues & PR

Feel free to open an issue !

Pull requests are welcome.
Any contributions you make are greatly appreciated.

postgresql-primary-replica-auto-setup's People

Contributors

jason810496 avatar

Watchers

 avatar

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.