Replicating Postgres database with pg_autoctl fails "pg_basebackup: error: fe_sendauth: no password supplied" on pg_autofailover
search cancel

Replicating Postgres database with pg_autoctl fails "pg_basebackup: error: fe_sendauth: no password supplied" on pg_autofailover

book

Article ID: 296404

calendar_today

Updated On:

Products

VMware Tanzu PostgreSQL

Issue/Introduction

pg_auto_failover includes the command line tool pg_autoctl that implements many commands to manage your Postgres nodes.

When trying to create a replica database fails with "pg_basebackup: error: fe_sendauth: no password supplied."

For example:

$ pg_autoctl create postgres --name pgauto02 --auth md5 --ssl-self-signed --pgdata $PGDATA --monitor postgres://autoctl_node:changeme@pgauto00/pg_auto_failover?sslmode=prefer    --dbname postgres run
09:35:59 4389 INFO  Using default --ssl-mode "require"
09:35:59 4389 INFO  Using --ssl-self-signed: pg_autoctl will create self-signed certificates, allowing for encrypted network traffic
09:35:59 4389 WARN  Self-signed certificates provide protection against eavesdropping; this setup does NOT protect against Man-In-The-Middle attacks nor Impersonation attacks.
09:35:59 4389 WARN  See https://www.postgresql.org/docs/current/libpq-ssl.html for details
09:35:59 4389 INFO  Started pg_autoctl postgres service with pid 4392
09:35:59 4392 INFO   /usr/bin/pg_autoctl do service postgres --pgdata /var/lib/pgsql/data/data -v
09:35:59 4389 INFO  Started pg_autoctl node-init service with pid 4393
09:35:59 4393 INFO  Registered node 14 (pgauto02:5432) with name "pgauto02" in formation "default", group 0, state "wait_standby"
09:35:59 4393 INFO  Writing keeper state file at "/var/lib/pgsql/.local/share/pg_autoctl/var/lib/pgsql/data/data/pg_autoctl.state"
09:35:59 4393 INFO  Writing keeper init state file at "/var/lib/pgsql/.local/share/pg_autoctl/var/lib/pgsql/data/data/pg_autoctl.init"
09:35:59 4393 INFO  Successfully registered as "wait_standby" to the monitor.
09:35:59 4393 INFO  FSM transition from "init" to "wait_standby": Start following a primary
09:35:59 4393 INFO  Transition complete: current state is now "wait_standby"
09:35:59 4393 INFO  New state for node 5 "pgauto01" (pgauto01:5432): single ➜ wait_primary
09:35:59 4393 INFO  New state for node 5 "pgauto01" (pgauto01:5432): wait_primary ➜ wait_primary
09:35:59 4393 INFO  Still waiting for the monitor to drive us to state "catchingup"
09:35:59 4393 WARN  Please make sure that the primary node is currently running `pg_autoctl run` and contacting the monitor.
09:35:59 4393 INFO  FSM transition from "wait_standby" to "catchingup": The primary is now ready to accept a standby
09:35:59 4393 INFO  Initialising PostgreSQL as a hot standby
09:35:59 4393 INFO   /usr/bin/pg_basebackup -w -d application_name=pgautofailover_standby_14 host=pgauto01 port=5432 user=pgautofailover_replicator sslmode=require --pgdata /var/lib/pgsql/data/backup/node_14 -U pgautofailover_replicator --verbose --progress --max-rate 100M --wal-method=stream --slot pgautofailover_standby_14
09:35:59 4393 INFO  pg_basebackup: error: fe_sendauth: no password supplied
09:35:59 4393 ERROR Failed to run pg_basebackup: exit code 1
09:35:59 4393 ERROR Failed initialize standby server, see above for details
09:35:59 4393 ERROR Failed to transition from state "wait_standby" to state "catchingup", see above.
09:36:00 4389 ERROR pg_autoctl service node-init exited with exit status 12


Environment

Product Version: 13.2

Resolution

If the option --auth is set to something other than "trust", then it is necessary to set the password in two places.

1. Set password for pgautofailover_replicator user in the pg_autoctl configuration.

To check the pg_autoctl configuration:
pg_autoctl config get


To set the parameter:

pg_autoctl config set replication.password "password"
Where the password needs to be set to the password of the replication user, pgautofailover_replicator, defined in the primary database.


2. Set password for pgautofailover_replicator user in $PGPASSWORD.

The password for the pgautofailover_replicator needs to be defined in the environment variable $PGPASSWORD:

export PGPASSWORD="password"