简体   繁体   English

通过在 docker compose 中的 postgres 命令行上传递 archive_command 来设置 WAL 归档

[英]Setting up WAL archiving by passing archive_command on the postgres command line in docker compose

I'm trying to set up WAL archiving in Postgres 13.1 using the official docker images.我正在尝试使用官方 docker 图像在 Postgres 13.1 中设置 WAL 归档。 I'm setting the archive_command setting on the command line in a docker compose file, but the command says 'not found' in the logs.我在 docker 撰写文件的命令行上设置 archive_command 设置,但命令在日志中显示“未找到”。 When I run the command directly on the container everything copies fine.当我直接在容器上运行命令时,一切都很好。

Is there a way to get better logging about why it's failing?有没有办法更好地记录失败的原因?

Docker Compose file: Docker 编写文件:

version: "3.8"
services:
  test_server_database:
    build:
      context: .
      dockerfile: Dockerfile-test-database
    volumes:
      - test-db:/var/lib/postgresql/data
      - test-db-creds:/root/.ssh
    environment:
      POSTGRES_USER: test
      POSTGRES_PASSWORD: 
      POSTGRES_DB: test_db
    ports:
      - 5433:5432
    command:
      - "postgres"
      - "-c"
      - "wal_level=logical"
      - "-c"
      - "archive_mode=on"
      - "-c"
      - 'archive_command="/usr/bin/scp -v -i /root/.ssh/ingest_id_rsa -pr -P 2222 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null /var/lib/postgresql/data/%p linuxserver.io@ingest_1:/data/wal/%f"'
      - "-c"
      - 'log_min_messages=DEBUG1'
volumes:
  test-db:
  test-db-creds:

Log messages:日志消息:

test_server_database_1  | sh: 1: /usr/bin/scp -v -i /root/.ssh/ingest_id_rsa -pr -P 2222 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null /var/lib/postgresql/data/pg_wal/00000001000000000000001F linuxserver.io@ingest_1:/data/wal/00000001000000000000001F: not found
test_server_database_1  | 2021-05-07 22:02:10.196 UTC [32] FATAL:  archive command failed with exit code 127
test_server_database_1  | 2021-05-07 22:02:10.196 UTC [32] DETAIL:  The failed archive command was: "/usr/bin/scp -v -i /root/.ssh/ingest_id_rsa -pr -P 2222 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null /var/lib/postgresql/data/pg_wal/00000001000000000000001F linuxserver.io@ingest_1:/data/wal/00000001000000000000001F"
test_server_database_1  | 2021-05-07 22:02:10.199 UTC [1] LOG:  archiver process (PID 32) exited with exit code 1

My mistake was including double quotes around the command in the archive_command setting, it should be without quotes:我的错误是在 archive_command 设置中的命令周围包含双引号,它应该不带引号:

      - "-c"
      - 'archive_command=/usr/bin/scp -v -i /root/.ssh/ingest_id_rsa -pr -P 2222 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null /var/lib/postgresql/data/%p linuxserver.io@ingest_1:/data/wal/%f'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM