У меня есть два облачных сервера, на одном сервере (мастере) поднят контейнер db (конфигурация docker-compose.yml будет ниже), на другом облачном сервере мне нужно скачать Postgresql и настроить его на работу с репликацией мастера. Как мне это сделать? Хочу использовать логическую репликацию.
**docker-compose.yml**
Находится в корне проекта.
services:
      db:
    build:
      context: ./db
    env_file:
      - .env
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
      - REPLICATOR_PASSWORD=${REPLICATOR_PASSWORD}
      - SLAVE_IP_ADDRESS=${SLAVE_IP_ADDRESS}
    volumes:
      - pgdata:/var/lib/postgresql/data
    ports:
      - '5433:5432'
    healthcheck:
      test: [ "CMD-SHELL", "pg_isready -U postgres" ]
      interval: 10s
      timeout: 5s
      retries: 5
    networks:
      - backend_network
    restart: unless-stopped

  app:
    build: .
    tty: true
    command: >
      sh -c "python manage.py migrate --noinput && 
             python manage.py collectstatic --noinput &&
             gunicorn config.wsgi:application --bind 0.0.0.0:8000"
    ports:
      - "8000:8000"
    env_file:
      - .env
    volumes:
      - .:/code
      - static-files:/code/static
      - media-files:/code/media
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_started
    networks:
      - backend_network
      - nginx_network
    restart: unless-stopped

**Dockerfile контейнера db**
FROM postgres:16.4

ENV POSTGRES_USER=postgres
ENV POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
ENV REPLICATOR_PASSWORD=${REPLICATOR_PASSWORD}

RUN apt-get update && apt-get install -y psmisc

COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh

COPY create-replication-user.sh /docker-entrypoint-initdb.d/create-replication-user.sh
RUN chmod +x /docker-entrypoint-initdb.d/create-replication-user.sh

EXPOSE 5432

ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

CMD ["postgres"]
**entrypoint.sh**
#!/bin/bash
set -e

SLAVE_IP_ADDRESS=${SLAVE_IP_ADDRESS:-195.133.24.155}

function update_pg_hba_conf() {
  while [ ! -f "$PGDATA/pg_hba.conf" ]; do
    echo "Waiting for creating pg_hba.conf..."
    sleep 1
  done

  if ! grep -q "host replication all ${SLAVE_IP_ADDRESS}/32 md5" "$PGDATA/pg_hba.conf"; then
    echo "host replication all ${SLAVE_IP_ADDRESS}/32 md5" >> "$PGDATA/pg_hba.conf"
    echo "Replicator conf has been added in pg_hba.conf."
  else
    echo "Replicator conf already exists in pg_hba.conf."
  fi
}

docker-entrypoint.sh postgres &

until pg_isready -U "$POSTGRES_USER"; do
  echo "Waiting for PostgreSQL..."
  sleep 1
done

update_pg_hba_conf

killall postgres
sleep 5

exec docker-entrypoint.sh postgres -c 'listen_addresses=*' \
                                   -c 'wal_level=logical' \
                                   -c 'max_wal_senders=10' \
                                   -c 'max_replication_slots=10'

**create-registration-user.sh**
#!/bin/bash
set -e

echo "Creating replicator user..."

psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
  CREATE ROLE replicator WITH REPLICATION LOGIN PASSWORD '$REPLICATOR_PASSWORD';
EOSQL

echo "Replicator user has been created."

**.env файл моего мастер контейнера БД**
POSTGRES_DB=postgres
POSTGRES_USER=postgres
POSTGRES_PASSWORD=PassPass
POSTGRES_HOST=db