7. 验证所有节点的流式复制
步骤 1
在 node0 上,重新启动 PostgreSQL 服务。
步骤 2
在 node1 上,使用 start_replication 脚本将 node1 与 node0 同步,然后重新启动 node1 上的 PostgreSQL。IP 地址 10.91.9.200 适用于 node0。
sudo su postgres
/db/bin/start_replication.sh 10.91.9.200
exit
sudo systemctl start postgresql-10.x
步骤 3
在 node2 上,使用 start_replication 脚本将 node2 与 node1 同步,然后重新启动 node2 上的 PostgreSQL。IP 地址 10.91.9.24 适用于 node1。
sudo su postgres
/db/bin/start_replication.sh 10.91.9.24
exit
sudo systemctl start postgresql-10.x
步骤 4
检查复制状况。
查看 PostgreSQL 进程状况结果,以验证复制是否处于活动状态。
在 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
在 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
在 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
根据上述进程状况的捕获内容,遵循以下步骤来验证复制是否已启动并正在运行:
node0 具有一个发送器进程,复制目标为:10.91.9.24 (node1)。
node1 具有一个发送器进程和一个接收器进程。
node2 只有一个接收器进程。
所有三个节点在流 1A/BC0039A0 处同步