4

I have updated my pg_hba.conf on the master to this.

host    loko     replicator      10.0.2.15/32               trust

and I did reload the configuration. Then I created a user with this command

 CREATE USER replicator REPLICATION LOGIN ENCRYPTED PASSWORD 'repl'

loko which is the database on my master and replicator as the user.

and running this command on the slave

pg_basebackup -h x.x.x.x -D "C:\Program Files\PostgreSQL\9.4\data" -U 
replicator -v -P --write-recovery-conf -X stream

results in

no pg_hba.conf entry for replication connection from host x.x.x.x. user replicator, SSL off

Thanks a lot for any help. Im new to this so I don't have any idea whats wrong with this. I just followed a tutorial.

0

1 Answer 1

7

You have to grant access in replication in pg_hba.conf. Here's the line you should add:

host    replication     replicator      10.0.2.15/32               trust

You will find documentation here: https://www.postgresql.org/docs/9.6/static/auth-pg-hba-conf.html

Here's the phrase that explain everything:

The value replication specifies that the record matches if a replication connection is requested (note that replication connections do not specify any particular database).

3
  • Yes, physical replication in PG 9.x uses WAL streaming. And the WAL contains all changes for all databases in a cluster. Hence specifying a database for the replication connection would make no sense, and that position is used for the replication keyword. I guess this also means you can't have a database called "replication". May 10, 2017 at 14:04
  • Yes you can! (But I don't how you could possibly use that database in pg_hba.conf) postgres=# create database replication; CREATE DATABASE
    – Arkhena
    Nov 22, 2018 at 10:55
  • you would just quote it (ex: "replication"). From the documentation: "Quoting one of the keywords in a database, user, or address field (e.g., all or replication) makes the word lose its special meaning, and just match a database, user, or host with that name." Aug 14, 2020 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.