阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Oracle Dataguard的强制切换

223次阅读
没有评论

共计 3596 个字符,预计需要花费 9 分钟才能阅读完成。

【前言】Dataguard 的从库一般情况下都是出于数据的抽取和查询的作用的,但是万一在主库发生故障的情况下就需要切换到备库了。而这种故障的切换往往又是灾难性的情况:比如主库的服务器根本就起不来了,没有办法进行正常的切换,就需要强制的把从库切换成主库了。

【操作步骤】这个时候主库根本是操作不了的,所以只需在从库执行以下操作

【1】停止应用恢复模式

alter database recover managed standby database finish;

【2】从库切换成主库

alter database commit to switchover to primary;

【3】启动数据库

Alter database open;

【4】检查备库的状态

select open_mode,database_role from v$database;

OPEN_MODE      DATABASE_ROLE————–      ———————- OPEN                PRIMARY

【其他】切换完成后,就需要更改应用的连接 IP 地址和相关的一系列的连接(DBLINK 等其他接口),如果再规划的时候就把这部分的内容考虑过去的话,那么就减少了很多切换后的工作。

如果服务器的 IP 地址不变的话,那么就可以节省很多的工作了。这就需要前期的规划:通过负载均衡设置一个虚拟 ip,当服务器发生故障后,切换虚拟 ip 对应的实体 ip 就好了。如果没有这个硬件的话,通过软件也是可以实现的比如:keepalived 工具等。

附:切换日志

alter database recover managed standby database finish 停止应用进行日志的恢复
Attempt to do a Terminal Recovery (DE2)
Media Recovery Start: Managed Standby Recovery (DE2)
started logmerger process
Wed Mar 29 10:21:35 2017
Managed Standby Recovery not using Real Time Apply
Parallel Media Recovery started with 8 slaves
Media Recovery Log /Oracle/DE2/oraarch/DE2arch/1_565_912333510.dbf
Media Recovery Waiting for thread 1 sequence 566 (in transit)
krsv_proc_kill: Killing 4 processes (all RFS, wait for I/O)
Begin: Standby Redo Logfile archival
End: Standby Redo Logfile archival
Terminal Recovery timestamp is ’03/29/2017 10:21:43′
Terminal Recovery: applying standby redo logs.
Terminal Recovery: thread 1 seq# 566 redo required
Terminal Recovery:
Recovery of Online Redo Log: Thread 1 Group 14 Seq 566 Reading mem 0
Mem# 0: /oracle/DE2/mirrlogA/sredo14.log
Identified End-Of-Redo (failover) for thread 1 sequence 566 at SCN 0xffff.ffffffff
Wed Mar 29 10:21:48 2017
Incomplete Recovery applied until change 21240383491 time 03/29/2017 10:27:41
Wed Mar 29 10:21:48 2017
Media Recovery Complete (DE2)
Terminal Recovery: successful completion
Forcing ARSCN to IRSCN for TR 4:4060514307
Attempt to set limbo arscn 4:4060514307 irscn 4:4060514307
Resetting standby activation ID 1489765315 (0x58cc03c3)
Wed Mar 29 10:21:51 2017
ARCH: Archival stopped, error occurred. Will continue retrying
ORACLE Instance DE2 – Archival Error
ORA-16014: log 14 sequence# 566 not archived, no available destinations
ORA-00312: online log 14 thread 1: ‘/oracle/DE2/mirrlogA/sredo14.log’
Completed: alter database recover managed standby database finish 完成日志的应用
Wed Mar 29 10:22:12 2017
alter database commit to switchover to primary 从库切换成主库
ALTER DATABASE SWITCHOVER TO PRIMARY (DE2)
Maximum wait for role transition is 15 minutes.
CLOSE: killing server sessions.
CLOSE: all sessions shutdown successfully.
Wed Mar 29 10:22:12 2017
SMON: disabling cache recovery
Backup controlfile written to trace file /oracle/DE2/saptrace/diag/rdbms/de2dg/DE2/trace/DE2_ora_9961494.trc
Standby terminal recovery start SCN: 21240295534
RESETLOGS after incomplete recovery UNTIL CHANGE 21240383491 重建 redolog
Online log /oracle/DE2/mirrlogB/log_g15m1.dbf: Thread 1 Group 5 was previously cleared
Online log /oracle/DE2/mirrlogB/log_g15m2.dbf: Thread 1 Group 5 was previously cleared
Online log /oracle/DE2/mirrlogA/log_g16m1.dbf: Thread 1 Group 6 was previously cleared
Online log /oracle/DE2/mirrlogA/log_g16m2.dbf: Thread 1 Group 6 was previously cleared
Online log /oracle/DE2/mirrlogB/log_g17m2.dbf: Thread 1 Group 7 was previously cleared
Online log /oracle/DE2/mirrlogB/log_g17m1.dbf: Thread 1 Group 7 was previously cleared
Online log /oracle/DE2/mirrlogA/log_g18m2.dbf: Thread 1 Group 8 was previously cleared
Online log /oracle/DE2/mirrlogA/log_g18m1.dbf: Thread 1 Group 8 was previously cleared
Standby became primary SCN: 21240295533
Wed Mar 29 10:22:13 2017
Setting recovery target incarnation to 3
Switchover: Complete – Database mounted as primary
Completed: alter database commit to switchover to primary 完成切换
Wed Mar 29 10:22:37 2017
alter database open
Data Guard Broker initializing…
Data Guard Broker initialization complete
Data Guard: verifying database primary role…

更多 Oracle 相关信息见 Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12

本文永久更新链接地址 :http://www.linuxidc.com/Linux/2017-05/143391.htm

正文完
星哥玩云-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-22发表,共计3596字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中