Steps To Recover A Dropped Tablespace Using TSPITR (Doc ID 1277795.1)

APPLIES TO:

Oracle Database - Enterprise Edition - Version 11.2.0.1 and later
Information in this document applies to any platform.
*** Checked for relevance on 16-NOV-2015 ***

PURPOSE

Recover a dropped tablespace using TSPITR.  使用TSPITR恢复删除的表空间

SCOPE

RMAN automatic Tablespace Point-In-Time Recovery ( TSPITR) enables you to quickly recover one or more tablespaces in an Oracle database to an earlier time, without affecting the state of the rest of the tablespaces and other objects in the database.

RMAN 自动表空间时间点恢复(TSPITR)使您可以将 Oracle 数据库中的一个或多个表空间快速恢复到更早的时间,而又不影响数据库中其余表空间和其他对象的状态。

Prior to 11.2 version the TSPITR had a restriction of not being able to recover the dropped tablespace.

在11.2版之前,TSPITR受到限制,无法恢复删除的表空间。

From 11.2 this limitation no longer exists. We can recover the dropped tablespace using TSPITR.

从11.2开始,此限制不再存在。我们可以使用TSPITR恢复删除的表空间

The below example is an attempt to show the steps and functioning of TSPITR to recover a dropped tablespace.

下面的示例尝试显示TSPITR恢复丢失的表空间的步骤和功能。

DETAILS

NOTE: In the images and/or the document content below, the user information and environment data used represents fictitious data from the Oracle sample schema(s), Public Documentation delivered with an Oracle database product or other training material. Any similarity to actual environments, actual persons, living or dead, is purely coincidental and not intended in any manner.

Example:

Target db name : ORA11G

1) Create a tablespace.

SQL> create tablespace users datafile 'D:\DATABASES\ORA11G\users01.dbf' size 10m reuse;

SQL> select tablespace_name from dba_tablespaces;

TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
TEMP
USERS

2) Create a user and create a table in the new tablespace.

SQL> create user tiger identified by <password>;
SQL> grant dba to tiger;
SQL> conn tiger/<password>
SQL> create table objects tablespace users as select * from dba_objects ;
SQL> select count(*) from objects; COUNT(*)
----------
17299

3) Make a note of the current log sequence number.  记下当前的日志序列号

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

SEQUENCE#
----------
21

4) Take a backup of the database and the archivelogs.  备份数据库和归档日志

% rman target /
RMAN> backup database plus archivelog;

5) Now login to the database and just perform a few log switches and then drop the tablespace. 现在登录数据库,仅执行一些日志切换,然后删除表空间

SQL> alter system switch logfile;
SQL> alter system switch logfile;
SQL> drop tablespace users including contents and datafiles;

6) Now note down the current log sequence number in the database.  现在记下数据库中当前的日志序列号

SQL> select SEQUENCE# from v$log where status='CURRENT';

SEQUENCE#
----------
25

7) The log sequence number in the database when the tablespace was dropped is 25. So if we recover upto sequence 24 then we will be able to get the tablespace back. To recover upto sequence 24 we have use 24+1=25 in the set until clause of the TSPITR statement.

删除表空间后,数据库中的日志序列号为25。因此,如果我们恢复到序列24,则可以取回表空间。为了恢复到序列24,我们在TSPITR语句的 set until 子句中使用24 + 1 = 25

% rman target /
RMAN> recover tablespace users until logseq 25 auxiliary destination 'd:\';
Starting recover at 03-JAN-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=15 device type=DISK
RMAN-05026: WARNING: presuming following set of tablespaces applies to specified point-in-time List of tablespaces expected to have UNDO segments
Tablespace SYSTEM
Tablespace UNDOTBS1 Creating automatic instance, with SID='nyxF'
initialization parameters used for automatic instance:
db_name=ORA11G
db_unique_name=nyxF_tspitr_ORA11G
compatible=11.2.0.0.0
db_block_size=8192
db_files=200
sga_target=280M
processes=50
db_create_file_dest=d:\
log_archive_dest_1='location=d:\'
#No auxiliary parameter file used starting up automatic instance ORA11G Oracle instance started
Total System Global Area 292933632 bytes
Fixed Size 1374164 bytes
Variable Size 100665388 bytes
Database Buffers 184549376 bytes
Redo Buffers 6344704 bytes
Automatic instance created List of tablespaces that have been dropped from the target database:
Tablespace users contents of Memory Script:
{
# set requested point in time
set until logseq 25 thread 1;
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone database';
# archive current online log
sql 'alter system archive log current';
# avoid unnecessary autobackups for structural changes during TSPITR
sql 'begin dbms_backup_restore.AutoBackupFlag(FALSE); end;';
}
executing Memory Script
executing command: SET until clause Starting restore at 03-JAN-11
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=59 device type=DISK channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece D:\DATABASES\ORA11G\FRA\ORA11G\BACKUPSET\2011_01_03\O1_MF_NCSNF_TAG20110103T092723_6L2LB86C_.BKP
channel ORA_AUX_DISK_1: piece handle=D:\DATABASES\ORA11G\FRA\ORA11G\BACKUPSET\2011_01_03\O1_MF_NCSNF_TAG20110103T092723_6L2LB86C_.BKP tag=TAG20110103T092723
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=D:\ORA11G\CONTROLFILE\O1_MF_6L2M39N0_.CTL
Finished restore at 03-JAN-11 sql statement: alter database mount clone database
sql statement: alter system archive log current
sql statement: begin dbms_backup_restore.AutoBackupFlag(FALSE); end; contents of Memory Script:
{
# set requested point in time
set until logseq 25 thread 1;
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile 1 to new;
set newname for clone datafile 3 to new;
set newname for clone datafile 2 to new;
set newname for clone tempfile 1 to new;
set newname for datafile 4 to
"D:\DATABASES\ORA11G\USERS01.DBF";
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile 1, 3, 2, 4;
switch clone datafile all;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
renamed tempfile 1 to D:\ORA11G\DATAFILE\O1_MF_TEMP_%U_.TMP in control file Starting restore at 03-JAN-11
using channel ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to D:\ORA11G\DATAFILE\O1_MF_SYSTEM_%U_.DBF
channel ORA_AUX_DISK_1: restoring datafile 00003 to D:\ORA11G\DATAFILE\O1_MF_UNDOTBS1_%U_.DBF
channel ORA_AUX_DISK_1: restoring datafile 00002 to D:\ORA11G\DATAFILE\O1_MF_SYSAUX_%U_.DBF
channel ORA_AUX_DISK_1: restoring datafile 00004 to D:\DATABASES\ORA11G\USERS01.DBF
channel ORA_AUX_DISK_1: reading from backup piece D:\DATABASES\ORA11G\FRA\ORA11G\BACKUPSET\2011_01_03\O1_MF_NNNDF_TAG20110103T092723_6L2L941Y_.BKP
channel ORA_AUX_DISK_1: piece handle=D:\DATABASES\ORA11G\FRA\ORA11G\BACKUPSET\2011_01_03\O1_MF_NNNDF_TAG20110103T092723_6L2L941Y_.BKP tag=TAG20110103T092723
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 03-JAN-11 datafile 1 switched to datafile copy
input datafile copy RECID=12 STAMP=739446137 file name=D:\ORA11G\DATAFILE\O1_MF_SYSTEM_6L2M3MRW_.DBF
datafile 3 switched to datafile copy
input datafile copy RECID=13 STAMP=739446137 file name=D:\ORA11G\DATAFILE\O1_MF_UNDOTBS1_6L2M3N8S_.DBF
datafile 2 switched to datafile copy
input datafile copy RECID=14 STAMP=739446137 file name=D:\ORA11G\DATAFILE\O1_MF_SYSAUX_6L2M3N1G_.DBF contents of Memory Script:
{
# set requested point in time
set until logseq 25 thread 1;
# online the datafiles restored or switched
sql clone "alter database datafile 1 online";
sql clone "alter database datafile 3 online";
sql clone "alter database datafile 2 online";
sql clone "alter database datafile 4 online";
# recover and open resetlogs
recover clone database tablespace "USERS", "SYSTEM", "UNDOTBS1", "SYSAUX" delete archivelog;
alter clone database open resetlogs;
}
executing Memory Script executing command: SET until clause
sql statement: alter database datafile 1 online
sql statement: alter database datafile 3 online
sql statement: alter database datafile 2 online
sql statement: alter database datafile 4 online Starting recover at 03-JAN-11
using channel ORA_AUX_DISK_1 starting media recovery archived log for thread 1 with sequence 22 is already on disk as file D:\DATABASES\ORA11G\FRA\ORA11G\ARCHIVELOG\2011_01_03\O1_MF_1_22_6L2LB9M1_.ARC
archived log for thread 1 with sequence 23 is already on disk as file D:\DATABASES\ORA11G\FRA\ORA11G\ARCHIVELOG\2011_01_03\O1_MF_1_23_6L2LPHCQ_.ARC
archived log for thread 1 with sequence 24 is already on disk as file D:\DATABASES\ORA11G\FRA\ORA11G\ARCHIVELOG\2011_01_03\O1_MF_1_24_6L2LPQ2G_.ARC
archived log file name=D:\DATABASES\ORA11G\FRA\ORA11G\ARCHIVELOG\2011_01_03\O1_MF_1_22_6L2LB9M1_.ARC thread=1 sequence=22
archived log file name=D:\DATABASES\ORA11G\FRA\ORA11G\ARCHIVELOG\2011_01_03\O1_MF_1_23_6L2LPHCQ_.ARC thread=1 sequence=23
archived log file name=D:\DATABASES\ORA11G\FRA\ORA11G\ARCHIVELOG\2011_01_03\O1_MF_1_24_6L2LPQ2G_.ARC thread=1 sequence=24
media recovery complete, elapsed time: 00:00:04
Finished recover at 03-JAN-11 database opened contents of Memory Script:
{
# make read only the tablespace that will be exported
sql clone 'alter tablespace USERS read only';
# create directory for datapump import
sql "create or replace directory TSPITR_DIROBJ_DPDIR as ''
d:\''";
# create directory for datapump export
sql clone "create or replace directory TSPITR_DIROBJ_DPDIR as ''
d:\''";
}
executing Memory Script sql statement: alter tablespace USERS read only
sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''d:\''
sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''d:\'' Performing export of metadata...
EXPDP> Starting "SYS"."TSPITR_EXP_nyxF":
EXPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
EXPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE
EXPDP> Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
EXPDP> Master table "SYS"."TSPITR_EXP_nyxF" successfully loaded/unloaded
EXPDP> ******************************************************************************
EXPDP> Dump file set for SYS.TSPITR_EXP_nyxF is:
EXPDP> D:\TSPITR_NYXF_54517.DMP
EXPDP> ******************************************************************************
EXPDP> Datafiles required for transportable tablespace USERS:
EXPDP> D:\DATABASES\ORA11G\USERS01.DBF
EXPDP> Job "SYS"."TSPITR_EXP_nyxF" successfully completed at 09:43:07
Export completed contents of Memory Script:
{
# shutdown clone before import
shutdown clone immediate
}
executing Memory Script database closed
database dismounted
Oracle instance shut down Performing import of metadata...
IMPDP> Master table "SYS"."TSPITR_IMP_nyxF" successfully loaded/unloaded
IMPDP> Starting "SYS"."TSPITR_IMP_nyxF":
IMPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
IMPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE
IMPDP> Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
IMPDP> Job "SYS"."TSPITR_IMP_nyxF" successfully completed at 09:43:29
Import completed contents of Memory Script:
{
# make read write and offline the imported tablespaces
sql 'alter tablespace USERS read write';
sql 'alter tablespace USERS offline';
# enable autobackups after TSPITR is finished
sql 'begin dbms_backup_restore.AutoBackupFlag(TRUE); end;';
}
executing Memory Script sql statement: alter tablespace USERS read write
sql statement: alter tablespace USERS offline
sql statement: begin dbms_backup_restore.AutoBackupFlag(TRUE); end; Removing automatic instance
Automatic instance removed
auxiliary instance file D:\ORA11G\DATAFILE\O1_MF_TEMP_6L2M5G8S_.TMP deleted
auxiliary instance file D:\ORA11G\ONLINELOG\O1_MF_3_6L2M5CJM_.LOG deleted
auxiliary instance file D:\ORA11G\ONLINELOG\O1_MF_2_6L2M5BNZ_.LOG deleted
auxiliary instance file D:\ORA11G\ONLINELOG\O1_MF_1_6L2M59N0_.LOG deleted
auxiliary instance file D:\ORA11G\DATAFILE\O1_MF_SYSAUX_6L2M3N1G_.DBF deleted
auxiliary instance file D:\ORA11G\DATAFILE\O1_MF_UNDOTBS1_6L2M3N8S_.DBF deleted
auxiliary instance file D:\ORA11G\DATAFILE\O1_MF_SYSTEM_6L2M3MRW_.DBF deleted
auxiliary instance file D:\ORA11G\CONTROLFILE\O1_MF_6L2M39N0_.CTL deleted
Finished recover at 03-JAN-11

8) Here rman uses transportable tablespace mechanism to plug the dropped tablespace back in to the database.

这里RMAN使用传输表空间将表空间重新插入数据库

SQL> select tablespace_name,status,plugged_in from dba_tablespaces;

TABLESPACE_NAME     STATUS   PLU
---------------- ------- ---
SYSTEM ONLINE NO
SYSAUX ONLINE NO
UNDOTBS1 ONLINE NO
TEMP ONLINE NO
USERS OFFLINE YES ===> Plugged_in is YES.

9) Online the tablespace.

SQL > alter tablespace users online;

10) Check for the data.

SQL> conn tiger/tiger
SQL> select count(*) from objects; COUNT(*)
----------
17299

REFERENCES

NOTE:455865.1 - How to Recover a Drop Tablespace with RMAN

使用 TSPITR 恢复删除的表空间的步骤 (Doc ID 1277795.1)的更多相关文章

  1. 12C-使用跨平台增量备份减少可移动表空间的停机时间 (Doc ID 2005729.1)

    12C - Reduce Transportable Tablespace Downtime using Cross Platform Incremental Backup (Doc ID 20057 ...

  2. ORACLE修改用户表所属表空间的步骤

    ORACLE修改用户表所属表空间的步骤 使用脚本进行修改.据目前所了解,正长情况下需要修改表的空间和表的索引的空间,如果涉及到BOLB字段的表,修改的方式又不一样了!正常情况下的修改脚本:1.修改表的 ...

  3. oracle 10g将数据导入到指定表空间的步骤

    --创建临时表空间 create temporary tablespace  yhtemp tempfile 'D:/oracle/oradata/Oracle10g/yhtemp.dbf' size ...

  4. 六分钟学会创建Oracle表空间的步骤

    经过长时间学习创建Oracle表空间,于是和大家分享一下,看完本文你肯定有不少收获,希望本文能教会你更多东西. 1.先查询空闲空间 select tablespace_name,file_id,blo ...

  5. oracle 删除表空间TABLESPACE步骤及注意项

    告诉大家,我喜欢通过toad for oralce来实现对oracle数据库的操作. 1.首先通过数据库管理员用户以SYSDBA身份登录.比如使用sys用户去登录 2.查看和记录待删除表空间所在的物理 ...

  6. [转载]Oracle修改用户表所属表空间的步骤

    1 .修改表的空间alter table TABLE_NAME move tablespace TABLESPACENAME 查询当前用户下的所有表选择'alter table'|| table_na ...

  7. UNDO表空间切换步骤

    1.新建UNDO表空间 create undo tablespace UNDOTBS2 datafile '/data01/testdb/undotbs01.dbf' size 1G; alter d ...

  8. Master Note: Undo 空间使用率高 (Doc ID 1578639.1)

    Master Note: High Undo Space Usage (Doc ID 1578639.1) APPLIES TO: Oracle Database Cloud Schema Servi ...

  9. 如何获取表增长历史记录信息? (Doc ID 1395195.1)

    How To Get Table Growth History Information? (Doc ID 1395195.1) APPLIES TO: Oracle Database - Enterp ...

随机推荐

  1. js解决客户端与服务器时间不一致的问题

    引出 最近在写一个项目时,要根据时间进行不同的展示,直接用new Date().getTime()获取当前时间,结果就出问题了.有些用户擅自修改自己的本地时间,导致获取到的时间并不是当前时间,尴尬. ...

  2. IT兄弟连 HTML5教程 DIV+CSS网站首页布局示例

    首页的设计直接影响网站的整体形象,虽然没有一个统一的规范,但最好将其设计为大众化的,只要信息内容能够合理地编排即可,使用户可以方便地找到需要的信息.另外,首页的高度最好不要超过三个屏幕,页面中使用的颜 ...

  3. IT兄弟连 HTML5教程 CSS3属性特效 CSS3背景

    CSS3规范中对背景这一部分,新加入了一些有用的功能,如可以设置多个背景图片.可以指定背景大小.设置背景渐变等功能.CSS3规范中定义的背景属性新增了background-clip.backgroun ...

  4. 东芝半导体最新ARM开发板——TT_M3HQ开箱评测

    前言 最近从面包板社区申请到一块东芝最新ARM Cortex-M3内核的开发板--TT_M3HQ,其实开发板收到好几天了,这几天一直在构思怎么来写这第一篇评测文章,看大家在社区也都发了第一篇评测,我也 ...

  5. ElementUI table 点击编辑按钮进行编辑实现示例

    <!DOCTYPE html> <html > <head> <meta charset="UTF-8"> <meta nam ...

  6. 线程优先级,设置,setPriority()方法

    package seday08.thread;/** * @author xingsir * 线程优先级 * 线程启动后纳入到线程调度,线程时刻处于被动获取CPU时间片而无法主动获取.我们可以通过调整 ...

  7. CAD制图初学入门如何学好CAD?CAD大神总结5点诀窍,必须收藏

    现在有很多的小伙伴们都加入到了CAD这个大家庭中,一开始都是都是一脸懵的状态,更不知要从何入手! 小编才开始也是,但是只要掌握好CAD的技巧和脊髓,一切都不是事.CAD大神总结5点诀窍,悄悄告诉你,必 ...

  8. 剑指offer笔记面试题3----数组中重复的数字

    题目一:找出数组中重复的数字.在一个长度为n的数组里的所有数字都在0~n-1的范围内.数组中某些数字是重复的,但不知道有几个数字重复了,也不知道每个数字重复了几次.请找出数组中任意一个重复的数字.例如 ...

  9. Pumpkin Raising Walk Through

    概述: 这个靶机的规则是根据提示获取南瓜的seed,然后根据一次获取的seed 登录服务器并完成提权,里面涉及到一些CTF的知识,加密解密,提权! 主机端口扫描: ╰─ nmap -p1-65535 ...

  10. Android 项目优化(二):启动页面优化

    一.启动页黑屏的问题 1.1 问题现象描述 Android App 启动页面黑屏的问题,现象表现为:Android 开发 App 启动时若没有做特殊处理的话,会出现一瞬间的白屏现象.即使启动页界面就加 ...