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. [转载]Linux中的网络接口及LO回环接口

    转自:https://blog.csdn.net/weixin_39863747/article/details/80564358 Linux中的网络接口及LO回环接口 2018年06月04日 10: ...

  2. There is no Action mapped for namespace / and action name .解答

    做struts2登陆检验的时候遇到了一个问题: 输入http://localhost/login_validation/的目的是想显示 文件夹下的文件列表,无奈,使用struts框架,web.xml设 ...

  3. Codeforces 629 E. Famil Door and Roads

    题目链接:http://codeforces.com/problemset/problem/629/E 询问这个简单环的期望.考虑将这个环拆成两部分. 令${deep[x]>=deep[y]}$ ...

  4. Algorithm 算法基础知识(未完成

    基础概念不讲,记录课上关键部分 时间复杂度(Time Complexity) 算法所需要花的时间 比较时间复杂度(主要看问题的规模) 时间频度(算法执行次数)T(n)和T(n1),如果两个时间频度为等 ...

  5. Rancher中的服务升级实验

    个容器副本,使用nginx:1.13.0镜像.假设使用一段时期以后,nginx的版本升级到1.13.1了,如何将该服务的镜像版本升级到新的版本?实验步骤及截图如下: 步骤截图: 个容器,选择镜像ngi ...

  6. 常见字符集&乱码问题

    字符集 常用字符集分类 ASCII及其扩展字符集 作用:表语英语及西欧语言. 位数:ASCII是用7位表示的,能表示128个字符:其扩展使用8位表示,表示256个字符. 范围:ASCII从00到7F, ...

  7. 人脸识别最新开发经验demo分享

    本来打算做个C#版demo,但没用成功,基于虹软的免费人脸识别技术 过程如下: 1. 传入一张单人脸照片: 2.调用检测人脸函数ASFDetectFaces,成功返回人脸信息的指针: 3.使用 Mar ...

  8. sort-桶排序

    void list_insert(list<int> &t,int num) { auto iter=t.begin(); for(;iter!=t.end();++iter) { ...

  9. Codeforces 985 F - Isomorphic Strings

    F - Isomorphic Strings 思路:字符串hash 对于每一个字母单独hash 对于一段区间,求出每个字母的hash值,然后排序,如果能匹配上,就说明在这段区间存在字母间的一一映射 代 ...

  10. vue子组件,同级组件之间的相互引用,以及传值交互

    博客地址:http://blog.csdn.net/wang_meiwei/article/details/75948844