【问题标题】:Logical replication from Posgres on Windows to Postgres in docker container on Linux从 Windows 上的 Postgres 到 Linux 上 docker 容器中的 Postgres 的逻辑复制
【发布时间】:2021-03-12 05:43:59
【问题描述】:

我正在使用 bitnami/postgresql:latest 映像,并且能够从 Win32 程序(使用 Unidac 驱动程序的 Delphi)连接到在 Docker 容器中的 Ubuntu 服务器上运行的 PostgreSQL 数据库。

用户将使用 Win32 程序离线捕获实地调查数据,然后他们在线上希望将数据复制到 Ubuntu 服务器上的 PostgreSQL 数据库。

在我看来,我应该使用逻辑复制,因为用户可能只使用 Ubuntu 服务器上整个主数据库的一个子集。

我必须能够映射 postgresql.conf 和 pg_hba.conf 文件。 我的 docker-compose.yml 文件中用于在 docker 容器中运行 PostgreSQL 的部分:

  postgres:
    restart: unless-stopped
    container_name: postgres
    image: bitnami/postgresql:latest
    environment:
      - TZ="Africa/Johannesburg"
      - POSTGRES_DATABASE=sdb_risk
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=xxxxxxxxxxxxxxxx
    ports:
      - 5432:5432
      - 5433:5433
    volumes:
      - ./postgres_data:/bitnami/postgresql
#      - .pg_hba.conf:/bitnami/postgresql/conf/pg_hba.conf

#      - .postgresql.conf:/bitnami/postgresql/conf/postgresql.conf 
networks:
  - dreamfactory-tier
  - app-tier

我的问题是:我是否在正确的轨道上进行逻辑复制,如果是,我如何映射 pg_hba.conf 和 postgresql.conf 文件?

问候,

诺尔斯·斯密特

【问题讨论】:

    标签: postgresql docker replication


    【解决方案1】:

    逻辑复制确实适用于在 docker 容器中运行的 Postgres。我做了什么来弄清楚:

    我通过在主机上运行 Postgres 解决了这个问题:Ubuntu 服务器(不在 docker 容器中)。 复制您的 postgresql.conf 和 pg_hba.conf 文件 将你的 postgresql.conf 和 pg_hba.conf 文件复制到你的 docker 根文件夹(你有你的 docker-compose.yml)文件

    我的 postgresql 文件的变化:

    #------------------------------------------------------------------------------
    # WRITE-AHEAD LOG
    #------------------------------------------------------------------------------
    
    # - Settings -
    
    ################# wal_level originally commented out ... Nols Smit #########
    wal_level = logical         # minimal, replica, or logical
    ############################################################################
    

    我的 pg_hba.conf 文件中的更改:

    host all all all md5
    ################## New entry below   ... Nols Smit ##########################
    host    all            all              0.0.0.0/0               md5   
    host    starsdb        replicator       i7Laptop                md5
    #############################################################################
    

    starsdb 是订阅者的 Postgres 数据库,i7Laptop 是发布者的主机名

    请记住,订阅者数据库最初必须为空,并且还使用 uuids 作为表的主键。

    问候,

    诺尔斯·斯密特

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-16
      • 2019-12-29
      • 1970-01-01
      • 2021-03-14
      • 2016-07-20
      • 2017-01-09
      • 2018-11-28
      • 2021-06-25
      相关资源
      最近更新 更多