danieldent / docker-postgres-replication Goto Github PK
View Code? Open in Web Editor NEWPostgres 9.6 & 9.5 Dockerized w/ Replication. Master/Slave setup in 30 seconds.
Home Page: https://hub.docker.com/r/danieldent/postgres-replication/
Postgres 9.6 & 9.5 Dockerized w/ Replication. Master/Slave setup in 30 seconds.
Home Page: https://hub.docker.com/r/danieldent/postgres-replication/
I am a complete beginner in Postgres, and I have pulled your docker master/slave image but it seems to be lacking the documentation onto what should be done after this pull.
I have tried docker run danieldent/postgres-replication
but it takes me to a series of log messages and takes away the shell to actually do anything, please guide me in this regard
Thanks
I'm migrating the docker-compose.yml to kubernetes, but I'm facing an issue that it seems to me has nothing to do with k8s, but with postgres, and I'm not an expert in postgres.
I got the following error when connecting a slave to a successfully deployed (and functional) master:
2016-10-26T10:39:48.274183765Z pg_basebackup: could not connect to server: FATAL: role "-vP" does not exist
2016-10-26T10:39:48.274942692Z Waiting for master to connect...
The message repeats endlessly because it's inside a until/done structure.
The k8s pod file below:
apiVersion: v1
kind: Pod
metadata:
name: postgres-slave
labels:
name: postgres-slave
spec:
containers:
- name: postgres-slave
image: danieldent/postgres-replication:9.6
env:
- name: POSTGRES_USER
value: "postgres"
- name: POSTGRES_PASSWORD
value: "postgres"
- name: PGDATA
value: "/var/lib/postgresql/data/pgdata"
- name: REPLICATE_FROM
value: "10.1.5.4"
ports:
- containerPort: 5432
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: pg-data-slave
volumes:
- name: pg-data-slave
emptyDir: {}
The container pings successfully to the master in 10.1.5.4 (I know I should connect to a service name, but this is a test), but afterwards I got the error above.
Now, if I change POSTGRES_USER and POSTGRES_PASSWORD to the deprecated version (PGUSER and PGPASSWORD), then the container passes the endless loop and replicates from the master correctly.
Excuse my newb-ness on this (and if there's a better place to ask, let me know), but I cannot seem to actually connect to the database once this is running. I cloned the repo, didn't change anything (as I just need this for some local dev testing), and did docker-compose up
. It seems to run fine, as I see this in the output:
pg-master_1 | LOG: database system is ready to accept connections
pg-slave_1 | LOG: database system is ready to accept read only connections
I see the two containers in docker ps
, etc. I then tried to actually attach to it, e.g.:
psql -h 172.18.0.2 -U postgres -W
IP address I got from doing docker inspect on the master's container ID. This eventually just times out. I'm running this on a Mac. Could you clue me in to what I'm missing/doing wrong?
Hi thanks for your code,
i'm looking for a solution that don't use persistent volumes. My goal is to be able to reinitializate the postgres data inside the master container, recovering them from a replica that is still alive, without the needs of share a common folder.I don't want to mount anything inside the container and be sure that if 1 replica stay up, all the data will be restored on master and the other replicas. Can you help me?
Hi, I just want to know the current status of this project as the last commit is from more than a year ago. Would be a waste if this project ends up dying. And want to say that I am interested in helping to maintain this project. What would be the first steps to do so?
Hi!
I'm probably stupid but I can't connect to the database with laravel. What should I put in the .env
file?
I've tried everything:
this is my docker-composer:
services:
php:
image: swithfr/php:7.2
volumes:
- ".:/var/www/laratest"
nginx:
image: nginx:latest
volumes:
- "./docker/nginx.conf:/etc/nginx/conf.d/default.conf"
links:
- php
ports:
- 8888:80
pg-master:
image: swithfr/pgsql-replication
restart:'always'.
environment:
POSTGRES_USER: "postgres
POSTGRES_PASSWORD:'postgres'.
PGDATA:'/var/lib/postgresql/data/pgdata'
volumes:
- '/var/lib/postgresql/data'
exposes:
- '5432'
pg-slave:
image: swithfr/pgsql-replication
restart:'always'.
environment:
POSTGRES_USER: "postgres
POSTGRES_PASSWORD:'postgres'.
PGDATA:'/var/lib/postgresql/data/pgdata'
REPLICATE_FROM: "pg-master
volumes:
- '/var/lib/postgresql/data'
exposes:
- '5432'
links:
- "pg-master
swithfr/pgsql-replication
is a copy of your Dockerfile with just the addition of these lines
RUN apt-get update
RUN apt-get install iputils-ping -y
I had to copy-paste file_env() for shared secrets, and there are some more changes for overall progress.
Also, what is the original version of docker-entrypoint.sh
you started from ? I could try to merge automatically, but it's impossible without complete tree and it's root.
pg-slave_1 | Waiting for master to ping...
pg-slave_1 | /usr/local/bin/docker-entrypoint.sh: line 39: ping: command not found
It is necessary to install ping. It is solved adding in the Dockerfile:
RUN apt-get update
RUN apt-get install iputils-ping -y
Awesome write up. Replication run fine in my side. Container data also works at '/var/lib/postgresql/data/pgdata'
Postgresql is installed in my local machine. But data dose not mount in below location
volumes:
- '/var/lib/postgresql/data'
Hey Daniel, any chance you could add a license to this project?
I am not very familiar with docker-compose
But this sample looks like running master & slave on the same machine.
If I am right, is there a way to run them on two different machines?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.