实验 表空间时间点恢复TSPITR(Tablespace Point In Time Recovery)
2014-10-10 16:01
537 查看
表空间时间点恢复TSPITR(Tablespace Point In Time Recovery)
不完整恢复必须应用到整个数据库.
TSPITR:依据目标数据库的表空间的一个子集来创建辅助数据库,仅在此子集上执行不完整恢复,
然后使用辅助数据库的表空间来替代目标数据库中的表空间,最终结果看起来好像仅
恢复了和还原了该子集,保持目标数据库其余部分是最新的,手动完成此任务很繁琐.
1 适用于:
(1)在一个逻辑上独立的表空间中,重要表中的行数据受损或被删除;
逻辑上独立指其他表空间中的对象与其不存在索引或父子表关系.
(2)误用ddl更改了表空间中的一个或多个表的结构,因此无法使用闪回表来恢复这些表,比如truncate表
(3)使用purge选项删除了表.
2 不适用:
(1)已删除的表空间
(2)如果重命名的表空间,无法恢复到重命名之前的时间点
3 术语:
目标时间:将表空间恢复到哪个时间点或scn.
恢复集:包含将要予以恢复的表空间的数据文件组.
辅助集:恢复表空间需要的其他数据文件,比如SYSTEM,UNDO,TEMP表空间数据文件
辅助目标:存储辅助集的临时位置,存储辅助文件集的临时位置,包括联机重做日志,归档,和恢复过程中控制文件副本
4 步骤:
(1)使用随机生成的名称自动启动辅助实例
(2)将控制文件还原到辅助实例,加载辅助数据库
(3)将恢复集的数据文件还原到辅助数据库
(4)将辅助集的数据库文件还原到辅助数据库
(5)将辅助集的数据库恢复到期望时间点
(6)从辅助数据库中导出已恢复表空间的字典元数据
(7)将恢复表空间的字典元数据导入到目标数据库
(8)删除所有辅助文件
(9)手动执行,将表空间联机
5 具体实验:
(1)创建测试数据
create tablespace pitr datafile '/u01/app/oracle/oradata/orcln/pitr.dbf' size 10m;
create tablespace pitr_ind datafile '/u01/app/oracle/oradata/orcln/pitr_ind.dbf' size 10m;
create user pr identified by pr default tablespace pitr;
grant connect,resource,dba to pr;
conn pr/pr
create table test (id number);
create index i_test on test(id) tablespace pitr_ind;
insert into test values(1);
commit;
select segment_name,segment_type,tablespace_name from user_segments;
(2)备份:
rman target /
RMAN> backup database plus archivelog;
删除表:
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
select sysdate from dual;
2014-10-10 14:22:03
select dbms_flashback.get_system_change_number from dual;
1121027
truncate table test ;
(3) 检查表空间的依赖性,是否自包含
检查名为test表空间的对象是否依赖其他表空间的任何对象,
以及其他表空间的对象是否依赖test表空间的对象
select * from sys.ts_pitr_check
where (ts1_name in ('PITR','PITR_IND') and ts2_name not in ('PITR','PITR_IND'))
or (ts1_name not in ('PITR','PITR_IND') and ts2_name in ('PITR','PITR_IND'));
select * from sys.ts_pitr_check
where (ts1_name in ('PITR') and ts2_name not in ('PITR'))
or (ts1_name not in ('PITR') and ts2_name in ('PITR'));
确定丢失对象: 可以先导出
select owner, name, tablespace_name,
to_char(creation_time, 'yyyy-mm-dd:hh24:mi:ss')
from ts_pitr_objects_to_be_dropped
where tablespace_name in ('PITR', 'PITR_IND')
and creation_time >
to_date('2014-01-06 03:29:45', 'yyyy-mm-dd:hh24:mi:ss')
order by tablespace_name, creation_time;
将表空间pitr和pitr_ind ofline;
Alter tablespace pitr offline;
Alter tablespace pitr_ind offline;
(4)rman自动执行tspitr
Mkdir /home/oracle/pitr
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
rman target /
sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"';
recover tablespace pitr,pitr_ind until time '2014-10-10 14:22:03' auxiliary destination '/home/oracle/pitr';
或者:
Recover tablespace pitr,pitr_ind until scn 1121027 auxiliary destination '/home/oracle/pitr';
(5)online tablespace
select tablespace_name,status
from dba_tablespaces
where tablespace_name in ('PITR', 'PITR_IND');
alter tablespace pitr online;
alter tablespace pitr_ind online;
conn pr/pr
select * from test;
不完整恢复必须应用到整个数据库.
TSPITR:依据目标数据库的表空间的一个子集来创建辅助数据库,仅在此子集上执行不完整恢复,
然后使用辅助数据库的表空间来替代目标数据库中的表空间,最终结果看起来好像仅
恢复了和还原了该子集,保持目标数据库其余部分是最新的,手动完成此任务很繁琐.
1 适用于:
(1)在一个逻辑上独立的表空间中,重要表中的行数据受损或被删除;
逻辑上独立指其他表空间中的对象与其不存在索引或父子表关系.
(2)误用ddl更改了表空间中的一个或多个表的结构,因此无法使用闪回表来恢复这些表,比如truncate表
(3)使用purge选项删除了表.
2 不适用:
(1)已删除的表空间
(2)如果重命名的表空间,无法恢复到重命名之前的时间点
3 术语:
目标时间:将表空间恢复到哪个时间点或scn.
恢复集:包含将要予以恢复的表空间的数据文件组.
辅助集:恢复表空间需要的其他数据文件,比如SYSTEM,UNDO,TEMP表空间数据文件
辅助目标:存储辅助集的临时位置,存储辅助文件集的临时位置,包括联机重做日志,归档,和恢复过程中控制文件副本
4 步骤:
(1)使用随机生成的名称自动启动辅助实例
(2)将控制文件还原到辅助实例,加载辅助数据库
(3)将恢复集的数据文件还原到辅助数据库
(4)将辅助集的数据库文件还原到辅助数据库
(5)将辅助集的数据库恢复到期望时间点
(6)从辅助数据库中导出已恢复表空间的字典元数据
(7)将恢复表空间的字典元数据导入到目标数据库
(8)删除所有辅助文件
(9)手动执行,将表空间联机
5 具体实验:
(1)创建测试数据
create tablespace pitr datafile '/u01/app/oracle/oradata/orcln/pitr.dbf' size 10m;
create tablespace pitr_ind datafile '/u01/app/oracle/oradata/orcln/pitr_ind.dbf' size 10m;
create user pr identified by pr default tablespace pitr;
grant connect,resource,dba to pr;
conn pr/pr
create table test (id number);
create index i_test on test(id) tablespace pitr_ind;
insert into test values(1);
commit;
select segment_name,segment_type,tablespace_name from user_segments;
(2)备份:
rman target /
RMAN> backup database plus archivelog;
删除表:
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
select sysdate from dual;
2014-10-10 14:22:03
select dbms_flashback.get_system_change_number from dual;
1121027
truncate table test ;
(3) 检查表空间的依赖性,是否自包含
检查名为test表空间的对象是否依赖其他表空间的任何对象,
以及其他表空间的对象是否依赖test表空间的对象
select * from sys.ts_pitr_check
where (ts1_name in ('PITR','PITR_IND') and ts2_name not in ('PITR','PITR_IND'))
or (ts1_name not in ('PITR','PITR_IND') and ts2_name in ('PITR','PITR_IND'));
select * from sys.ts_pitr_check
where (ts1_name in ('PITR') and ts2_name not in ('PITR'))
or (ts1_name not in ('PITR') and ts2_name in ('PITR'));
确定丢失对象: 可以先导出
select owner, name, tablespace_name,
to_char(creation_time, 'yyyy-mm-dd:hh24:mi:ss')
from ts_pitr_objects_to_be_dropped
where tablespace_name in ('PITR', 'PITR_IND')
and creation_time >
to_date('2014-01-06 03:29:45', 'yyyy-mm-dd:hh24:mi:ss')
order by tablespace_name, creation_time;
将表空间pitr和pitr_ind ofline;
Alter tablespace pitr offline;
Alter tablespace pitr_ind offline;
(4)rman自动执行tspitr
Mkdir /home/oracle/pitr
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
rman target /
sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"';
recover tablespace pitr,pitr_ind until time '2014-10-10 14:22:03' auxiliary destination '/home/oracle/pitr';
或者:
Recover tablespace pitr,pitr_ind until scn 1121027 auxiliary destination '/home/oracle/pitr';
(5)online tablespace
select tablespace_name,status
from dba_tablespaces
where tablespace_name in ('PITR', 'PITR_IND');
alter tablespace pitr online;
alter tablespace pitr_ind online;
conn pr/pr
select * from test;
相关文章推荐
- tspitr(tablespace point in time recovery)实验
- tspitr(tablespace point in time recovery)实验
- Tablespace Point-in-Time Recovery--关于表空间即时点恢复
- Oracle database TSPITR(TableSpace Point-In-Time Recovery) 表空间基于时间点的恢复
- TSPITR:Tablespace Point-in-Time Recovery实例
- 11g Release 2 enhanced Tablespace Point In Time Recovery
- TSPITR:Tablespace Point-in-Time Recovery表空间不完全恢复
- 11g Release 2 enhanced Tablespace Point In Time Recovery
- RMAN Tablespace Point-in-Time Recovery (TSPITR)
- 7.5 Point-in-Time (Incremental) Recovery Using the Binary Log 使用binay log 基于时间点恢复
- Oracle Tablespace Point-in-Time Recovery (TSPITR)
- RMAN Table Point In Time Recovery (PITR) in PDBs
- Performing RMAN Tablespace Point-in-time Recovery(TSPITR)
- 实验表空间时间点恢复(TSPITR)
- 7.5 Point-in-Time (Incremental) Recovery Using the Binary Log 使用binay log 基于时间点恢复
- Complete, Incomplete and Point-In-Time Recovery【每日一译】--2012-11-09
- MySQL backup and point in time recovery with binary logs
- 表空间时间点恢复(TSPITR)简介
- Oracle 表空间时间点恢复 (TSPITR)
- 【12C考题精解】OCP 1z0-060 QUESTION 8: Recovery of a Tablespace in the CDB