Docker堆栈部署postgresql slave容器在几分钟内重启

时间:2018-01-16 01:20:23

标签: postgresql docker-swarm docker-stack

在swarm中使用docker stack运行此YML。 Docker堆栈文件用于创建具有2个从属的Postgresql主/从设置。

从属容器将在几分钟内重新启动并重复....

如何解决?

applicationWillFinishLaunching_

搬运工-stacl-postgresql.yml

docker stack deploy -c docker-stack-postgresql.yml post

master的env文件:.env.master

<pre>version: "3"
services:
  db1:
    image: bitnami/postgresql:latest
    ports:
      - "127.0.0.1:5432:5432"
    networks:
      - awesomenet
    deploy:
      placement:
        constraints: [node.hostname == node-docker-1]
    volumes:
      - pgdata:/bitnami/postgresql
    env_file: .env.master
  db2:
    image: bitnami/postgresql:latest
    depends_on:
      - db1
    ports:
     - "127.0.0.1:5433:5432"
    networks:
      - awesomenet
    deploy:
      placement:
        constraints: [node.hostname == node-docker-2]
    volumes:
      - pgdata:/bitnami/postgresql
    env_file: .env.slave
  db3:
    image: bitnami/postgresql:latest
    depends_on:
      - db1
    ports:
      - "127.0.0.1:5434:5432"
    networks:
      - awesomenet
    deploy:
      placement:
        constraints: [node.hostname == node-docker-3]
    volumes:
      - pgdata:/bitnami/postgresql
    env_file: .env.slave
volumes:
  pgdata:

networks:
  awesomenet:
    driver: overlay
    driver_opts:
      encrypted: "true"
    </pre>

env文件:.env.slave

<pre>
POSTGRESQL_REPLICATION_MODE=master
POSTGRESQL_REPLICATION_USER=replication_user
POSTGRESQL_REPLICATION_PASSWORD= replication_password
POSTGRESQL_USERNAME=postgres
POSTGRESQL_PASSWORD=password
POSTGRESQL_DATABASE=monkey_db
</pre>

PostgreSQL日志文件:

<pre>
POSTGRESQL_REPLICATION_MODE=slave
POSTGRESQL_REPLICATION_USER=replication_user
POSTGRESQL_REPLICATION_PASSWORD= replication_password
POSTGRESQL_MASTER_HOST=db1
POSTGRESQL_MASTER_PORT=5432
</pre>

PostgreSQL error.log

<pre>
nami    INFO  Initializing postgresql
postgre INFO   This installation requires no credentials.
nami    INFO  postgresql successfully initialized
</pre>

1 个答案:

答案 0 :(得分:0)

这对我有用:

  $this->request->getParam(param1)
  $this->request->getParam(param2)

因此,您可能尝试为所有三种服务使用相同的卷。因此1.为每个创建一个不同的命名卷或2.为db2 / 3不使用卷,因为它们只是主要的副本。

此外,不需要使用depends_on,它在Swarm堆栈中不起作用。

相关问题