0

I'm working on setting up a read replica for PostgreSQL across two datacenters over the internet. As part of the setup, I've modified the pg_hba.conf file on the primary server (server-a) to include the following:

host    replication     replication_user     <server-b-ip>/32      trust

(Note: I'm aware that using trust is not recommended for production)

To verify the connection from the replica server (server-b), I ran a query against server-a using:

psql -h <server-a-ip> -U replication_user -d postgres -c "SELECT 1;"

This works, indicating that the basic connectivity and authentication are working as expected.

However, when I try to initiate a full backup on server-b using pg_basebackup to prepare the replica, I encounter an error:

pg_basebackup -h <server-a-ip> -D /var/lib/postgresql/12/main -U replication_user -v -P --wal-method=stream

The command returns the following error message:

pg_basebackup: error: connection to server at "<server-a-ip>", port 5432 failed: FATAL:  no pg_hba.conf entry for replication connection from host "<server-b-ip>", user "replication_user", no encryption

Prior to these steps, I have created a replication role for the user replication_user with the necessary permissions:

CREATE ROLE replication_user REPLICATION LOGIN PASSWORD 'mypassword';

It seems I might be missing a step or need to adjust my configuration. Does anyone have insights on what else needs to be done to successfully establish the read replica?

Chris
  • 101

0 Answers0