1. 设置备库的闪回目录

show parameter db_recovery_file;

NAME                             TYPE                         VALUE
------------------------------------ --------------------------------- -------------------------------------------
db_recovery_file_dest    string      /u01/app/oracle/fast_recovery_area
db_recovery_file_dest_size   big integer 4G

2. 开启备库的闪回功能

select flashback_on from v$database;

FLASHBACK_ON
------------------------------------------------------
NO alter database flashback on; alter database flashback on
*
ERROR at line 1:
ORA-01153: an incompatible media recovery is active alter database recover managed standby database cancel;
alter database flashback on;
select flashback_on from v$database; FLASHBACK_ON
------------------------------------------------------
YES
alter database recover managed standby database using current logfile disconnect from session;

3. 检查主备库同步状态

  • 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_id
and al.resetlogs_change#=(select max(resetlogs_change#) from v$archived_log )
group by ads.dest_id; DEST_ID Current Sequence Last Archived
---------- ---------------- -------------
1 79 79
2 79 80
  • on standby
select al.thrd "Thread", almax "Last Seq Received", lhmax "Last Seq Applied"
from (select thread# thrd, max(sequence#) almax
from v$archived_log
where resetlogs_change#=(select resetlogs_change# from v$database)
group by thread#) al,
(select thread# thrd, max(sequence#) lhmax
from v$log_history
where resetlogs_change#=(select resetlogs_change# from v$database)
group by thread#) lh
where al.thrd = lh.thrd; Thread Last Seq Received Last Seq Applied
---------- ----------------- ----------------
1 79 79

4. 取消备库的恢复进程

select process,status from v$managed_standby;

PROCESS             STATUS
------------------- ------------------------------------
ARCH CLOSING
ARCH CLOSING
ARCH CONNECTED
ARCH CLOSING
RFS IDLE
RFS IDLE
RFS IDLE
MRP0 APPLYING_LOG alter database recover managed standby database cancel; select process,status from v$managed_standby; PROCESS STATUS
------------------- ------------------------------------
ARCH CLOSING
ARCH CLOSING
ARCH CONNECTED
ARCH CLOSING
RFS IDLE
RFS IDLE
RFS IDLE

5. 创建备库的还原点

create restore point before_open_standby guarantee flashback database;
select name from v$restore_point; NAME
--------------------------------------------------
BEFORE_OPEN_STANDBY

6. 在主库归档日志

alter system archive log current;

7. 确认备库已经归档了最新的日志

select al.thrd "Thread", almax "Last Seq Received", lhmax "Last Seq Applied"
from (select thread# thrd, max(sequence#) almax
from v$archived_log
where resetlogs_change#=(select resetlogs_change# from v$database)
group by thread#) al,
(select thread# thrd, max(sequence#) lhmax
from v$log_history
where resetlogs_change#=(select resetlogs_change# from v$database)
group by thread#) lh
where al.thrd = lh.thrd; Thread Last Seq Received Last Seq Applied
---------- ----------------- ----------------
1 80 79

8. 延迟指向被激活的备库的日志归档目的地

show parameter log_archive_dest_state_2;

NAME                             TYPE                              VALUE
------------------------------------ --------------------------------- ------------------------------
log_archive_dest_state_2    string ENABLE alter system set log_archive_dest_state_2='DEFER'; show parameter log_archive_dest_state_2; NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
log_archive_dest_state_2 string DEFER

9. 激活备库

alter database activate standby database;
alter database open;
select open_mode,database_role from v$database; OPEN_MODE               DATABASE_ROLE
------------------------------------------------------------ ------------------------------------------------
READ WRITE               PRIMARY

10. 向备库写入测试数据

begin
for i in 1..10000 loop
insert into test10 values (i,'shall');
end loop;
commit;
end;
/ PL/SQL procedure successfully completed. select count(*) from test10; COUNT(*)
----------
10000

11. 将备库闪回至还原点

shutdown immediate;
startup mount;
flashback database to restore point before_open_standby;
alter database convert to physical standby;
shutdown immediate;
startup mount;
alter database recover managed standby database using current logfile disconnect from session;

12. 重新启用到备库的日志归档目的地

alter system set log_archive_dest_state_2='ENABLE';
show parameter log_archive_dest_state_2; NAME         TYPE       VALUE
------------------------------------ --------------------------------- ------------------------------
log_archive_dest_state_2    string      ENABLE

13. 测试数据同步是否正常

  •  on primary
alter system archive log current;
alter system archive log current; 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_id
and al.resetlogs_change#=(select max(resetlogs_change#) from v$archived_log )
group by ads.dest_id; DEST_ID Current Sequence Last Archived
---------- ---------------- -------------
1 83 83
2 83 84
  • on standby
select al.thrd "Thread", almax "Last Seq Received", lhmax "Last Seq Applied"
from (select thread# thrd, max(sequence#) almax
from v$archived_log
where resetlogs_change#=(select resetlogs_change# from v$database)
group by thread#) al,
(select thread# thrd, max(sequence#) lhmax
from v$log_history
where resetlogs_change#=(select resetlogs_change# from v$database)
group by thread#) lh
where al.thrd = lh.thrd; Thread Last Seq Received Last Seq Applied
---------- ----------------- ----------------
1 83 83

14. 清理闪回点

select name from v$restore_point;

NAME
--------------------------------------------------
BEFORE_OPEN_STANDBY drop restore point BEFORE_OPEN_STANDBY;

Oracle 11.2.0.4.0 Dataguard部署和日常维护(7) - Dataguard Flashback篇的更多相关文章

  1. Oracle 11.2.0.4.0 Dataguard部署和日常维护(3)-Datauard监控篇

    1.  v$database    查看当前数据库的角色和保护模式 primary库查看 column NAME format a10 column PROTECTION_MODE format a2 ...

  2. Oracle 11.2.0.4.0 Dataguard部署和日常维护(1)-数据库安装篇

    本次测试环境 系统版本 CentOS release 6.8 主机名 ec2t-userdata-01 ec2t-userdata-01 IP地址 10.189.102.118 10.189.100. ...

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

    1. 检查当前主备库同步状态 on primary select ads.dest_id,max(sequence#) "Current Sequence", max(log_se ...

  4. Oracle 11.2.0.4.0 Dataguard部署和日常维护(2)-Datauard部署篇

    1. primary库设置dataguard相关参数   1.1. 强制primay库在任何状态下必须记录日志 SYS@userdata>select FORCE_LOGGING from v$ ...

  5. Oracle 11.2.0.4.0 Dataguard部署和日常维护(4)-Datauard Gap事件解决篇

    Oracle dataguard主库删除备库需要的归档时,会导致gap事情的产生,或者备库由于网络或物理故障原因,倒是备库远远落后于主库,都会产生gap事件,本例模拟gap事件的产生以及处理. 1. ...

  6. 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 ...

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

    1. dataguard主备切换   1.1. 查看当前主备库是否具备切换条件 on slave select sequence#,first_time,next_time,archived,appl ...

  8. Gitlab 快速部署及日常维护 (二)

    一.概述 上一篇我们将Gitlab的安装部署和初始化设置部分全部讲解完成了,接下来我们介绍Gitlab在日常工作中常遇见的问题进行梳理说明. 二.Gitlab的安装和维护过程中常见问题 1.Gitla ...

  9. Gitlab 快速部署及日常维护 (一)

    一.GitLab简介GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的web服务 二.GitLab系统架构git用户的主目录通常是/home/git(~ ...

随机推荐

  1. Hadoop技术内幕1——源代码环境准备

    Hadoop核心 1.HDFS:高容错性.高伸缩性……,允许用户将Hadoop部署在廉价的硬件上,构建分布式系统 2.MapReduce:分布式计算框架,允许用户在不了解分布式系统底层细节的情况下,开 ...

  2. 2、My Scripts

    http://www.cnblogs.com/image-eye/archive/2011/10/26/2220405.html      注释详解 1.打印选择菜单,按照选择项一键安装不同的web服 ...

  3. 3、Python函数详解(0601)

    回顾: re search,findall,finditer.sub,subn function ()    调用函数 def func_name(arg1,....)   生成函数对象 func_s ...

  4. jenkins 异常

    八月 03, 2017 7:23:54 下午 org.eclipse.jetty.util.log.JavaUtilLog warn 警告: FAILED ServerConnector@29e6eb ...

  5. WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.

    点击报错信息中的app, 按照提示,修改compile 为 implementation 再次同步即可 结果

  6. 3.git、TortoiseGit的安装、仓库的配置教程

    参考:https://blog.csdn.net/hc_ttxs/article/details/79375788 引言: Git: 就是最原始的分布式版本控制系统,是开源的. GitHub:与Git ...

  7. leecode第十六题(最接近的三数之和)

    class Solution { public: void quick_order(vector<int>& num, int star, int en)//快排 { int st ...

  8. web 前端知识体系 网站资源分析

    一.比较全面的思维导图 二.相关资源 1. 布局框架:Bootstrap: http://getbootstrap.com/Foundation: http://foundation.zurb.com ...

  9. windows版 Java调用人脸识别离线sdk

    最近因工作需求在java-web服务中调用人脸识别离线sdk,主要通过JNA及JNI技术,但均未调试通过,JNA调用时出现以下异常,一直未解决,求大佬指点,导常信息如下: in BaiduFaceAp ...

  10. Codeforces 1006 F - Xor-Paths

    F - Xor-Path 思路: 双向搜索dfs 如果普通的搜索复杂度是n 那么双向搜索复杂度是√n 代码: #include<bits/stdc++.h> using namespace ...