Skip to content

On the Replication Server

Setup the Docker Container

  1. Download hview and its components from Docker Hub.

  2. Edit the Docker Compose file and add the following mount volume to where the database will replicate to temporarily:

- ./db.new:/var/lib/postgresql/data2
  1. Start the HView Database Component:
docker start hview

On the Primary Server

Log into the Current Production Server and Confirm the Following Settings

  1. postgresql.conf file:

  2. Ensure the following settings are configured:

    wal_level = logical
    wal_log_hints = on
    
  3. Allow the Replication Server to Connect to the Primary:

  4. Update pg_hba.conf with the following line:

    host replication hviewrep 10.20.4.152/32 md5
    
  5. Restart the HView Database Container:

On the Replication Server

Execute the Backup Command to the Temp Mounted Store

  1. Run the following command to perform the backup:
screen docker exec -it hview.db pg_basebackup -h 10.20.5.190 -p 6976 -U hviewrep -X stream -C -S replica_1 -v -R -W -D /var/lib/postgresql/data2/
  1. Stop the HView Database Container.

  2. Move the old /db directory to db.original.

  3. Move the db.new directory to the db folder.

  4. Start up the Replication Server.

  5. Check the database container logs.

  6. Confirm the replication status:

  7. On the Master, run:

    select * from pg_stat_replication;
    
  8. On the Replica (Streaming Replication in Our Case), run:

    select * from pg_stat_wal_receiver;