官方文档推荐的标准操作语句,备库按顺序如下
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;
SQL> ALTER DATABASE OPEN;
以前的一个实验,主库宕机的情况下,备库直接执行如下三条语句即可(三种保护模式都实验过,都是可以的)
1.备库执行alter database recover managed standby database finish force;
2.备库执行alter database commit to switchover to primary with session shutdown;
3.备库执行alter database open;
以上情况如果是采用arch传输或采用lgwr传输但是没有real-time Apply(real-time Apply的前提就是先建立standby redo log再执行alter database recover managed standby database using current logfile disconnect from session;),主库一些数据插入后commit但是不archive log current后,备库会丢失这些数据,如果是最大可用模式则不会。
原来standby是open状态,如果是最大性能模式、最大保护模式则执行以上第二步后变成了mount状态。如果是最大可用模式则执行第一步后变成了mount状态
主库宕机后,备库原来的状态不变,如果原来是MAXIMIZE PERFORMANCE、MAXIMUM AVAILABILITY、MAXIMUM PROTECTION维持不变。
备库关机后,重启的过程中,可以直接startup到open模式,但是select open_mode from v$database的结果还是read only
最大可用性模式下,关闭备库DB和监听,验证是否转换为最大性能模式
主库v$database.protection_mode \v$database.protection_level由MAXIMUM AVAILABILITY\MAXIMUM AVAILABILITY变成MAXIMUM AVAILABILITY\RESYNCHRONIZATION,且主库正常运作可以正常多次执行alter system archive log current。重启备库DB至 startup和监听后,备库执行alter database recover managed standby database using current logfile disconnect from session;就可以了,并不需要一定要执行alter database recover managed standby database disconnect from session;再alter database recover managed standby database cancel;再alter database recover managed standby database using current logfile disconnect from session;说明最大可用模式与最大保护模式不同的是,如果故障导致主数据库无法写重做流到异地备重做日志时,即当最大可用模式不能实现时,自动降级为最大性能模式(但是主数据库不会关闭且主库protection_mode不变,只是主库protection_level变成RESYNCHRONIZATION,说明这个自动降级是一种隐性的状态非表现在protection_mode和protection_level中),这样的结果使得日志同步不再实时。
RESYNCHRONIZATION的意思:再同步\重新同步
官方文档推荐的 标准操作的一次 实验过程
SQL> select database_role, switchover_status from v$database;
DATABASE_ROLE SWITCHOVER_STATUS
---------------- --------------------
PHYSICAL STANDBY NOT ALLOWED
ORACLE官方文档信息:A value of either TO PRIMARY or SESSIONS ACTIVE indicates that the standby database is ready to be switched to the primary role
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;
SQL> select database_role, switchover_status from v$database;
DATABASE_ROLE SWITCHOVER_STATUS
---------------- --------------------
PHYSICAL STANDBY TO PRIMARY
ORACLE官方文档信息:A value of either TO PRIMARY or SESSIONS ACTIVE indicates that the standby database is ready to be switched to the primary role
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;(会把原来open read only模式切换为mouted模式)
SQL> select database_role, switchover_status from v$database;
DATABASE_ROLE SWITCHOVER_STATUS
---------------- --------------------
PRIMARY NOT ALLOWED
SQL> ALTER DATABASE OPEN;
切换实验用到的一系列验证的语句
select STATUS from v$instance;
select OPEN_MODE,DATABASE_ROLE,PROTECTION_MODE,PROTECTION_LEVEL,SWITCHOVER_STATUS from v$database;
alter database recover managed standby database finish force;
select STATUS from v$instance;
select OPEN_MODE,DATABASE_ROLE,PROTECTION_MODE,PROTECTION_LEVEL,SWITCHOVER_STATUS from v$database;
alter database commit to switchover to primary with session shutdown;
select STATUS from v$instance;
select OPEN_MODE,DATABASE_ROLE,PROTECTION_MODE,PROTECTION_LEVEL,SWITCHOVER_STATUS from v$database;
alter database open;
select STATUS from v$instance;
select OPEN_MODE,DATABASE_ROLE,PROTECTION_MODE,PROTECTION_LEVEL,SWITCHOVER_STATUS from v$database;
主库MAXIMUM PERFORMANCE时备库Mount和open各来一次
Standby是MOUNT状态
Standby是OPNE状态
![](http://img.blog.itpub.net/blog/attachment/201607/22/30126024_1469177484fwb2.jpg?x-oss-process=style/bb)
![](http://img.blog.itpub.net/blog/attachment/201607/22/30126024_1469177505fF1Z.jpg?x-oss-process=style/bb)
主库MAXIMUM AVAILABILITY时备库open来一次
![](http://img.blog.itpub.net/blog/attachment/201607/22/30126024_1469177541BbBb.jpg?x-oss-process=style/bb)
Standby是OPEN状态(不用mount是因为mount无法验证数据是否实时同步过来了,mount时无法select 用户建立的表)
![](http://img.blog.itpub.net/blog/attachment/201607/22/30126024_1469177573k1Ys.jpg?x-oss-process=style/bb)
![](http://img.blog.itpub.net/blog/attachment/201607/22/30126024_146917759499za.jpg?x-oss-process=style/bb)
主库MAXIMUM PROTECTION时备库open来一次
主库图片
![](http://img.blog.itpub.net/blog/attachment/201607/28/30126024_14696935085YKk.jpg?x-oss-process=style/bb)
备库图片
![](http://img.blog.itpub.net/blog/attachment/201607/28/30126024_1469693533iNjy.jpg?x-oss-process=style/bb)
![](http://img.blog.itpub.net/blog/attachment/201607/28/30126024_1469693557oe44.jpg?x-oss-process=style/bb)
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30126024/viewspace-2122405/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/30126024/viewspace-2122405/