hapostgres / pg_auto_failover

Postgres extension and service for automated failover and high-availability
Other
1.07k stars 113 forks source link

ERROR Connection to database failed: connection to server at "servername" (<ip address>), port 5000 failed: FATAL: no pg_hba.conf entry for host "<ip address>", user "postgres", database "postgres", SSL encryption #912

Closed dannylu006 closed 1 year ago

dannylu006 commented 2 years ago
  1. Installed 14.4 PG software via https://www.postgresql.org/ftp/source/v14.4/
  2. Installed pg_auto_failover via https://github.com/citusdata/pg_auto_failover/tree/v1.6.4
  3. Ran below command to create the monitor server, but ran into error: pg_autoctl create monitor --ssl-self-signed --hostname localhost --auth trust --run
  4. Here is a snippet of the error: 10:29:45 4552 WARN Self-signed certificates provide protection against eavesdropping; this setup does NOT protect against Man-In-The-Middle attacks nor Impersonation attacks. 10:29:45 4552 WARN See https://www.postgresql.org/docs/current/libpq-ssl.html for details 10:29:45 4552 INFO Initialising a PostgreSQL cluster at "/servername/pg/monitor/data" 10:29:45 4552 INFO /hostname/pg/PostgreSQL-14.2/bin/pg_ctl initdb -s -D /servername/pg/monitor/data --option '--auth=trust' 10:29:46 4552 INFO /usr/bin/openssl req -new -x509 -days 365 -nodes -text -out /servername/pg/monitor/data/server.crt -keyout /servername/pg/monitor/data/server.key -subj "/CN=localhost" 10:29:46 4552 INFO Started pg_autoctl postgres service with pid 4569 10:29:46 4569 INFO /servername/pg/PostgreSQL-14.2/bin/pg_autoctl do service postgres --pgdata /hostname/pg/monitor/data -v 10:29:46 4552 INFO Started pg_autoctl listener service with pid 4570 10:29:46 4575 INFO /hostname/pg/PostgreSQL-14.2/bin/postgres -D /servername/pg/monitor/data -p 5000 -h * 10:29:46 4569 INFO Postgres is now serving PGDATA "/servername/pg/monitor/data" on port 5000 with pid 4575 10:29:46 4570 WARN Failed to connect to "postgres://postgres@servername:5000/postgres?", retrying until the server is ready 10:29:48 4570 ERROR Connection to database failed: connection to server at "servername" (), port 5000 failed: FATAL: no pg_hba.conf entry for host "", user "postgres", database "postgres", SSL encryption 10:29:48 4570 ERROR connection to server at "servername" (), port 5000 failed: FATAL: no pg_hba.conf entry for host "", user "postgres", database "postgres", no encryption 10:29:48 4570 ERROR Failed to connect to "postgres://postgres@servername:5000/postgres?" after 26 attempts in 2047 ms, pg_autoctl stops retrying now 10:29:48 4570 ERROR Failed to create user "autoctl" on local postgres server 10:29:48 4552 ERROR pg_autoctl service listener exited with exit status 12

QUESTION: It looks like the postgresql instance was created since we see all the required files are present in the PGDATA directory. However, it appears nothing related to pg_auto_failover objects are created since it has permission connecting to the instance as referenced by the error above.

Any feedback is greatly appreciated.

DimCitus commented 1 year ago

Hi @dannylu006 ; you edited the logs to the extend that it's impossible to reason about them. Please share the actual command you've been using and the actual logs if you want help. Specifically, I can't understand what would have been hostname and servername in your edited logs.

10:29:46 4569 INFO /servername/pg/PostgreSQL-14.2/bin/pg_autoctl do service postgres --pgdata /hostname/pg/monitor/data -v
10:29:46 4552 INFO Started pg_autoctl listener service with pid 4570
10:29:46 4575 INFO /hostname/pg/PostgreSQL-14.2/bin/postgres -D /servername/pg/monitor/data -p 5000 -h *

Here we have two different PGDATA entries in two different lines. That's not how pg_autoctl works.

Closing for triage; please consider opening again if that's still a current issue for you, but this time with actual commands and output.