Giter Club home page Giter Club logo

devops-postgres-logical-data-replication's Introduction

DevOps Postgres Data Replication

Postgres 13 Dockerized with Replication Master/Slave Postgres Replication through logical method

Quickstart: docker-compose up

HOW-TO Test

WARNING, run in all instances (Logical replical does not replicate DDL):

CREATE TABLE customers ( id int GENERATED ALWAYS AS IDENTITY PRIMARY KEY, first_name varchar(255) NOT NULL, last_name varchar(255) NOT NULL, email varchar(255) NOT NULL );

Run in db-origin(Master):

CREATE PUBLICATION PUBLICATION_TO_ALL FOR ALL TABLES;

Run in db-intermediate(Slave 1):

CREATE PUBLICATION PUBLICATION_TO_ALL FOR ALL TABLES; (just to test if the db-final-destination will be read to read through replica)

CREATE SUBSCRIPTION SUBSCRIBE_TO_ALL_2 CONNECTION 'host=db-origin dbname=postgres user=postgres password=admin' PUBLICATION PUBLICATION_TO_ALL; (To read from Master)

Run in db-destination(Slave 2):

CREATE SUBSCRIPTION SUBSCRIBE_TO_ALL CONNECTION 'host=db-intermediate dbname=postgres user=postgres password=admin' PUBLICATION PUBLICATION_TO_ALL_2; (To read from Slave)

Test Insert / Update commands in MASTER:

INSERT INTO customers (first_name, last_name, email) VALUES ('Timoteo', 'Soutello', '[email protected]);

Useful commands

  • Get the default config
    • docker run -i --rm postgres cat /usr/share/postgresql/postgresql.conf.sample > my-postgres.conf
    • docker run -i --rm postgres cat /usr/share/postgresql/13/pg_hba.conf.sample > pg_hba.conf

References

devops-postgres-logical-data-replication's People

Contributors

timoteosoutello avatar

Watchers

James Cloos avatar  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.