设为首页 加入收藏

TOP

Oracle RMAN实现“一键式”表空间TSPITR(一)
2015-11-10 12:17:39 来源: 作者: 【 】 浏览:18
Tags:Oracle RMAN 实现 空间 TSPITR

在实际业务场景中,相对比“天塌地陷”的全库恢复场景,单Schema、单Tablespace甚至单数据表的局部恢复更加有施展的空间。出现误操作的时候,用户往往希望一个或者部分数据表恢复到过去的一个时间点。同时又不希望将全库恢复到过去时间,丢失部分数据。


RMAN提供了一种实现所谓TSPITR(Tablespace Point-In-Time Recovery)的技术,通过简单的一个语句,就可以在主库不停库(很吸引人)的情况下,利用备份集和连续的归档日志,实现表空间级别的定点恢复。


本篇主要介绍进行RMAN TSPITR操作的步骤方法和一些技术细节点,供需要的朋友待查。


1、环境背景介绍


笔者选择Oracle 11g进行试验,具体版本为11.2.0.4版本。数据库模式为归档模式。


SQL> select * from v$version;


BANNER


--------------------------------------------------------------------------------


Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - Production


PL/SQL Release 11.2.0.4.0 - Production


CORE? ? 11.2.0.4.0 Production


TNS for Linux: Version 11.2.0.4.0 - Production


NLSRTL Version 11.2.0.4.0 - Production


SQL> archive log list;


Database log mode? ? ? ? ? ? ? Archive Mode


Automatic archival? ? ? ? ? ? Enabled


Archive destination? ? ? ? ? ? USE_DB_RECOVERY_FILE_DEST


Oldest online log sequence? ? 5


Next log sequence to archive? 8


Current log sequence? ? ? ? ? 8


尝试构建一个全新schema,在一个全新的tablespace中。实验数据选择scott用户的数据。


SQL> create tablespace testtbl datafile size 10m autoextend on extent management local uniform size 1m segment space management auto;


Tablespace created


SQL> create user test identified by test default tablespace testtbl;


User created


SQL> grant resource, connect to test;


Grant succeeded


使用之前导出的scott数据,进行remap导入。


[oracle@SimpleLinux ~]$ impdp \"/ as sysdba\" dumpfile=scott_20150618.dmp remap_schema=scott:test remap_tablespace=users:testtbl


Import: Release 11.2.0.4.0 - Production on Thu Jun 18 09:50:17 2015


Copyright (c) 1982, 2011, Oracle and/or its affiliates.? All rights reserved.


Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - Production


With the Partitioning, Oracle Label Security, OLAP, Data Mining


and Real Application Testing options


Master table "SYS"."SYS_IMPORT_FULL_01" successfully loaded/unloaded


(篇幅原因,有省略……)


Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT


Processing object type SCHEMA_EXPORT/POST_SCHEMA/PROCACT_SCHEMA


Job "SYS"."SYS_IMPORT_FULL_01" completed with 1 error(s) at Thu Jun 18 09:50:28 2015 elapsed 0 00:00:08


SQL> select owner ,tablespace_name, count(*) from dba_segments where owner='TEST' group by owner, tablespace_name;


OWNER? ? TABLESPACE_NAME? ? ? ? ? ? ? ? ? COUNT(*)


------------------------------ ------------------------------ ----------


TEST? ? ? ? TESTTBL? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 5


两个数据表。


SQL> select count(*) from test.emp;


? COUNT(*)


----------


? ? ? ? 14


SQL> select count(*) from test.dept;


? COUNT(*)


----------


? ? ? ? 4


2、数据备份和故障发生


归档模式下,需要有一份完全的备份,才能实现恢复操作。


RMAN> backup database plus archivelog delete input;


Starting backup at 18-JUN-15


current log archived


allocated channel: ORA_DISK_1


channel ORA_DISK_1: SID=47 device type=DISK


(篇幅原因,有省略…….)


Starting Control File and SPFILE Autobackup at 18-JUN-15


piece handle=/u01/app/fast_recovery_area/ORA11G/autobackup/2015_06_18/o1_mf_s_882701042_br4d3m3c_.bkp comment=NONE


Finished Control File and SPFILE Autobackup at 18-JUN-15


SQL> select group#, sequence# from v$log where status='CURRENT';


? ? GROUP#? SEQUENCE#


---------- ----------


? ? ? ? 2? ? ? ? 17


此时,操作时间为:


SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') a from dual;


A


--------------------


2015-06-18 10:51:19


? ? ? ? ? ? ? ? ? ? ? ? ? ?


过了几个小时,误操作发生。


SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') a from dual;


A


--------------------


2015-06-18 13:47:29


SQL> select group#, sequ

首页 上一页 1 2 3 4 5 6 下一页 尾页 1/6/6
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇使用Linux Strace跟踪调试Oracle.. 下一篇使用Flashback Database进行数据..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: