Oracle 11.2.0.4.0 Dataguard部署和日常维护(5)-Datauard 主备切换和故障转移篇

1. dataguard主备切换

1.1. 查看当前主备库是否具备切换条件

  • on slave
select sequence#,first_time,next_time,archived,applied from v$archived_log where SEQUENCE#=(select max(SEQUENCE#) from v$archived_log);

 SEQUENCE#   FIRST_TIME             NEXT_TIME            ARCHIVED     APPLIED
----------   -------------------   -------------------   ---------    ---------------------------
    51     2017-07-03 22:00:41    2017-07-04 17:04:55   YES           IN-MEMORY

select sequence#,first_time,next_time,archived,applied from v$archived_log where SEQUENCE#=(select max(SEQUENCE#) from v$archived_log);

 SEQUENCE# FIRST_TIME           NEXT_TIME       ARCHIVED  APPLIED
---------- ------------------- ------------------- --------- ---------------------------
    51 2017-07-03 22:00:41 2017-07-04 17:04:55 YES         IN-MEMORY

select PROCESS,SEQUENCE#,STATUS from v$managed_standby;

PROCESS                  SEQUENCE#   STATUS
--------------------------- ---------- ------------------------------------
ARCH                      47       CLOSING
ARCH                      50       CLOSING
ARCH                       0        CONNECTED
ARCH                      51       CLOSING
RFS                        0           IDLE
RFS                       52       IDLE
RFS                        0       IDLE
MRP0                      52       APPLYING_LOG
  • on master
select SEQUENCE#,STATUS from v$log order by SEQUENCE#;

 SEQUENCE#   STATUS
---------- ------------------------------------------------
    50     INACTIVE
    51     INACTIVE
    52     CURRENT

column DATABASE_ROLE format a20
column OPEN_MODE format a15
column PROTECTION_MODE format a20
column SWITCHOVER_STATUS format a20
select DATABASE_ROLE,OPEN_MODE,PROTECTION_MODE,SWITCHOVER_STATUS from v$database;

DATABASE_ROLE         OPEN_MODE       PROTECTION_MODE      SWITCHOVER_STATUS
-------------------- --------------- -------------------- --------------------
PRIMARY              READ WRITE      MAXIMUM PERFORMANCE  TO STANDBY

1.2. 将主库转换为备库

alter database commit to switchover to physical standby with session shutdown;
startup mount;
alter database recover managed standby database using current logfile disconnect from session;
select DATABASE_ROLE,OPEN_MODE,PROTECTION_MODE,SWITCHOVER_STATUS from v$database;

DATABASE_ROLE         OPEN_MODE        PROTECTION_MODE      SWITCHOVER_STATUS
-------------------- --------------- -------------------- --------------------
PHYSICAL STANDBY      MOUNTED          MAXIMUM PERFORMANCE  TO PRIMARY

1.3. 将备库转换为主库

column DATABASE_ROLE format a20
column OPEN_MODE format a15
column PROTECTION_MODE format a20
column SWITCHOVER_STATUS format a20
select DATABASE_ROLE,OPEN_MODE,PROTECTION_MODE,SWITCHOVER_STATUS from v$database;

DATABASE_ROLE        OPEN_MODE       PROTECTION_MODE      SWITCHOVER_STATUS
-------------------- --------------- -------------------- --------------------
PHYSICAL STANDBY     MOUNTED         MAXIMUM PERFORMANCE  TO PRIMARY

alter database commit to switchover to primary;
alter database open;
select DATABASE_ROLE,OPEN_MODE,PROTECTION_MODE,SWITCHOVER_STATUS from v$database;

DATABASE_ROLE        OPEN_MODE      PROTECTION_MODE       SWITCHOVER_STATUS
-------------------- --------------- -------------------- --------------------
PRIMARY              READ WRITE     MAXIMUM PERFORMANCE   TO STANDBY

1.4. 测试主备数据同步状态

  • on primary
select sequence#,first_time,next_time,archived,applied from v$archived_log where SEQUENCE#=(select max(SEQUENCE#) from v$archived_log);

 SEQUENCE# FIRST_TIME          NEXT_TIME          ARCHIVED  APPLIED
---------- ------------------- ------------------- --------- ---------------------------
    54   2017-07-05 02:30:34 2017-07-05 02:30:40  YES       NO
    54   2017-07-05 02:30:34 2017-07-05 02:30:40  YES       YES

alter system archive log current;
alter system archive log current;

select sequence#,first_time,next_time,archived,applied from v$archived_log where SEQUENCE#=(select max(SEQUENCE#) from v$archived_log);

 SEQUENCE# FIRST_TIME           NEXT_TIME          ARCHIVED  APPLIED
---------- ------------------- ------------------- --------- ---------------------------
    56   2017-07-05 02:40:01  2017-07-05 02:40:03 YES       NO
    56   2017-07-05 02:40:01  2017-07-05 02:40:03 YES       NO
  • on standby
select sequence#,first_time,next_time,archived,applied from v$archived_log where SEQUENCE#=(select max(SEQUENCE#) from v$archived_log);

 SEQUENCE# FIRST_TIME          NEXT_TIME           ARCHIVED  APPLIED
---------- ------------------- ------------------- --------- ---------------------------
    56     2017-07-05 02:40:01 2017-07-05 02:40:03 YES       IN-MEMORY

2. dataguard故障转移

2.1. 前提:主库已经挂掉

2.2. 将备库强制转换为主库

2.3. 重建备库

时间: 2024-10-16 16:42:20

Oracle 11.2.0.4.0 Dataguard部署和日常维护(5)-Datauard 主备切换和故障转移篇的相关文章

Oracle 11.2.0.4.0 dataguard部署和日常维护(2)

1. primary库设置dataguard相关参数 1.1. 强制primay库在任何状态下必须记录日志 SYS@userdata>select FORCE_LOGGING from v$database; FORCE_LOG --------- NO SYS@userdata>alter database force logging; Database altered. SYS@userdata>select FORCE_LOGGING from v$database; FORCE_

Oracle 11.2.0.4.0 Dataguard部署和日常维护(6)-Active dataguard

1. 检查主备库的状态 on primary column DATABASE_ROLE format a20 column OPEN_MODE format a15 column PROTECTION_MODE format a20 column SWITCHOVER_STATUS format a20 select DATABASE_ROLE,OPEN_MODE,PROTECTION_MODE,SWITCHOVER_STATUS from v$database; DATABASE_ROLE O

Oracle 11.2.0.4.0 Dataguard部署和日常维护(7) - Dataguard Flashback

1. 检查主备库同步状态 2. 开启备库的闪回功能和闪回目录 3. 取消备库的恢复进程 4. 创建备库的还原点 5. 在主库归档日志 6. 确认备库已经归档了最新的日志 7. 延迟指向将被激活的备的日志归档目的地 8. 激活备库 9. 向备库写入测试数据 10. 将备库闪回至还原点 11. 重新启用到备库的日志归档目的地 12. 测试数据同步是否正常

Oracle 11.2.0.4.0 Dataguard部署和日常维护(6)-Dataguard Snapshot

1. 检查当前主备库同步状态 on primary select ads.dest_id,max(sequence#) "Current Sequence", max(log_sequence) "Last Archived" from v$archived_log al, v$archive_dest ad, v$archive_dest_status ads where ad.dest_id=al.dest_id and al.dest_id=ads.dest_

Oracle11g搭建DataGuard及主备切换方法总结【亲测可用】

2019-04-11 分类:Oracle 阅读(2626) 评论(0) 文章目录[隐藏] 一.DataGuard 工作原理 二.搭建环境 三.主库配置 四.备库配置 五.主备切换 一.DataGuard 工作原理 Data Gurad 通过冗余数据来提供数据保护,Data Gurad 通过日志同步机制保证冗余数据和主数之前的同步,这种同步可以是实时,延时,同步,异步多种形式.Data Gurad 常用于异地容灾和小企业的高可用性方案,虽然可以在Standby 机器上执行只读查询,从而分散Prim

ORACLE DataGuard主备切换

主库磁盘问题,导致主库宕机,因为归档还没有应用,导致备库无法转为主库 先查看一下备库当前的信息: SQL> select * from v$version; BANNER ---------------------------------------------------------------------Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production PL/SQL Release 11.

oracle 11g dataguard主备切换

1.检查主备的环境 dg1节点: SQL> archive log list; Database log mode            Archive Mode Automatic archival            Enabled Archive destination           /u01/oradata/tong/archive Oldest online log sequence      59 Next log sequence to archive     61 Cur

oracle dg库switchover主备切换

switchover 切换:主库与备库数据同步正常情况下的切换,主要用于 主备维护.切换演练等: failover 切换:主库与备库在数据未同步情况下的强制切换,主要用 于主库宕机.故障情况下切换: 一.switchover 切换 主库与备库数据同步,且正常运行,将主库与备库的角色互换: 切换前,务必检查当前主库与备库的归档是否是同步的,确认同步后再执行切换 switchover 切换 主库操作 第1步.主库停止监听 lsnrctl stop (理论上是不需要停止主库监听的,但是实际上如果切换时

Oracle Dataguard HA (主备,灾备)方案部署调试

包括: centos6.5 oracle11gR2 DataGuard安装 dataGuard 主备switchover角色切换 数据同步测试 <一,>DG数据库数据同步测试1,正常启动主库$sqlplus / as sysdbasql>startup 2,启动备库$sqlplus / as sysdbasql>startup mountsql>alter database recover managed standby database disconnect from se