
通常見(jiàn)到的還原操作,都是將所有的表空間和數(shù)據(jù)還原到相同的一個(gè)時(shí)間點(diǎn)上,無(wú)論是否是故障恢復(fù)點(diǎn)。而TSPITR則是以表空間為粒度單元,單獨(dú)將某個(gè)表空間內(nèi)容還原到一個(gè)特定可恢復(fù)時(shí)間點(diǎn)上。 舉一個(gè)例子:一個(gè)Oracle數(shù)據(jù)庫(kù)運(yùn)行在歸檔模式下,在夜間22點(diǎn)保留一份
通常見(jiàn)到的還原操作,都是將所有的表空間和數(shù)據(jù)還原到相同的一個(gè)時(shí)間點(diǎn)上,無(wú)論是否是故障恢復(fù)點(diǎn)。而TSPITR則是以表空間為粒度單元,單獨(dú)將某個(gè)表空間內(nèi)容還原到一個(gè)特定可恢復(fù)時(shí)間點(diǎn)上。
舉一個(gè)例子:一個(gè)Oracle數(shù)據(jù)庫(kù)運(yùn)行在歸檔模式下,在夜間22點(diǎn)保留一份完全備份。早上8點(diǎn)時(shí)候,某個(gè)特定表空間上數(shù)據(jù)表(單個(gè)表獨(dú)占表空間)發(fā)生一個(gè)誤操作,數(shù)據(jù)損壞。要求在不傷害其他數(shù)據(jù)表數(shù)據(jù)的情況下,將表空間數(shù)據(jù)恢復(fù)到早上5點(diǎn)。這樣部分?jǐn)?shù)據(jù)恢復(fù)的場(chǎng)景,就是TSPITR的典型應(yīng)用。在實(shí)際場(chǎng)景中,常常希望恢復(fù)部分的數(shù)據(jù)到過(guò)去時(shí)間點(diǎn)上。
TSPITR目前最方便的方法是使用RMAN進(jìn)行自動(dòng)的恢復(fù)。
其使用前提為兩個(gè):
1. 必須存在相應(yīng)【本文來(lái)自鴻網(wǎng)互聯(lián) (http://www.68idc.cn)】的備份集合
2. 表空間對(duì)象是子包含的,也就是其他表空間中不包括與這個(gè)表空間對(duì)象相關(guān)的對(duì)象數(shù)據(jù)(互相獨(dú)立)
恢復(fù)步驟和原理如下:
RMAN三個(gè)對(duì)象集合:catalog、target和auxiliary。其中auxiliary就是用于輔助target各種備份還原要求的操作數(shù)據(jù)庫(kù)。這個(gè)庫(kù)在TSPITR中扮演臨時(shí)數(shù)據(jù)還原作用的;
首先完成數(shù)據(jù)檢查工作,確定備份集合和表空間完整性;
當(dāng)前時(shí)間是T1,如果需要將數(shù)據(jù)還原為T(mén)0。使用RMAN提取備份數(shù)據(jù)集合,還原到auxiliary上形成一個(gè)新的實(shí)例數(shù)據(jù)庫(kù)。選擇性應(yīng)用歸檔日志序列,還原auxiliary到TO時(shí)間點(diǎn);
使用expdp工具從auxiliary中導(dǎo)出目標(biāo)表空間為dump對(duì)象。注意:還原auxiliary并不是100%重建target,而是選擇系統(tǒng)運(yùn)行表空間和目標(biāo)表空間;
在target數(shù)據(jù)庫(kù)中刪除原表空間。使用impdp工具導(dǎo)入dump文件進(jìn)入target數(shù)據(jù)庫(kù);
清理環(huán)境,將創(chuàng)建的auxiliary數(shù)據(jù)庫(kù)刪除。
這種系列操作,如果使用RMAN命令系列是可以逐步完成的。自動(dòng)化RMAN的TSPITR操作也是對(duì)這個(gè)過(guò)程的完全自動(dòng)化運(yùn)行。
下面通過(guò)實(shí)驗(yàn)來(lái)進(jìn)行演示操作:
--創(chuàng)建測(cè)試用戶(hù)zlm并賦予權(quán)限
SQL> create user zlm identified by zlm;
User created.
SQL> grant dba to zlm;
Grant succeeded.
--創(chuàng)建測(cè)試表空間tspitr
SQL> create tablespace tspitr datafile '/data/oradata/ora10g/tspitr01.dbf' size 100m autoextend off extent management local uniform size 1m segment space management auto;
Tablespace created.
--修改用戶(hù)zlm缺省表空間為tspitr
SQL> alter user zlm default tablespace tspitr;
User altered.
SQL> show user
USER is ""
SQL> conn zlm/zlm@ora10g213
Connected.
SQL> !
--創(chuàng)建一個(gè)RMAN備份集
[oracle@bak ~]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Fri Dec 26 16:44:00 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORA10G (DBID=4175411955)
RMAN> backup as compressed backupset database format '/u01/orabackup/backupsets/full_ora10g_%U' plus archive log format '/u01/orabackup/backupsets/arc_ora10g_%U' delete all input;
Starting backup at 26-DEC-14
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=138 devtype=DISK
channel ORA_DISK_1: starting compressed archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=30 recid=30 stamp=867343597
channel ORA_DISK_1: starting piece 1 at 26-DEC-14
channel ORA_DISK_1: finished piece 1 at 26-DEC-14
piece handle=/u01/orabackup/backupsets/arc_ora10g_13pr577g_1_1 tag=TAG20141226T164639 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:04
channel ORA_DISK_1: deleting archive log(s)
archive log filename=/oracle/flash_recovery_area/ORA10G/archivelog/2014_12_26/o1_mf_1_30_b9t83f1s_.arc recid=30 stamp=867343597
Finished backup at 26-DEC-14
Starting backup at 26-DEC-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/data/oradata/ora10g/system01.dbf
input datafile fno=00003 name=/data/oradata/ora10g/sysaux01.dbf
input datafile fno=00002 name=/data/oradata/ora10g/undotbs01.dbf
input datafile fno=00005 name=/data/oradata/ora10g/example01.dbf
input datafile fno=00006 name=/data/oradata/ora10g/tspitr01.dbf
input datafile fno=00004 name=/data/oradata/ora10g/users01.dbf
channel ORA_DISK_1: starting piece 1 at 26-DEC-14
channel ORA_DISK_1: finished piece 1 at 26-DEC-14
piece handle=/u01/orabackup/backupsets/full_ora10g_14pr577l_1_1 tag=TAG20141226T164644 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:47
Finished backup at 26-DEC-14
Starting backup at 26-DEC-14
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=31 recid=31 stamp=867343772
channel ORA_DISK_1: starting piece 1 at 26-DEC-14
channel ORA_DISK_1: finished piece 1 at 26-DEC-14
piece handle=/u01/orabackup/backupsets/arc_ora10g_15pr57ct_1_1 tag=TAG20141226T164933 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: deleting archive log(s)
archive log filename=/oracle/flash_recovery_area/ORA10G/archivelog/2014_12_26/o1_mf_1_31_b9t88wnv_.arc recid=31 stamp=867343772
Finished backup at 26-DEC-14
Starting Control File and SPFILE Autobackup at 26-DEC-14
piece handle=/u01/orabackup/backupsets/ora10g-c-4175411955-20141226-05.ctl comment=NONE
Finished Control File and SPFILE Autobackup at 26-DEC-14
RMAN> exit
Recovery Manager complete.
--連接到測(cè)試用戶(hù)zlm查看當(dāng)前日志
[oracle@bak ~]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Dec 26 16:50:46 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> conn zlm/zlm@ora10g213
Connected.
SQL> select sequence#,status from v$log;
SEQUENCE# STATUS
---------- ----------------
32 CURRENT
30 INACTIVE
31 ACTIVE
--創(chuàng)建測(cè)試表t1,并切換若干次日志
SQL> create table t1 as select * from dba_objects;
Table created.
SQL> alter system switch logfile;
System altered.
SQL> select sequence#,status from v$log;
SEQUENCE# STATUS
---------- ----------------
32 ACTIVE
33 CURRENT
31 ACTIVE
SQL> alter system switch logfile;
System altered.
SQL> select sequence#,status from v$log;
SEQUENCE# STATUS
---------- ----------------
32 ACTIVE
33 ACTIVE
34 CURRENT --此時(shí)仍然時(shí)候數(shù)據(jù)的
SQL> select count(*) from t1;
COUNT(*)
----------
50382
--對(duì)表進(jìn)行truancate操作,模擬誤操作
SQL> truncate table t1;
Table truncated.
SQL> select count(*) from t1;
COUNT(*)
----------
0
SQL> alter system switch logfile;
System altered.
SQL> select sequence#,status from v$log;
SEQUENCE# STATUS
---------- ----------------
35 CURRENT --truncate之后又切換了一次日志,當(dāng)前日志為35
33 ACTIVE
34 ACTIVE
SQL> !
創(chuàng)建表的時(shí)候,logseq是32,之后切換了一次日志,到33,此時(shí)的表中仍然是有數(shù)據(jù)的,但是truncate操作后表中的數(shù)據(jù)就沒(méi)有了,這個(gè)動(dòng)作基本就是在logseq 34的時(shí)候發(fā)生的,truncate完以后又切了日志,到了35,我們實(shí)驗(yàn)的目的就是要把表空間恢復(fù)到logseq=34這個(gè)時(shí)間點(diǎn)(Time In Point)。根據(jù)剛才說(shuō)的那個(gè)例子,就是到故障點(diǎn)8點(diǎn)以前的某個(gè)數(shù)據(jù)未丟失的時(shí)間點(diǎn)(5點(diǎn))
--創(chuàng)建一個(gè)auxiliary目錄(必要步驟)
[oracle@bak ~]$ mkdir /u01/aux
[oracle@bak ~]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Fri Dec 26 16:54:36 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORA10G (DBID=4175411955)
auxiliary目標(biāo)目錄中會(huì)在之后的RMAN腳本執(zhí)行過(guò)程中,生成一些系統(tǒng)恢復(fù)需要的文件,等RMAN恢復(fù)完后會(huì)展示一下這個(gè)目錄的結(jié)構(gòu)。
--最關(guān)鍵的來(lái)了,用RMAN命令進(jìn)行TSPITR恢復(fù)到故障點(diǎn)之前的某個(gè)時(shí)刻
RMAN> recover tablespace tspitr until logseq 33 auxiliary destination '/u01/aux';
Starting recover at 26-DEC-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=159 devtype=DISK
RMAN-05026: WARNING: presuming following set of tablespaces applies to specified point in time
List of tablespaces expected to have UNDO segments --有undo段的表空間列表
tablespace SYSTEM
tablespace UNDOTBS1
Creating automatic instance, with SID='xvBc' --創(chuàng)建一個(gè)自動(dòng)化實(shí)例,隨機(jī)SID為xvBc
initialization parameters used for automatic instance: --為自動(dòng)化實(shí)例分配的參數(shù)
db_name=ORA10G
compatible=10.2.0.1.0
db_block_size=8192
db_files=200
db_unique_name=tspitr_ORA10G_xvBc
large_pool_size=1M
shared_pool_size=110M
#No auxiliary parameter file used
db_create_file_dest=/u01/aux --之前創(chuàng)建的auxiliary目錄
control_files=/u01/aux/cntrl_tspitr_ORA10G_xvBc.f --控制文件的位置
starting up automatic instance ORA10G --啟動(dòng)自動(dòng)化實(shí)例
Oracle instance started
Total System Global Area 201326592 bytes
Fixed Size 1218508 bytes
Variable Size 146802740 bytes
Database Buffers 50331648 bytes
Redo Buffers 2973696 bytes
Automatic instance created
contents of Memory Script: --第1個(gè)內(nèi)存腳本內(nèi)容
{
# set the until clause
set until logseq 33 thread 1; --指定的需要恢復(fù)到的logseq
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone database';
# archive current online log for tspitr to a resent until time
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 26-DEC-14
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=36 devtype=DISK
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /u01/orabackup/backupsets/ora10g-c-4175411955-20141226-05.ctl
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u01/orabackup/backupsets/ora10g-c-4175411955-20141226-05.ctl tag=TAG20141226T164935
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
output filename=/u01/aux/cntrl_tspitr_ORA10G_xvBc.f
Finished restore at 26-DEC-14
sql statement: alter database mount clone database
sql statement: alter system archive log current
sql statement: begin dbms_backup_restore.AutoBackupFlag(FALSE); end;
released channel: ORA_DISK_1
released channel: ORA_AUX_DISK_1
contents of Memory Script: --第2個(gè)內(nèi)存腳本內(nèi)容
{
# generated tablespace point-in-time recovery script
# set the until clause
set until logseq 33 thread 1;
plsql <<<-- tspitr_2
declare
sqlstatement varchar2(512);
offline_not_needed exception;
pragma exception_init(offline_not_needed, -01539);
begin
sqlstatement := 'alter tablespace '|| 'TSPITR' ||' offline for recover';
krmicd.writeMsg(6162, sqlstatement);
krmicd.execSql(sqlstatement);
exception
when offline_not_needed then
null;
end; >>>;
# set an omf destination filename for restore
set newname for clone datafile 1 to new;
# set an omf destination filename for restore
set newname for clone datafile 2 to new;
# set an omf destination tempfile
set newname for clone tempfile 2 to new;
# set a destination filename for restore
set newname for datafile 6 to
"/data/oradata/ora10g/tspitr01.dbf";
# rename all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set plus the auxilliary tablespaces
restore clone datafile 1, 2, 6;
switch clone datafile all;
#online the datafiles restored or flipped
sql clone "alter database datafile 1 online";
#online the datafiles restored or flipped
sql clone "alter database datafile 2 online";
#online the datafiles restored or flipped
sql clone "alter database datafile 6 online";
# make the controlfile point at the restored datafiles, then recover them
recover clone database tablespace "TSPITR", "SYSTEM", "UNDOTBS1" delete archivelog;
alter clone database open resetlogs;
# PLUG HERE the creation of a temporary tablespace if export fails due to lack
# of temporary space.
# For example in Unix these two lines would do that:
#sql clone "create tablespace aux_tspitr_tmp
# datafile ''/tmp/aux_tspitr_tmp.dbf'' size 500K";
}
executing Memory Script
executing command: SET until clause
sql statement: alter tablespace TSPITR offline for recover
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
renamed temporary file 2 to /u01/aux/TSPITR_ORA10G_XVBC/datafile/o1_mf_temp_%u_.tmp in control file
Starting restore at 26-DEC-14
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=39 devtype=DISK
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/aux/TSPITR_ORA10G_XVBC/datafile/o1_mf_system_%u_.dbf
restoring datafile 00002 to /u01/aux/TSPITR_ORA10G_XVBC/datafile/o1_mf_undotbs1_%u_.dbf
restoring datafile 00006 to /data/oradata/ora10g/tspitr01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/orabackup/backupsets/full_ora10g_14pr577l_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u01/orabackup/backupsets/full_ora10g_14pr577l_1_1 tag=TAG20141226T164644
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:02:26
Finished restore at 26-DEC-14
datafile 1 switched to datafile copy
input datafile copy recid=4 stamp=867344300 filename=/u01/aux/TSPITR_ORA10G_XVBC/datafile/o1_mf_system_b9t8nvw3_.dbf
datafile 2 switched to datafile copy
input datafile copy recid=5 stamp=867344300 filename=/u01/aux/TSPITR_ORA10G_XVBC/datafile/o1_mf_undotbs1_b9t8nvx5_.dbf
sql statement: alter database datafile 1 online
sql statement: alter database datafile 2 online
sql statement: alter database datafile 6 online
Starting recover at 26-DEC-14
using channel ORA_AUX_DISK_1
starting media recovery
archive log thread 1 sequence 32 is already on disk as file /oracle/flash_recovery_area/ORA10G/archivelog/2014_12_26/o1_mf_1_32_b9t8dkr8_.arc
channel ORA_AUX_DISK_1: starting archive log restore to default destination
channel ORA_AUX_DISK_1: restoring archive log
archive log thread=1 sequence=31
channel ORA_AUX_DISK_1: reading from backup piece /u01/orabackup/backupsets/arc_ora10g_15pr57ct_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u01/orabackup/backupsets/arc_ora10g_15pr57ct_1_1 tag=TAG20141226T164933
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
archive log filename=/u01/app/oracle/product/10.2.0/db_1/dbs/arch1_31_860802036.dbf thread=1 sequence=31
channel clone_default: deleting archive log(s)
archive log filename=/u01/app/oracle/product/10.2.0/db_1/dbs/arch1_31_860802036.dbf recid=32 stamp=867344306
archive log filename=/oracle/flash_recovery_area/ORA10G/archivelog/2014_12_26/o1_mf_1_32_b9t8dkr8_.arc thread=1 sequence=32
media recovery complete, elapsed time: 00:00:05
Finished recover at 26-DEC-14
database opened
contents of Memory Script: --第3個(gè)內(nèi)存腳本(邏輯導(dǎo)入導(dǎo)出)
{
# export the tablespaces in the recovery set
host 'exp userid =\"/@\(DESCRIPTION=\(ADDRESS=\(PROTOCOL=beq\)\(PROGRAM=/u01/app/oracle/product/10.2.0/db_1/bin/oracle\)\(ARGV0=oraclexvBc\)\(ARGS=^'\(DESCRIPTION=\(LOCAL=YES\)\(ADDRESS=\(PROTOCOL=beq\)\)\)^'\)\(ENVS=^'ORACLE_SID=xvBc^'\)\)\(CONNECT_DATA=\(SID=xvBc\)\)\)
as sysdba\" point_in_time_recover=y tablespaces=
TSPITR file=
tspitr_a.dmp';
# shutdown clone before import
shutdown clone immediate
# import the tablespaces in the recovery set
host 'imp userid =\"/@ as sysdba\" point_in_time_recover=y file=
tspitr_a.dmp';
# online/offline the tablespace imported
sql "alter tablespace TSPITR online";
sql "alter tablespace TSPITR offline";
# enable autobackups in case user does open resetlogs from RMAN after TSPITR
sql 'begin dbms_backup_restore.AutoBackupFlag(TRUE); end;';
}
executing Memory Script
Export: Release 10.2.0.1.0 - Production on Fri Dec 26 16:58:55 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Export done in US7ASCII character set and AL16UTF16 NCHAR character set
server uses ZHS16GBK character set (possible charset conversion)
Note: table data (rows) will not be exported
About to export Tablespace Point-in-time Recovery objects... --執(zhí)行導(dǎo)出TSPITR對(duì)象
For tablespace TSPITR ...
. exporting cluster definitions
. exporting table definitions
. . exporting table T
. . exporting table T1 --導(dǎo)出誤刪除的測(cè)試表
. exporting referential integrity constraints
. exporting triggers
. end point-in-time recovery
Export terminated successfully without warnings. --導(dǎo)出完成無(wú)報(bào)錯(cuò)
host command complete
database closed
database dismounted
Oracle instance shut down
Import: Release 10.2.0.1.0 - Production on Fri Dec 26 16:59:17 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Export file created by EXPORT:V10.02.01 via conventional path
About to import Tablespace Point-in-time Recovery objects...
import done in US7ASCII character set and AL16UTF16 NCHAR character set
import server uses ZHS16GBK character set (possible charset conversion)
. importing SYS's objects into SYS
. importing ZLM's objects into ZLM
. . importing table "T"
. . importing table "T1" --導(dǎo)入誤刪除的測(cè)試表
. importing SYS's objects into SYS
Import terminated successfully without warnings.
host command complete
sql statement: alter tablespace TSPITR online
sql statement: alter tablespace TSPITR offline --最后一步操作是把要恢復(fù)的表空間offline的
sql statement: begin dbms_backup_restore.AutoBackupFlag(TRUE); end;
Removing automatic instance --刪除自動(dòng)化實(shí)例以及相關(guān)文件
Automatic instance removed
auxiliary instance file /u01/aux/cntrl_tspitr_ORA10G_xvBc.f deleted
auxiliary instance file /u01/aux/TSPITR_ORA10G_XVBC/datafile/o1_mf_system_b9t8nvw3_.dbf deleted
auxiliary instance file /u01/aux/TSPITR_ORA10G_XVBC/datafile/o1_mf_undotbs1_b9t8nvx5_.dbf deleted
auxiliary instance file /u01/aux/TSPITR_ORA10G_XVBC/datafile/o1_mf_temp_b9t8t370_.tmp deleted
auxiliary instance file /u01/aux/TSPITR_ORA10G_XVBC/onlinelog/o1_mf_1_b9t8srrv_.log deleted
auxiliary instance file /u01/aux/TSPITR_ORA10G_XVBC/onlinelog/o1_mf_2_b9t8svp8_.log deleted
auxiliary instance file /u01/aux/TSPITR_ORA10G_XVBC/onlinelog/o1_mf_3_b9t8sy5v_.log deleted
Finished recover at 26-DEC-14
RMAN> exit
Recovery Manager complete.
[oracle@bak ~]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Dec 26 17:03:26 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn zlm/zlm@ora10g213
Connected.
SQL> select count(*) from t1;
select count(*) from t1
*
ERROR at line 1:
ORA-00376: file 6 cannot be read at this time
ORA-01110: data file 6: '/data/oradata/ora10g/tspitr01.dbf'
無(wú)法打開(kāi)恢復(fù)的6號(hào)文件,由于最后的操作是把該表空間offline的
SQL> select status from dba_tablespaces where tablespace_name='TSPITR';
STATUS
---------
OFFLINE
--重新將tspitr表空間online
SQL> alter tablespace tspitr online;
Tablespace altered.
SQL> select count(*) from t1;
COUNT(*)
----------
50382
之前誤刪除的測(cè)試表T1的數(shù)據(jù)又回來(lái)了。
最后來(lái)看一下auxiliary目錄結(jié)構(gòu)
[oracle@bak admin]$ cd /u01/aux
[oracle@bak aux]$ ll
total 4
drwxr-x--- 4 oracle oinstall 4096 Dec 26 16:55 TSPITR_ORA10G_XVBC
[oracle@bak aux]$ cd TSPITR_ORA10G_XVBC/
[oracle@bak TSPITR_ORA10G_XVBC]$ ll -lrth
total 8.0K
drwxr-x--- 2 oracle oinstall 4.0K Dec 26 16:59 onlinelog
drwxr-x--- 2 oracle oinstall 4.0K Dec 26 16:59 datafile
[oracle@bak TSPITR_ORA10G_XVBC]$ cd onlinelog/
[oracle@bak onlinelog]$ ll
total 0
[oracle@bak onlinelog]$ cd ..
[oracle@bak TSPITR_ORA10G_XVBC]$ cd datafile
[oracle@bak datafile]$ ll
total 0
[oracle@bak datafile]$
雖然在中間過(guò)程創(chuàng)建了相關(guān)目錄和文件,恢復(fù)結(jié)束以后,只留下了目錄結(jié)構(gòu),文件都被自動(dòng)刪除了
總結(jié):
其實(shí)TSPITR方式是對(duì)整個(gè)表空間的恢復(fù),無(wú)論該表空間上有多少?gòu)埍砘驅(qū)ο螅灰亲园谋砜臻g,就可以使用這種方法來(lái)進(jìn)行恢復(fù)。但是也有局限性,比方說(shuō)要恢復(fù)的表空間上有許多表,也是自包含的表空間,由于某張表的誤刪除,恢復(fù)時(shí)把所有該表空間上表的數(shù)據(jù)回退到故障點(diǎn)之前的某個(gè)時(shí)間點(diǎn),而有時(shí)往往并不想這么做。因此,對(duì)于粒度更細(xì)的精確到表級(jí)別的恢復(fù),TSPITR并非最佳方式,利用閃回特性來(lái)恢復(fù)才是更好的方案。
聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com