Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WARN: unable to check pg1: [DbConnectError] unable to connect to 'dbname='postgres' port=5432 user='sa'': connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: fe_sendauth: no password supplied #2068

Closed
damienApp opened this issue May 16, 2023 · 11 comments
Assignees
Labels

Comments

@damienApp
Copy link

damienApp commented May 16, 2023

Please provide the following information when submitting an issue (feature requests or general comments can skip this):

  1. pgBackRest version:
    ==> pgBackRest 2.45

  2. PostgreSQL version:
    ==> postgres (PostgreSQL) 15.2

  3. Operating system/version - if you have more than one server (for example, a database server, a repository host server, one or more standbys), please specify each:
    ==> Red Hat Enterprise Linux release 8.7 (Ootpa)

  4. Did you install pgBackRest from source or from a package?
    From ==> https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

  5. Please attach the following as applicable:

    • pgbackrest.conf file(s)
    • postgresql.conf settings applicable to pgBackRest (archive_command, archive_mode, listen_addresses, max_wal_senders, wal_level, port)
    • errors in the postgresql log file before or during the time you experienced the issue
    • log file in /var/log/pgbackrest for the commands run (e.g. /var/log/pgbackrest/mystanza_backup.log)
      pgbacrest.conf.txt
      pgbackrest --config=/etc/pgbackrest.conf --log-level-console=info --stanza=prod_backup stanza-create
      2023-05-16 09:07:02.489 P00 INFO: stanza-create command begin 2.45: --config=/etc/pgbackrest.conf --exec-id=63528-b9174227 --log-level-console=info --log-level-file=debug --pg1-path=/DATABASE/PGDATA/PGOTVMI625S1/DATA/ --pg1-user=sa --repo1-path=/DATABASE/PGSAVE/PGOTVMI625S1/pgbackrest --stanza=prod_backup
      WARN: unable to check pg1: [DbConnectError] unable to connect to 'dbname='postgres' port=5432 user='sa'': connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: fe_sendauth: no password supplied
      ERROR: [056]: unable to find primary cluster - cannot proceed
      HINT: are all available clusters in recovery?
      2023-05-16 09:07:02.493 P00 INFO: stanza-create command end: aborted with exception [056]
  6. Describe the issue:
    When I try to create my Stanza I am told that no password is presented, I decided to put my user in trust in the pg_hba.conf file and the same thing does not work either is that someone Any idea how to fix the problem ?

resume pg_hba.conf
"[.....]# Streaming
host replication sa 10.34.251.75/32 trust"
postgres.conf.txt

@pgstef
Copy link
Member

pgstef commented May 16, 2023

Hi,

host replication sa 10.34.251.75/32 trust

That's a replication connection and using the host ip.

You need to allow the unix socket connection and access to the normal db, not restricting to replication. Also, if you want to avoid trust in your pg_hba, you might simply use a pgpass file.

Kind Regards

@pgstef pgstef self-assigned this May 16, 2023
@damienApp
Copy link
Author

damienApp commented May 16, 2023

Hello, Thank you for your quick answer, yes I decided to use a PGPASSFILL which is declared as an environment variable here : -> env
FILE_PGPASS=/etc/postgres/pgpass-PGOTVMI625S1
and which contains this: otvmi625s:5432:*:MyPassword
I know it can read it because the first time I ran it it asked me to change the permissions but still it can't connect.
The modification in trust for pg_hba was just to test if by putting nothing at all it would succeed or not.
Regards,

@pgstef
Copy link
Member

pgstef commented May 16, 2023

The pg_hba entry should look like local all all scram-sha-256 since you'll use the unix socket.
Then in the .pgpass file, the line should look like localhost:5432:postgres:user:password.

The underlying issue here is that you try to use the host based connection but pgBackRest is using the unix socket.

To be honest, I never tried to change the default pgpass location when using pgBackRest but imho, I think the environment variable should be PGPASSFILE not FILE_PGPASS.

@damienApp
Copy link
Author

Ok so I do the modification for environnement variable :
PGPASSFILE=/etc/postgres/pgpass-PGOTVMI625S1

And for pg_hba.conf :

TYPE DATABASE USER CIDR-ADDRESS METHOD

local all all scram-sha-256
host all all 127.0.0.1/32 password
host all all 10.34.251.75/32 password # otvmi625s

Streaming

host replication "sa" 10.34.251.75/32 password # pg_basebackup

But :
-> sudo systemctl restart PGOTVMI625S1.service
SAND postgres@otvmi625s:/DATABASE/PGDATA/PGOTVMI625S1/DATA [SID= PGOTVMI625S1 ]
-> pgbackrest --config=/etc/pgbackrest.conf --log-level-console=info --stanza=prod_backup stanza-create
2023-05-16 10:34:31.966 P00 INFO: stanza-create command begin 2.45: --config=/etc/pgbackrest.conf --exec-id=171743-e8ede4d2 --log-level-console=info --log-level-file=debug --pg1-path=/DATABASE/PGDATA/PGOTVMI625S1/DATA/ --pg1-user=sa --repo1-path=/DATABASE/PGSAVE/PGOTVMI625S1/pgbackrest --stanza=prod_backup
WARN: unable to check pg1: [DbConnectError] unable to connect to 'dbname='postgres' port=5432 user='sa'': connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: fe_sendauth: no password supplied
ERROR: [056]: unable to find primary cluster - cannot proceed
HINT: are all available clusters in recovery?
2023-05-16 10:34:31.969 P00 INFO: stanza-create command end: aborted with exception [056]
SAND postgres@otvmi625s:/DATABASE/PGDATA/PGOTVMI625S1/DATA [SID= PGOTVMI625S1 ]
->

@pgstef
Copy link
Member

pgstef commented May 16, 2023

And what's in /etc/postgres/pgpass-PGOTVMI625S1?
Could you first try to make it work with the default pgpass location before moving it there?

@damienApp
Copy link
Author

damienApp commented May 16, 2023

In we have /etc/postgres/pgpass-PGOTVMI625S1 :

[root@otvmi625s w100396]# cat /etc/postgres/pgpass-PGOTVMI625S1
localhost:5432:postgres:sa:xxx

When I place it in the default location in pgpass.conf with the same ==> localhost:5432:postgres:sa:xxx
it's the same error :

pgbackrest --config=/etc/pgbackrest.conf --log-level-console=info --stanza=prod_backup stanza-create
2023-05-16 12:34:45.967 P00 INFO: stanza-create command begin 2.45: --config=/etc/pgbackrest.conf --exec-id=171743-e8ede4d2 --log-level-console=info --log-level-file=debug --pg1-path=/DATABASE/PGDATA/PGOTVMI625S1/DATA/ --pg1-user=sa --repo1-path=/DATABASE/PGSAVE/PGOTVMI625S1/pgbackrest --stanza=prod_backup
WARN: unable to check pg1: [DbConnectError] unable to connect to 'dbname='postgres' port=5432 user='sa'': connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: fe_sendauth: no password supplied
ERROR: [056]: unable to find primary cluster - cannot proceed
HINT: are all available clusters in recovery?

@pgstef
Copy link
Member

pgstef commented May 16, 2023

When I place it in the default location in pgpass.conf

What do you mean? Where did you placed it? It should be ~/.pgpass

@damienApp
Copy link
Author

Oh I place it on /etc/postgres, so I replace it on ~/.pgpass and I exportat the good path on the pgpassfile env as you can see with the same information as before :

-> env | grep PGPASSFILE
PGPASSFILE=/root/.pgpass/pgpass.conf

[root@otvmi625s .pgpass]# cat pgpass.conf
localhost:5432:postgres:sa:xxxx

And : WARN: unable to check pg1: [DbConnectError] unable to connect to 'dbname='postgres' port=5432 user='sa'': connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: fe_sendauth: no password supplied



@pgstef
Copy link
Member

pgstef commented May 16, 2023

As stated in PG docs, the file should be named .pgpass and placed in the home directory of the system user used to execute the pgbackrest command.

psql -U sa -d postgres should work (with the system user you're launching the pgbackrest commands) before trying it with pgBackRest.

@damienApp
Copy link
Author

I thank you for your patience. The pgbackrest command is functional and I was able to create my stanza. Thx a lot <3

@pgstef
Copy link
Member

pgstef commented May 16, 2023

Just to follow up, the PGPASSFILE environment variable should work too, if configured properly.

I just tested the following situation:

$ cat 15/data/pg_hba.conf
local all stefan scram-sha-256

$ psql -U stefan -d postgres
Password for user stefan: 

$ pgbackrest --stanza=demo stanza-create
WARN: unable to check pg1: [DbConnectError] unable to connect to 'dbname='postgres' port=5432 user='stefan'': connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: fe_sendauth: no password supplied
ERROR: [056]: unable to find primary cluster - cannot proceed
       HINT: are all available clusters in recovery?

Then I added the ~postgres/.pgpass default file with localhost:5432:postgres:stefan:test + chmod 0600 /var/lib/pgsql/.pgpass and moved it to /etc/.pgpass.

$ PGPASSFILE=/etc/.pgpass psql -U stefan -d postgres -c "select now();"
              now              
-------------------------------
 2023-05-16 11:40:49.323321+00
(1 row)

$ PGPASSFILE=/etc/.pgpass pgbackrest --stanza=demo stanza-create
...
P00   INFO: stanza-create command end: completed successfully

@github-actions github-actions bot locked and limited conversation to collaborators Aug 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants