docker-postgres-bdr
docker-postgres-bdr copied to clipboard
PostgreSQL with Bi-Directional Replication in a docker. (CentOS7+Supervisor)
PostgreSQL with BDR B-Directional Replication in a docker.
Docker Image with PostgreSQL server with BDR support for database Bi-Directional replication. Based on CentOS with Supervisor.
User can specify if database should work as stand-alone
or master/slave
mode. Even though BDR is more master/master
solution we need to deploy first image which will create BDR setup inside of PostgreSQL. So for this purpose on run
we need to specify one image to be so called master.
Environmental Variables
Variable | Meaning |
---|---|
POSTGRES_PASSWORD |
Self explanatory |
POSTGRES_USER |
Self explanatory |
POSTGRES_DB |
Self explanatory |
POSTGRES_PORT |
Self explanatory |
MODE |
Mode in which this image shoudl work. Options: single/master/slave (default=single) |
MASTER_ADDRESS |
Address of master node |
MASTER_PORT |
Master node port |
SLAVE_PORT |
Slave node port |
Usage
Stand-Alone mode
docker run \
-d \
--name postgres \
-p 5432:5432 \
polinux/postgres-bdr
Master + 2 slaves
Use docker-compose.yml
exmple.
Deploy all at once from docker-compose-yml
file.
docker compose up
Deploy master only
docker compose up master
Deploy slave1 only
docker compose up slave1
Deploy slave2 only
docker compose up slave2
Build
docker build -t polinux/postgres-bdr .
Docker troubleshooting
Use docker command to see if all required containers are up and running:
$ docker ps
Check logs of postgres-bdr server container:
$ docker logs postgres-bdr
Sometimes you might just want to review how things are deployed inside a running container, you can do this by executing a bash shell through docker's exec command:
docker exec -ti postgres-bdr /bin/bash
History of an image and size of layers:
docker history --no-trunc=true polinux/postgres-bdr | tr -s ' ' | tail -n+2 | awk -F " ago " '{print $2}'
Author
Przemyslaw Ozgo ([email protected])
This work is also inspired by agios's work on their docker images. Many thanks!