无法启动 postdock/pgpool

问题描述 投票:0回答:1

我正在使用 postdock/postgre 和 postdock/pgpool 安装具有高可用性的 postgresql。

这是我的 docker-compose.yml 文件:

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

当我运行

docker stack deploy -c docker-compose.yml master_slave_postgres
时,它只启动我的主数据库和从数据库。

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

当我查看 pgpool 的日志时,它会抛出以下错误:

[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

如何解决这个问题?我也尝试将 require_min_backends 更改为 0,但它不起作用,因为 pgpool 至少只从 1 个后端开始

postgresql docker docker-compose docker-swarm
1个回答
0
投票

PostDock 似乎没有维护。 最新版本于 2019 年发布。

使用 Docker 设置 PostgreSQL 集群的更好选择是使用

bitnami/postgres
映像。

以下是如何设置复制集群的快速示例:

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:

文档链接

© www.soinside.com 2019 - 2024. All rights reserved.