Configuring the pg_hba.conf file

Now that the postgresql.conf file has been configured successfully, it is necessary to configure the pg_hba.conf file for streaming. Note that this is only necessary if we are planning to use pg_basebackup, which is the state-of-the-art tool for creating base backups.

Basically, the options we have in the pg_hba.conf file are the same ones that we already saw in Chapter 8, Managing PostgreSQL Security. There is just one major issue to keep in mind:

# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication postgres trust
host replication postgres 127.0.0.1/32 trust
host replication postgres ::1/128 trust

We can define standard pg_hba.conf file rules. The important thing is that the second column says replication. Normal rules are not enough—it is really important to add explicit replication permissions. Also keep in mind that we don't have to do this as a superuser. We can create a specific user who is only allowed to perform login and replication.

Again, PostgreSQL 10 and later versions are already configured in the way we have outlined in this section. Local replication works when out-of-the-box—remote IPs have to be added to pg_hba.conf.

Now that the pg_hba.conf file has been configured correctly, PostgreSQL can be restarted.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset