(Optional) Adding a Backup User
Create a user named backup as the backup user of the PostgreSQL database. If a replication user and the primary/secondary environment have been set in the actual environment, skip this section.
- Optional: Configure the network access range for database replication.
If the range has been configured in the environment, skip this step.
- Open the pg_hba.conf file in the data directory. In this example, the data directory is /data/pg-13.2/data/.
vi /data/pg-13.2/data/pg_hba.conf
- Press i to enter the insert mode and add the following content to the file:
host replication all 0.0.0.0/0 md5

- Press Esc, type :wq!, and press Enter to save the file and exit.
- Run the following command to restart PostgreSQL for the configurations to take effect:
/usr/local/pgsql-13.2/bin/pg_ctl -D /data/pg-13.2/data -l logfile restart
- Open the pg_hba.conf file in the data directory. In this example, the data directory is /data/pg-13.2/data/.
- Create a backup user.
- On the primary database server, log in to the PostgreSQL database as the postgres user.
/usr/local/pgsql-13.2/bin/psql -U postgres

- Create a backup user named backup. In this example, the user name is backup and the password is 123456. For security purposes, please use a more complex and secure password in the actual scenarios.
create role backup REPLICATION LOGIN PASSWORD '123456';

- Exit the database.
\q
- On the primary database server, log in to the PostgreSQL database as the postgres user.
Parent topic: Deployment Environment