Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the server running on host "pgmaster"? #272

Open
airton-soares opened this issue Jan 5, 2022 · 0 comments
Open

Is the server running on host "pgmaster"? #272

airton-soares opened this issue Jan 5, 2022 · 0 comments

Comments

@airton-soares
Copy link

Hi.

I was trying to run a docker-compose with postdock-pgsql, postdock-barman and postdock-pgpool using as reference the file in https://github.com/syndbg/postgres-docker-cluster/blob/master/docker-compose.yml.

The exact file I was using is this one:

version: '4'
networks:
    cluster:
        driver: bridge
services:
  pgmaster:
    image: paunin/postdock-pgsql
    environment:
      PARTNER_NODES: "pgmaster,pgslave1,pgslave3"
      NODE_ID: 1 # Integer number of node
      NODE_NAME: node1 # Node name
      CLUSTER_NODE_NETWORK_NAME: pgmaster # (default: hostname of the node)
      NODE_PRIORITY: 100  # (default: 100)
      SSH_ENABLE: 1
      #database we want to use for application
      POSTGRES_PASSWORD: postgres
      POSTGRES_USER: postgres
      POSTGRES_DB: db_test
      CLEAN_OVER_REWIND: 0
      CONFIGS: "listen_addresses:'*',max_replication_slots:5"
                            # in format variable1:value1[,variable2:value2[,...]]
                            # used for pgpool.conf file
      #defaults:
      CLUSTER_NAME: pg_cluster # default is pg_cluster
      REPLICATION_DB: db_test_replica # default is replication_db
      REPLICATION_USER: postgres # default is replication_user
      REPLICATION_PASSWORD: postgres # default is replication_pass
        
    ports:
      - 5432:5432
    volumes:
      - pgmaster:/var/lib/postgresql/data
    networks:
      cluster:
        aliases:
          - pgmaster
  
  pgslave1:
    image: paunin/postdock-pgsql
    environment:
      PARTNER_NODES: "pgmaster,pgslave1,pgslave3"
      REPLICATION_PRIMARY_HOST: pgmaster
      NODE_ID: 2
      NODE_NAME: node2
      CLUSTER_NODE_NETWORK_NAME: pgslave1 # (default: hostname of the node)
      CLEAN_OVER_REWIND: 1
      CONFIGS: "max_replication_slots:10" #some overrides
    ports:
      - 5441:5432
    volumes:
      - pgslave1:/var/lib/postgresql/data
    networks:
      cluster:
        aliases:
          - pgslave1

  # Add more slaves if required
  pgslave2:
    image: paunin/postdock-pgsql
    environment:
      REPLICATION_PRIMARY_HOST: pgslave1 # I want to have cascade Streeming replication
      NODE_ID: 3
      NODE_NAME: node3
      CLUSTER_NODE_NETWORK_NAME: pgslave2 # (default: hostname of the node)
      #USE_REPLICATION_SLOTS: 0
    ports:
      - 5442:5432
    volumes:
      - pgslave2:/var/lib/postgresql/data
    networks:
      cluster:
        aliases:
          - pgslave2
  
  pgslave3:
    image: paunin/postdock-pgsql
    environment:
      PARTNER_NODES: "pgmaster,pgslave1,pgslave3"
      REPLICATION_PRIMARY_HOST: pgmaster
      NODE_ID: 4
      NODE_NAME: node4
      CLUSTER_NODE_NETWORK_NAME: pgslave3 # (default: hostname of the node)
      NODE_PRIORITY: 200  # (default: 100)
      CLEAN_OVER_REWIND: 1
    ports:
      - 5443:5432
    volumes:
      - pgslave3:/var/lib/postgresql/data
    networks:
      cluster:
        aliases:
          - pgslave3

  pgslave4:
    image: paunin/postdock-pgsql
    environment:
      REPLICATION_PRIMARY_HOST: pgslave3
      NODE_ID: 5
      NODE_NAME: node5
      CLUSTER_NODE_NETWORK_NAME: pgslave4 # (default: hostname of the node)
      #USE_REPLICATION_SLOTS: 0
    ports:
      - 5444:5432
    volumes:
      - pgslave4:/var/lib/postgresql/data
    networks:
      cluster:
        aliases:
          - pgslave4
  
  backup:
    image: paunin/postdock-barman
    environment:
      REPLICATION_USER: postgres # default is replication_user
      REPLICATION_PASSWORD: postgres # default is replication_pass
      REPLICATION_HOST: pgmaster
      POSTGRES_PASSWORD: postgres
      POSTGRES_USER: postgres
      POSTGRES_DB: db_test
      SSH_ENABLE: 1
      BACKUP_SCHEDULE: "*/30 */5 * * *"
    volumes:
      - backup:/var/backups
    networks:
      cluster:
        aliases:
          - backup
  
  pgpool:
    image: paunin/postdock-pgpool
    environment:
      PCP_USER: pcp_user
      PCP_PASSWORD: pcp_pass
      WAIT_BACKEND_TIMEOUT: 60

      CHECK_USER: postgres
      CHECK_PASSWORD: postgres
      CHECK_PGCONNECT_TIMEOUT: 3 #timout for checking if primary node is healthy
      SSH_ENABLE: 1
      DB_USERS: postgres:postgres # in format user:password[,user:password[...]]
      BACKENDS: "0:pgmaster:5432:1:/var/lib/postgresql/data:ALLOW_TO_FAILOVER,1:pgslave1::::,3:pgslave3::::,2:pgslave2::::" #,4:pgslaveDOES_NOT_EXIST::::
                # in format num:host:port:weight:data_directory:flag[,...]
                # defaults:
                #   port: 5432
                #   weight: 1
                #   data_directory: /var/lib/postgresql/data
                #   flag: ALLOW_TO_FAILOVER
      REQUIRE_MIN_BACKENDS: 3 # minimal number of backends to start pgpool (some might be unreachable)
      CONFIGS: "num_init_children:250,max_pool:4"
                # in format variable1:value1[,variable2:value2[,...]]
                # used for pgpool.conf file
    ports:
      - 5430:5432
      - 9898:9898 # PCP
    networks:
      cluster:
        aliases:
          - pgpool

volumes:
  pgmaster:
  pgslave1:
  pgslave2:
  pgslave3:
  pgslave4:
  backup:

But for some reason, in the master and all other nodes containers logs I've got this:

>>>>>> Db pix_gateway_test_replica is still not accessable on pgmaster:5432 (will try 9 times more)
>>>>>> Db pix_gateway_test_replica is still not accessable on pgmaster:5432 (will try 8 times more)
>>>>>> Db pix_gateway_test_replica is still not accessable on pgmaster:5432 (will try 7 times more)
>>>>>> Db pix_gateway_test_replica is still not accessable on pgmaster:5432 (will try 6 times more)
>>>>>> Db pix_gateway_test_replica is still not accessable on pgmaster:5432 (will try 5 times more)
>>>>>> Db pix_gateway_test_replica is still not accessable on pgmaster:5432 (will try 4 times more)
>>>>>> Db pix_gateway_test_replica is still not accessable on pgmaster:5432 (will try 3 times more)
>>>>>> Db pix_gateway_test_replica is still not accessable on pgmaster:5432 (will try 2 times more)
>>>>>> Db pix_gateway_test_replica is still not accessable on pgmaster:5432 (will try 1 times more)
>>> Db pix_gateway_test_replica is not accessable, even after 9 tries!
>>> Foreground processes returned code: '1'
psql: could not connect to server: Connection refused
Is the server running on host "pgmaster" (192.168.32.5) and accepting
TCP/IP connections on port 5432?

In the backup container logs I've got:

ERROR: Cannot connect to server 'pg_cluster'
2022-01-05 16:40:02,952 [45] barman.server ERROR: Cannot connect to server 'pg_cluster': could not translate host name "pgmaster" to address: Name or service not known

My machine is a Mac Pro with macOS Monterey 12.1. I've already tried to turn my firewall off but it was not effective.

Any idea of what could be causing it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant