DataGuard日常维护
2008-09-19 10:05:59 来源:WEB开发网m.监控恢复操作的进程
SELECTARCHIVED_THREAD#,ARCHIVED_SEQ#,APPLIED_THREAD#,APPLIED_SEQ#FROMV$ARCHIVE_DEST_STATUS;
--从正在恢复状态只读打开;
SQL>AlterDATABASERECOVERMANAGEDSTANDBYDATABASECANCEL;
SQL>AlterDATABASEOPENREADONLY;
--切换回到恢复状态;
SQL>AlterDATABASERECOVERMANAGEDSTANDBYDATABASEDISCONNECTFROMSESSION;
切换角色
注意:Swithover时只能先从Primary切到Standby,再从Standby切到Primary.
1、在主库端
selectdatabase_role,switchover_statusfromv$database;
如果是to standby 表可以正常切换.
直接执行 ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY;
否则执行: ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;
SQL>shutdownimmediate;
SQL>startupnomount;
SQL>alterdatabasemountstandbydatabase;
SQL>selectdatabase_rolefromv$database;
SQL>alterdatabaserecovermanagedstandbydatabasedisconnectfromsession;
2、在备库端
selectdatabase_role,switchover_statusfromv$database;
如果是to_primary 表可以正常切换.
执行:ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
否则执行: ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;
shutdownimmediate;
startup;
然后观察主备库日志,如果正常的话会看到备库会自动应用日志.
failover测试
1. 备库上检查是否存在归档中断
SQL>SELECTTHREAD#,LOW_SEQUENCE#,HIGH_SEQUENCE#FROMV$ARCHIVE_GAP;
2. 在主库上执行语句并找出归档文件
SQL>SELECTNAMEFROMV$ARCHIVED_LOGWHERETHREAD#=1ANDDEST_ID=1ANDSEQUENCE#BETWEENXXANDXX;
--如果存在拷贝相应的归档到STANDBY数据库,并注册.
SQL>ALTERDATABASEREGISTERPHYSICALLOGFILE'xxx';
***其他情况(primary数据库无法打开):
--检查归档文件是否完整
分别在primary/standby执行下列语句:
SQL>selectdistinctthread#,max(sequence#)over(partitionbythread#)afromv$archived_log;
把相差的归档复制到待转换的standby服务器
3. 启动failover
SQL>alterdatabaserecovermanagedstandbydatabasefinishforce;
FORCE关键字将会停止当前活动的RFS进程,以便立刻执行failover。
或
SQL>alterdatabaserecovermanagedstandbydatabasefinishskipstandbylogfile;
4. 切换物理standby角色为primary
SQL>alterdatabasecommittoswitchovertoprimary;
SQL>shutdownimmediate
SQL>startup
更多精彩
赞助商链接