- 最后登录
- 2017-5-4
- 在线时间
- 81 小时
- 威望
- 999
- 金钱
- 2391
- 注册时间
- 2013-9-11
- 阅读权限
- 150
- 帖子
- 1124
- 精华
- 5
- 积分
- 999
- UID
- 1220
|
3#
发表于 2017-4-26 11:53:26
本帖最后由 biotwang 于 2017-8-7 14:21 编辑
Oracle 使用TSPITR恢复被drop表空间的步骤
如果自己搞不定可以找诗檀软件专业ORACLE数据库修复团队成员帮您恢复!
诗檀软件专业数据库修复团队
服务热线 : 13764045638 QQ号:47079569 邮箱:service@parnassusdata.com
适用于:
Oracle Database – Enterprise Edition – 版本11.2.0.1 及以上
本文信息适用于任何平台。
目的
使用TSPITR恢复被drop表空间。
范围
RMAN自动Tablespace Point-In-Time Recovery ( TSPITR)使你能快速恢复在Oracle数据库中一个或多个表空间到较早的时间,而不影响数据库中的其他表空间和其他对象的状态。
在11.2版本之前,TSPITR有无法恢复被drop表空间的限制。
从11.2起不再有该限制。我们可以使用TSPITR恢复被drop表空间。
以下示例显示TSPITR恢复被drop表空间的步骤和功能。
详情
示例:
1) 创建一个表空间。
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) 创建一个用户并在新表空间中创建一个表。
SQL> create user tiger identified by tiger;
SQL> grant dba to tiger;
SQL> conn tiger/tiger
SQL> create table objects tablespace users as select * from dba_objects ;
SQL> select count(*) from objects;
COUNT(*)
----------
17299
3) 记录当前日志序列号。
SQL > select sequence# from v$log where status='CURRENT';
SEQUENCE#
----------
21
4) 对数据库和归档日志进行备份。
% rman target /
RMAN> backup database plus archivelog;
5) 现在登录到数据库,仅执行一些日志切换,然后drop表空间。
SQL> alter system switch logfile;
SQL> alter system switch logfile;
SQL> drop tablespace users including contents and datafiles;
6) 现在记下数据库中当前日志序列号。
SQL> select SEQUENCE# from v$log where status='CURRENT';
SEQUENCE#
----------
25
7)当表空间被drop时,数据库中的序列号是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
executing Memory Script
database closed
database dismounted
8) 这里,rman使用可传输表空间机制将被drop表空间重新插入数据库。
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) 联机表空间。
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 |
|