日期:2014-05-16  浏览次数:20489 次

物理Data Guard主备库切换步骤

物理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;

 

 --如果报ORA-16139: media recovery required,可能是由于未应用日志引起,可先执行

ALTER  DATABASE RECOVER MANAGED STANDBY  DATABASE DISCONNECT FROM SESSION;

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

 

 SQL> ALTER DATABASE OPEN;

 SQL> SHUTDOWN IMMEDIATE;

  SQL> STARTUP;

 

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

 

SQL> ALTER SYSTEM SWITCH LOGFILE;

 

Setp 8   应用归档日志(原主库上执行)

 

  SQL> ALTER  DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;