主库磁盘问题,导致主库宕机,因为归档还没有应用,导致备库无法转为主库
先查看一下备库当前的信息:
SQL> select * from v$version; BANNER ---------------------------------------------------------------------Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production PL/SQL Release 11.2.0.3.0 - Production CORE 11.2.0.3.0 Production TNS for Linux: Version 11.2.0.3.0 - Production NLSRTL Version 11.2.0.3.0 - Production
查看当前数据库的状态:
SQL> select open_mode from v$database; OPEN_MODE -------------------- READ ONLY
该启动状态分为NOMOUNT,MOUNT,READ ONLY,READ WRITE四种状态
查看DG主备库的切换状态:
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE; SWITCHOVER_STATUS -------------------- TO STANDBY
DG失效切换状态包括NOT ALLOWED,SESSIONS ACTIVE,TO STANDBY,TO PRIMARY。当主库为TO STANDBY时,表示主库可以进行主备角色的切换。
ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY;
如遇到以下错误提示,说明主备间还有活动的会话链接
ORA-01093: ALTER DATABASE CLOSE only permitted with no sessions connected
可以通过以下语句强制关闭活动会话:
ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;
ORA-16139: media recovery required
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH SKIP STANDBY LOGFILE;
主库角色切换为备库后,还有部分参数需要修改。
1、修改获取归档的C/S端,这里的FAL(Fetch Archive Log)
SQL> show parameters fal NAME TYPE VALUE ---------- ----------- -------- fal_client string SID_PRI fal_server string SID_DG
2、修改主库log_archive_dest_state_n及log_archive_dest_n。
SQL> show parameters log_archive_dest_state_2 NAME TYPE VALUE ------------------------- ----------- -------log_archive_dest_state_2 string DEFER
SQL> show parameters log_archive_dest_2 NAME TYPE VALUE ------------------ ----------- ------------------log_archive_dest_2 string service=SID_DG
3、修改备库log_archive_dest_state_n及log_archive_dest_n。
SQL> show parameters log_archive_dest_state_2 NAME TYPE VALUE ------------------------- ----------- -------log_archive_dest_state_2 string ENABLE
SQL> show parameters log_archive_dest_2 NAME TYPE VALUE ------------------ ----------- ------------------log_archive_dest_2 string service=SID_PRI
4、查看备库状态 SESSIONS ACTIVE 切换角色为主库
alter database commit to switchover to primary; shutdown immediate startup mount alter database open read write
5、查看备库的文件管理状态
SQL> show parameters standby_file_management NAME TYPE VALUE ----------------------- ----------- ---------standby_file_management string AUTO
6、切换备库进入恢复模式:
alter database recover managed standby database disconnect from session;
7、查看主备归档同步情况:
SQL> select process, status,sequence#,block#,blocks, delay_mins from v$managed_standby; PROCESS STATUS SEQUENCE# BLOCK# BLOCKS DELAY_MINS --------- ------------ ---------- ---------- ---------- ---------- ARCH CONNECTED 0 0 0 0 ARCH CONNECTED 0 0 0 0 ARCH CONNECTED 0 0 0 0 ARCH CONNECTED 0 0 0 0 MRP0 WAIT_FOR_LOG 8048 0 0 0 RFS IDLE 0 0 0 0 RFS IDLE 8048 170025 824 0 RFS IDLE 0 0 0 0
只要备库的MRP(Managed Recovery Process)进程启动,就表示归档正常进行
SQL> select dest_name,status,target,archiver,schedule, valid_type,valid_role,db_unique_name from v$archive_dest where dest_name='LOG_ARCHIVE_DEST_2'; DEST_NAME STATUS TARGET ARCHIVER SCHEDULE VALID_TYPE VALID_ROLE DB_UNIQUE_NAME ------------------------- --------- ------- ---------- -------- --------------- ------------ ------------------------------ LOG_ARCHIVE_DEST_2 VALID STANDBY LGWR ACTIVE ALL_LOGFILES ALL_ROLES NONE
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。