7. Verificare la replica di streaming in tutti i nodi
Passo 1
In node0 riavviare il servizio PostgreSQL.
Passo 2
In node1 sincronizzare node1 con node0 utilizzando lo script start_replication, quindi riavviare PostgreSQL in node1. L'indirizzo IP 10.91.9.200 è per node0.
sudo su postgres
/db/bin/start_replication.sh 10.91.9.200
exit
sudo systemctl start postgresql-10.x
Passo 3
In node2 sincronizzare node2 con node1 utilizzando lo script start_replication, quindi riavviare PostgreSQL sul nodo 2. L'indirizzo IP 10.91.9.24 è per node1.
sudo su postgres
/db/bin/start_replication.sh 10.91.9.24
exit
sudo systemctl start postgresql-10.x
Passo 4
Controllare lo stato della replica.
Esaminare i risultati dello stato dei processi PostgreSQL per verificare che la replica sia attiva.
In node0:
[ec2-user@ip-10-91-9-200 ~]$ ps -ef|grep postgres
postgres 837 1 0 14:39 ? 00:00:00 /usr/pgsql-10.x/bin/postgres -D /db/postgres
postgres 863 837 0 14:39 ? 00:00:00 postgres: logger process
postgres 878 837 0 14:39 ? 00:00:00 postgres: checkpointer process
postgres 879 837 0 14:39 ? 00:00:00 postgres: writer process
postgres 880 837 0 14:39 ? 00:00:00 postgres: wal writer process
postgres 881 837 0 14:39 ? 00:00:00 postgres: autovacuum launcher process
postgres 882 837 0 14:39 ? 00:00:00 postgres: archiver process
postgres 883 837 0 14:39 ? 00:00:00 postgres: stats collector process
postgres 910 837 0 14:39 ? 00:00:00 postgres: wal sender process replicator 10.91.9.24(48264) streaming 1A/BC0039A0
in node1:
[ec2-user@ip-10-91-9-24 ~]$ ps -ef|grep postgres
postgres 834 1 0 14:39 ? 00:00:00 /usr/pgsql-10.x/bin/postgres -D /db/postgres
postgres 861 834 0 14:39 ? 00:00:00 postgres: logger process
postgres 863 834 0 14:39 ? 00:00:00 postgres: startup process recovering 000000170000001A000000BC
postgres 897 834 0 14:39 ? 00:00:00 postgres: checkpointer process
postgres 898 834 0 14:39 ? 00:00:00 postgres: writer process
postgres 899 834 0 14:39 ? 00:00:00 postgres: stats collector process
postgres 1236 834 0 14:39 ? 00:00:00 postgres: wal sender process replicator 10.91.9.41(48620) streaming 1A/BC0039A0
postgres 1279 834 0 14:39 ? 00:00:05 postgres: wal receiver
in node2:
[ec2-user@ip-10-91-9-41 ~]$ ps -ef|grep postgres
postgres 837 1 0 14:39 ? 00:00:00 /usr/pgsql-10.x/bin/postgres -D /db/postgres
postgres 859 837 0 14:39 ? 00:00:00 postgres: logger process
postgres 860 837 0 14:39 ? 00:00:00 postgres: startup process recovering 000000170000001A000000BC
postgres 887 837 0 14:39 ? 00:00:00 postgres: checkpointer process
postgres 888 837 0 14:39 ? 00:00:00 postgres: writer process
postgres 889 837 0 14:39 ? 00:00:00 postgres: stats collector process
postgres 890 837 0 14:39 ? 00:00:07 postgres: wal receiver
Nelle schermate dello stato dei processi riportate sopra osservare quanto segue per verificare che la replica sia in esecuzione:
node0 ha un processo mittente e il target di replica è: 10.91.9.24 (node1).
node1 ha un processo mittente e un processo destinatario.
node2 ha solo un processo destinatario.
Tutti e tre i nodi sono sincronizzati nello stream 1A/BC0039A0