SQL> select thread#, low_sequence#, high_sequence# from v$archive_gap;
确认下是否存在日志间隙,发现gap现象,说明failover不会有数据损失情况。
在standby端,关闭apply和结束应用动作
SQL> alter database recover managed standby database cancel;
数据库已更改。
SQL> alter database recover managed standby database finish;
数据库已更改。
SQL> select name, LOG_MODE, OPEN_MODE, database_role, SWITCHOVER_STATUS, db_unique_name from v$database;
NAME LOG_MODE OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS DB_UNIQUE_NAME
--------- ------------ -------------------- ---------------- -------------------- ------------------------------
PROD ARCHIVELOG READ ONLY PHYSICAL STANDBY TO PRIMARY orcl
SQL> alter database commit to switchover to primary with session shutdown;
数据库已更改。
SQL> select name, LOG_MODE, OPEN_MODE, database_role, SWITCHOVER_STATUS, db_unique_name from v$database;
NAME LOG_MODE OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS DB_UNIQUE_NAME
--------- ------------ -------------------- ---------------- -------------------- ------------------------------
PROD ARCHIVELOG MOUNTED PRIMARY NOT ALLOWED orcl
SQL> alter database open;
数据库已更改。
SQL> select name, LOG_MODE, OPEN_MODE, database_role, SWITCHOVER_STATUS, db_unique_name from v$database;
NAME LOG_MODE OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS DB_UNIQUE_NAME
-------- ------------ -------------------- ---------------- -------------------- ------------------------------
PROD ARCHIVELOG READ WRITE PRIMARY RESOLVABLE GAP orcl
SQL>
参考:https://www.cnblogs.com/lhrbest/p/4680273.html