GithubHelp home page GithubHelp logo

danieldent / docker-postgres-replication Goto Github PK

View Code? Open in Web Editor NEW
211.0 211.0 91.0 16 KB

Postgres 9.6 & 9.5 Dockerized w/ Replication. Master/Slave setup in 30 seconds.

Home Page: https://hub.docker.com/r/danieldent/postgres-replication/

Shell 100.00%

docker-postgres-replication's People

Contributors

danieldent avatar shopeonarope avatar wrouesnel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-postgres-replication's Issues

proper documentation for beginners

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

Problems migrating to kubernetes with POSTGRES_USERNAME and POSTGRES_PASSWORD

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.

Cannot connect to database

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?

allows replication without share persistent volumes

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?

Is this project dead?

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?

Can't connect to DB

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:

  • port tested: 5432
  • host tested: localhost, 127.0.0.0.1, pgsql

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

Regulary merge origin docker-library/postgres

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.

ping: command not found

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

Data does not mount in local volume path

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'

Deploy master and slave on different machines

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?

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.