Cannot start postdock/pgpool

32 views Asked by At

I am using postdock/postgre and postdock/pgpool to install a postgresql with high availability.

Here is my docker-compose.yml file:

version: '3'
networks:
    cluster:

services:
    pgmaster:
        image: postdock/postgres
        environment:
            PARTNER_NODES: "pgmaster,pgslave"
            CLUSTER_NODE_NETWORK_NAME: pgmaster
            NODE_PRIORITY: 100
            NODE_ID: 1
            NODE_NAME: pgmaster
            POSTGRES_PASSWORD: monkey_pass
            POSTGRES_USER: monkey_user
            POSTGRES_DB: monkey_db
            CONFIGS: "listen_addresses:'*'"
            CLUSTER_NAME: pg_cluster
            REPLICATION_DB: replication_db
            REPLICATION_USER: replication_user
            REPLICATION_PASSWORD: replication_pass
        ports:
            - 5440:5432
        networks:
            - cluster
    pgslave:
        image: postdock/postgres
        environment:
            PARTNER_NODES: "pgmaster,pgslave"
            REPLICATION_PRIMARY_HOST: pgmaster
            NODE_ID: 2
            NODE_NAME: pgslave
            CLUSTER_NODE_NETWORK_NAME: pgslave
            REPLICATION_PRIMARY_PORT: 5432
            CONFIGS: "max_replication_slots:10"
        ports:
            - 5441:5432
        networks:
            - cluster
    pgpool:
        image: postdock/pgpool
        environment:
            PCP_USER: pcp_user
            PCP_PASSWORD: pcp_pass
            WAIT_BACKEND_TIME_OUT: 60
            CHECK_USER: monkey_user
            CHECK_PASS: monkey_pass
            CHECK_PGCONNECT_TIMEOUT: 3
            DB_USERS: monkey_user:monkey_pass
            BACKEND: "0:pgmaster:5432:1:/var/lib/postgresql/data:ALLOW_TO_FAILOVER,1:pgslave::::"
            REQUIRE_MIN_BACKENDS: 1
            CONFIGS: "num_init_children:250,max_pool:4"
        ports:
            - 5432:5432
            - 9898:9898
        networks:
            - cluster

when I run docker stack deploy -c docker-compose.yml master_slave_postgres, it only starts my master and slave database.

ID                  NAME                             MODE                REPLICAS            IMAGE                      PORTS
xpsa42e9ohd2        master_slave_postgres_pgmaster   replicated          1/1                 postdock/postgres:latest   *:5440->5432/tcp
ld32o296p2np        master_slave_postgres_pgpool     replicated          0/1                 postdock/pgpool:latest     *:5432->5432/tcp, *:9898->9898/tcp
j7u8uwvbsjwm        master_slave_postgres_pgslave    replicated          1/1                 postdock/postgres:latest   *:5441->5432/tcp

When I have a look at the log of the pgpool it throws this:

[email protected]    | >>> CLEANING environment (if required)...
[email protected]    | >>> CLEANING environment (if required)...
[email protected]    | >>> STARTING SSH (if required)...
[email protected]    | >>> SSH is not enabled!
[email protected]    | >>> CLEANING environment (if required)...
[email protected]    | >>> STARTING SSH (if required)...
[email protected]    | >>> CLEANING environment (if required)...
[email protected]    | >>> SSH is not enabled!
[email protected]    | >>> TURNING PGPOOL...
[email protected]    | >>> STARTING SSH (if required)...
[email protected]    | >>> STARTING SSH (if required)...
[email protected]    | >>> SSH is not enabled!
[email protected]    | >>> Opening access from all hosts by md5 in /usr/local/etc/pool_hba.conf
[email protected]    | >>> TURNING PGPOOL...
[email protected]    | >>> SSH is not enabled!
[email protected]    | >>> Adding user pcp_user for PCP
[email protected]    | >>> Opening access from all hosts by md5 in /usr/local/etc/pool_hba.conf
[email protected]    | >>> TURNING PGPOOL...
[email protected]    | >>> TURNING PGPOOL...
[email protected]    | >>> Adding user pcp_user for PCP
[email protected]    | >>> Opening access from all hosts by md5 in /usr/local/etc/pool_hba.conf
[email protected]    | >>> Creating a ~/.pcppass file for pcp_user
[email protected]    | >>> Opening access from all hosts by md5 in /usr/local/etc/pool_hba.conf
[email protected]    | >>> Adding user pcp_user for PCP
[email protected]    | >>> Adding users for md5 auth
[email protected]    | >>> Adding user pcp_user for PCP
[email protected]    | >>> Creating a ~/.pcppass file for pcp_user
[email protected]    | >>>>>> Adding user monkey_user
[email protected]    | >>> Adding users for md5 auth
[email protected]    | >>> Creating a ~/.pcppass file for pcp_user
[email protected]    | >>> Creating a ~/.pcppass file for pcp_user
[email protected]    | >>>>>> Adding user monkey_user
[email protected]    | >>> Adding users for md5 auth
[email protected]    | >>> Adding check user 'monkey_user' for md5 auth
[email protected]    | >>> Adding users for md5 auth
[email protected]    | >>>>>> Adding user monkey_user
[email protected]    | >>>>>> Adding user monkey_user
[email protected]    | >>> Adding user 'monkey_user' as check user
[email protected]    | >>> Adding check user 'monkey_user' for md5 auth
[email protected]    | >>> Adding user 'monkey_user' as health-check user
[email protected]    | >>> Adding user 'monkey_user' as check user
[email protected]    | >>> Adding check user 'monkey_user' for md5 auth
[email protected]    | >>> Adding check user 'monkey_user' for md5 auth
[email protected]    | >>> Adding user 'monkey_user' as health-check user
[email protected]    | >>> Adding backends
[email protected]    | >>> Adding user 'monkey_user' as check user
[email protected]    | >>> Adding user 'monkey_user' as check user
[email protected]    | >>> Adding user 'monkey_user' as health-check user
[email protected]    | >>> Adding backends
[email protected]    | >>> Checking if we have enough backends to start
[email protected]    | >>> Adding user 'monkey_user' as health-check user
[email protected]    | >>> Checking if we have enough backends to start
[email protected]    | >>>>>> Can not start pgpool with REQUIRE_MIN_BACKENDS=1, BACKENDS_COUNT=0
[email protected]    | >>> Adding backends
[email protected]    | >>> Adding backends
[email protected]    | >>>>>> Can not start pgpool with REQUIRE_MIN_BACKENDS=1, BACKENDS_COUNT=0
[email protected]    | >>> Checking if we have enough backends to start
[email protected]    | >>>>>> Can not start pgpool with REQUIRE_MIN_BACKENDS=1, BACKENDS_COUNT=0
[email protected]    | >>> Checking if we have enough backends to start
[email protected]    | >>>>>> Can not start pgpool with REQUIRE_MIN_BACKENDS=1, BACKENDS_COUNT=0

How can I fix this issue? I also tried changing require_min_backends to 0, but it did not work because the pgpool only starts with 1 backend at least

1

There are 1 answers

0
Sebastian Liebscher On

PostDock seems to be unmaintained. The latest release was published in 2019.

A better option for setting up a PostgreSQL cluster with Docker would be to use the bitnami/postgres image.

Here is a quick example of how to set up a replication cluster. From the documentation:

version: '2'

services:
  postgresql-master:
    image: 'bitnami/postgresql:latest'
    ports:
      - '5432'
    volumes:
      - 'postgresql_master_data:/bitnami/postgresql'
    environment:
      - POSTGRESQL_REPLICATION_MODE=master
      - POSTGRESQL_REPLICATION_USER=repl_user
      - POSTGRESQL_REPLICATION_PASSWORD=repl_password
      - POSTGRESQL_USERNAME=my_user
      - POSTGRESQL_PASSWORD=my_password
      - POSTGRESQL_DATABASE=my_database
  postgresql-slave:
    image: 'bitnami/postgresql:latest'
    ports:
      - '5432'
    depends_on:
      - postgresql-master
    environment:
      - POSTGRESQL_REPLICATION_MODE=slave
      - POSTGRESQL_REPLICATION_USER=repl_user
      - POSTGRESQL_REPLICATION_PASSWORD=repl_password
      - POSTGRESQL_MASTER_HOST=postgresql-master
      - POSTGRESQL_PASSWORD=my_password
      - POSTGRESQL_MASTER_PORT_NUMBER=5432

volumes:
  postgresql_master_data: