|PolarDB-O主备高可用部署及切换排雷指引( 八 )
backend_xmin | state | sent_lsn | write_lsn | flush_lsn | replay_lsn | write_lag | flush_lag | replay_lag | sync_prior
ity | sync_state
------+----------+------------+-------------------------+-----------------+-----------------+-------------+----------------------------------+-
-------------+-----------+------------+------------+------------+------------+-----------------+-----------------+-----------------+-----------
----+------------
7189 | 16384 | replicator | standby_3232296578_5432 | 192.168.238.130 | | 47952 | 03-NOV-20 11:45:15.677601 +08:00 |
| streaming | 0/419D2FE8 | 0/419D2FE8 | 0/419D2FE8 | 0/419D2FE8 | 00:00:00.002503 | 00:00:00.002511 | 00:00:00.003535 |
1 | sync
(1 row)
vip也漂移到备节点了:
ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.238.131 netmask 255.255.255.0 broadcast 192.168.238.255
inet6 fe80::be05:6c57:dd7c:6856 prefixlen 64 scopeid 0x20<link>
inet6 fe80::3bff:7a9d:519:41ab prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:58:fa:6a txqueuelen 1000 (Ethernet)
RX packets 2073965 bytes 3100280275 (2.8 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 80015 bytes 81406434 (77.6 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens33:5432: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.238.133 netmask 255.255.255.0 broadcast 192.168.238.255
ether 00:0c:29:58:fa:6a txqueuelen 1000 (Ethernet)
2)自动方式切换
停止现在的131主库:
/usr/local/polardb_o_current/bin/pg_ctl stop -D $PGDATA -mi
查看切换状态:
curl -H ''Content-Type:application/json'' http://127.0.0.1:5000/v1/status?type=visual
自动切换中:
curl -H ''Content-Type:application/json'' http://127.0.0.1:5000/v1/status?type=visual
{
''phase'': ''SwitchingPhase'',
''master'': {
''endpoint'': ''192.168.238.131:5432'',
''data_path'': ''/opt/polardb/data'',
''user'': ''polardb'',
''phase'': ''RUNNING'',
''start_at'': ''2020-11-03 11:45:15'',
''sync_status'': ''SYNC''
},
''standby'': [
{
''endpoint'': ''192.168.238.130:5432'',
''data_path'': ''/opt/polardb/data'',
''user'': ''polardb'',
''phase'': ''RUNNING'',
''start_at'': ''2020-11-03 11:45:19'',
''sync_status'': ''SYNC''
}
],
''vip'': [
{
''vip'': ''192.168.238.133'',
''interface'': ''ens33'',
''mask'': ''255.255.255.0'',
''endpoint'': ''192.168.238.131:5432''
}
]
}
自动切换后:
curl -H ''Content-Type:application/json'' http://127.0.0.1:5000/v1/status?type=visual
{
''phase'': ''RunningPhase'',
''master'': {
''endpoint'': ''192.168.238.130:5432'',
''data_path'': ''/opt/polardb/data'',
''user'': ''polardb'',
''phase'': ''RUNNING'',
''start_at'': ''2020-11-03 13:58:17'',