Oracle 11.2.0.4.0 Dataguard部署和日常维护(7) - Dataguard Flashback篇
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篇的更多相关文章
- Oracle 11.2.0.4.0 Dataguard部署和日常维护(3)-Datauard监控篇
1. v$database 查看当前数据库的角色和保护模式 primary库查看 column NAME format a10 column PROTECTION_MODE format a2 ...
- 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. ...
- Oracle 11.2.0.4.0 Dataguard部署和日常维护(6)-Dataguard Snapshot篇
1. 检查当前主备库同步状态 on primary select ads.dest_id,max(sequence#) "Current Sequence", max(log_se ...
- Oracle 11.2.0.4.0 Dataguard部署和日常维护(2)-Datauard部署篇
1. primary库设置dataguard相关参数 1.1. 强制primay库在任何状态下必须记录日志 SYS@userdata>select FORCE_LOGGING from v$ ...
- Oracle 11.2.0.4.0 Dataguard部署和日常维护(4)-Datauard Gap事件解决篇
Oracle dataguard主库删除备库需要的归档时,会导致gap事情的产生,或者备库由于网络或物理故障原因,倒是备库远远落后于主库,都会产生gap事件,本例模拟gap事件的产生以及处理. 1. ...
- 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 ...
- Oracle 11.2.0.4.0 Dataguard部署和日常维护(5)-Datauard 主备切换和故障转移篇
1. dataguard主备切换 1.1. 查看当前主备库是否具备切换条件 on slave select sequence#,first_time,next_time,archived,appl ...
- Gitlab 快速部署及日常维护 (二)
一.概述 上一篇我们将Gitlab的安装部署和初始化设置部分全部讲解完成了,接下来我们介绍Gitlab在日常工作中常遇见的问题进行梳理说明. 二.Gitlab的安装和维护过程中常见问题 1.Gitla ...
- Gitlab 快速部署及日常维护 (一)
一.GitLab简介GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的web服务 二.GitLab系统架构git用户的主目录通常是/home/git(~ ...
随机推荐
- BSEG和BSIS、BSAS、BSID、BSAD、BSIK、BSAK 六个表的关系
BSEG和BSIS.BSAS.BSID.BSAD.BSIK.BSAK六个表的关系 1.数据关系: BSAS+BSIS+BSAK+BSIK+BSAD+BSID = BSEG 2.六个表说明: clear ...
- Python 网页解析器
Python 有几种网页解析器? 1. 正则表达式 2.html.parser (Python自动) 3.BeautifulSoup(第三方)(功能比较强大) 是一个HTML/XML的解析器 4.lx ...
- mybatis+spring boot, mapper 提示Could not autowire. No beans of … type found
工具及背景: IntelliJ IDEA 2016.1.3 Ultimate.spring boot, maven项目,利用mybatis 注解的方式查询mysql. 业务逻辑关系:controlle ...
- vuex深入理解 modules
一.什么是module? 背景:在Vue中State使用是单一状态树结构,应该的所有的状态都放在state里面,如果项目比较复杂,那state是一个很大的对象,store对象也将对变得非常大,难于管理 ...
- java创建线程的方法
1.1 创建线程 1.1.1 无返回值的线程创建 package com.first; public class ThreadTest { public static void ma ...
- 类的调用1(被调用的MyFirstJava)
package com.mec.MyFirstJavaLife.text; public class MyFirstJava { /** * @param args */ private in ...
- cocos2dx AudioEngine在Android7上播放音效卡顿问题处理
1.此问题在cocos2dx 3.13/3.14版本(其它版本没有测试过)在Android7中使用AudioEngine的play2d函数播放音效时出现. 调试时出现如下提示: 2.论坛中相关讨论帖地 ...
- Pychram - 使用介绍
Pychram - 使用介绍 PyCharm中Directory与Python package的区别 对于Python而言,有一点是要认识明确的,python作为一个相对而言轻量级的,易用的脚本语言( ...
- Java从内存流中读取byte数组
Java中通过servlet接收二进制数据,然后将二进制数据流读取为byte数组.开始使用:byte[] bs = new byte[request.getContentLength()];reque ...
- MATLAB程序控制结构