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. java复制文件夹中的所有文件和文件夹到另一个文件夹中

    1.复制文件夹 public static void copyDir(String oldPath, String newPath) throws IOException { File file = ...

  2. Graphics for R

    https://cran.r-project.org/web/views/Graphics.html CRAN Task View: Graphic Displays & Dynamic Gr ...

  3. python 加密

    https://github.com/duanhongyi/gmssl

  4. CentOS7 安装Perl

    官网:http://www.cpan.org/src/ wget https:.tar.gz cd perl- ./Configure -des -Dprefix=$HOME/localperl ma ...

  5. mysql基本知识总结

    第一天 create database act_web character set utf8; : 创建数据库并设立编码(命令中是不允许使用“-”的) '; :创建用户并设立密码 grant all ...

  6. 力扣(LeetCode)13. 罗马数字转整数

    罗马数字包含以下七种字符: I, V, X, L,C,D 和 M. 字符 数值 I 1 V 5 X 10 L 50 C 100 D 500 M 1000 例如, 罗马数字 2 写做 II ,即为两个并 ...

  7. ios手机域名https协议注意事项

    加载网页版链接框架不能用http 1.下载到本地 2.转换为cdn https

  8. Python pip 常用命令

    使用了这么就pip命令,但是一直是简单使用,很多命令都是用了查,查了用,今天把常用的命令汇总一下,方便使用. 命令: pip 由上图可以看到 pip 支持一下命令 Commands: install ...

  9. C# 中 ? 和 ??

    a??2 等价于 a==null?2:a 原文:https://blog.csdn.net/szx1999/article/details/50996495

  10. appium --log-timestamp > appium.log

     appium --log-timestamp > appium.log