我要评分
获取效率
正确性
完整性
易理解

(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.

  1. Optional: Configure the network access range for database replication.

    If the range has been configured in the environment, skip this step.

    1. 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
    2. Press i to enter the insert mode and add the following content to the file:
      host    replication     all             0.0.0.0/0               md5

    3. Press Esc, type :wq!, and press Enter to save the file and exit.
    4. 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
  2. Create a backup user.
    1. On the primary database server, log in to the PostgreSQL database as the postgres user.
      /usr/local/pgsql-13.2/bin/psql -U postgres

    2. 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'; 

    3. Exit the database.
      \q