物理Data Guard主备切换步骤

时间:2021-10-23 13:09:14

物理Data Guard角色转换步骤

 

Step  1   验证主库是否能执行角色转换到备库(原主库执行)

SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
-----------------
TO STANDBY
1 row selected

Step 2  开始把物理主库改变为物理备库物理(原主库执行)

SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY;
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY with session shutdown;
注:如果有活动的session可以使用此选项,否则转换会遇到ORA-01093错误,也可以杀掉活动会话或等活动会话后进行转换

 

Step 3  关闭并重启主库(原主库执行)

SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP MOUNT;

Step 4  验证备库是否能执行角色转换到主库(原备库执行)

SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
-----------------
TO_PRIMARY
1 row selected

Step 5   开始把物理备库转换成物理主库(原备库执行)

SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;

Step 6   打开备库,然后关闭重启.(原备库执行)

SQL> ALTER DATABASE OPEN;

SQL> SHUTDOWN IMMEDIATE;SQL> STARTUP;

 

Step 7   验证是否转换成功(原备库执行)

SQL> ALTER SYSTEM SWITCH LOGFILE;