YashanDB数据库主备高可用架构实践( 六 )

4)查看主备状态,备节点已经升级为主节点
[yashan@tango-DB02 ~]$ yasboot cluster status -c yashandb -d hostid| node_type | nodeid | pid| instance_status | database_status | database_role | listen_address| data_path--------------------------------------------------------------------------------------------------------------------------------------------------------- host0001 | db| 1-1:1| off| -| -| -| 192.168.112.121:1688 | /usr/local/yashandb/yasdb_data/db-1-1 ----------+-----------+--------+------+-----------------+-----------------+---------------+----------------------+--------------------------------------- host0002 | db| 1-2:2| 4410 | open| normal| primary| 192.168.112.122:1688 | /usr/local/yashandb/yasdb_data/db-1-2 ----------+-----------+--------+------+-----------------+-----------------+---------------+----------------------+---------------------------------------重启原来的主节点后,主备关系正常
[yashan@tango-DB02 ~]$ yasboot cluster status -c yashandb -d hostid| node_type | nodeid | pid| instance_status | database_status | database_role | listen_address| data_path----------------------------------------------------------------------------------------------------------------------------------------------------------- host0001 | db| 1-1:1| 102613 | open| normal| standby| 192.168.112.121:1688 | /usr/local/yashandb/yasdb_data/db-1-1 ----------+-----------+--------+--------+-----------------+-----------------+---------------+----------------------+--------------------------------------- host0002 | db| 1-2:2| 4410| open| normal| primary| 192.168.112.122:1688 | /usr/local/yashandb/yasdb_data/db-1-2 ----------+-----------+--------+--------+-----------------+-----------------+---------------+----------------------+---------------------------------------3.1.2 手动主备切换1)登录备机,检查主备机同步状态,确认主备机同步无异常
SQL> SELECT database_id,database_name,log_mode,open_mode,database_role FROM V$DATABASE;DATABASE_ID DATABASE_NAMELOG_MODEOPEN_MODEDATABASE_ROLE--------------------- ---------------------------------------------------------------- ----------------- ----------------- -----------------2888093870 yashandbARCHIVELOGREAD_ONLYSTANDBY2)确认备机同步状态正常
SQL> SELECT connection, status, peer_addr, transport_lag, apply_lag FROM V$REPLICATION_STATUS;CONNECTIONSTATUSPEER_ADDRTRANSPORT_LAGAPPLY_LAG ----------------- ----------------- ---------------------------------------------------------------- ------------- ------------ CONNECTEDNORMAL192.168.112.121:1689003)在备机执行switchover切换操作,此时主机的所有事务中断,且switchover执行过程中,客户端无法连接主机 。
SQL> alter database switchover;切换完成后 , 查看主备机的角色是否发生变化
[yashan@tango-DB01 ~]$ yasboot cluster status -c yashandb -d hostid| node_type | nodeid | pid| instance_status | database_status | database_role | listen_address| data_path---------------------------------------------------------------------------------------------------------------------------------------------------------- host0001 | db| 1-1:1| 39926 | open| normal| standby| 192.168.112.121:1688 | /usr/local/yashandb/yasdb_data/db-1-1 ----------+-----------+--------+-------+-----------------+-----------------+---------------+----------------------+--------------------------------------- host0002 | db| 1-2:2| 38096 | open| normal| primary| 192.168.112.122:1688 | /usr/local/yashandb/yasdb_data/db-1-2 ----------+-----------+--------+-------+-----------------+-----------------+---------------+----------------------+---------------------------------------4)也可以使用yaboot命令执行主备切换
[yashan@tango-DB01 ~]$ yasboot node switchover -c yashandb -n 1-1|key|value|-----------------------------------------------+------|clusterName|yashandb|the group type of input node is|db|the group name of input node is|dbg1|the role of input node is|standby|the primary node name of input node's group is |1-2Switchover need primary node and selected node all are open and normalAre you sure you want to switchover node 1-1 to primary: [yashandb][yes/no]: yes type | uuid| name| hostid | index | status| return_code | progress | cost ------------------------------------------------------------------------------------------------------------- task | 839275bfbfccf242 | SwitchoverYasdbCluster | -| dbg1| SUCCESS | 0| 100| 2------+------------------+------------------------+--------+-------+---------+-------------+----------+------task completed, status: SUCCESS其中参数-n为要升主的节点ID(例如1-1,可以通过cluster status命令查看,不需要冒号及后面的数字) 。检查主备节点状态,确认已经发生了切换 。
3.2 表的闪回操作YashanDB提供的闪回功能,当用户误操作等原因导致表的数据被删除,使用闪回功能可以查看过去的数据状态,并在时间上倒回指定时间点的数据,无需从备份中恢复数据 。注:该功能只对行存表(HEAP表)有效


推荐阅读