根據表空間的TSPITR恢復

lsl031發表於2007-09-02


一般而言,資料庫如果需要不完全恢復,那麼整個資料庫都是要利用備份來前滾和回滾的(untill子句)。是造成資料損失的。

1.建立輔助資料庫aux:

set ORACLE_SID=aux

新建一個目錄,以存入輔助資料庫aux


mkdir F:auxdb


(2)

(3) oradim –new –sid aux -USRPWD jos -INTPWD jos

查詢獲取再要恢復的時間後是否還有其他物件的生成,切記恢復侯這些資料是會丟失的。

SELECT owner, name, tablespace_name, to_char(creation_time, 'YYYY-MM-DD:HH24:MI:SS')
FROM sys.ts_pitr_objects_to_be_dropped
WHERE tablespace_name IN ('POOLDB_MEDIUM')
AND creation_time > to_date('2002-MAY-29:11:50:00','YYYY-MON-DD:HH24:MI:SS')
ORDER BY tablespace_name, creation_time(依據物件建立時間來查)


Determine the relationships between objects that overlap the recovery boundaries by querying
TS_PIRT_CHECK view, if it returns rows, solve the problem then proceed.

SELECT * FROM sys.ts_pitr_check WHERE (ts1_name IN ('TS1','TS2') AND ts2_name NOT IN ('TS1','TS2')) OR (ts1_name NOT IN

('TS1','TS2') AND ts2_name IN ('TS1','TS2'));

In this case, TS1=POOLDB_MEDIUM, and there is TS2. If the query returns rows, add the returned
Tablespace name to the in list till no row returns, then proceed to solve the problem before continue


2.加入監聽設定和網路連線配置。


lisner檔案中: (SID_DESC =


(GLOBAL_DBNAME = aux)


(ORACLE_HOME = F:auxdb)


(SID_NAME = aux)


)

tnsname檔案中

aux =


(DESCRIPTION =


(ADDRESS_LIST =


(ADDRESS = (PROTOCOL = TCP)(HOST = rainny-eb128e61)(PORT = 1521))


)


(CONNECT_DATA =


(SERVER = DEDICATED)


(SERVICE_NAME = aux)


)


)


4.複製一份initsid.ora引數檔案和所有控制檔案到aux存入的目錄f:auxdb,重新命名為initaux.ora,並修改內容,在此例中,目標資料是

rainny,RMAN CATALOG資料庫是OEMREP,輔助資料庫是aux.注意:


DB_NAME

和目標資料庫相同,此例為rainny


LOCK_NAME_SPACE

如果是輔助資料庫和目標資料庫是同一臺機器,則設值為:_目標資料庫名,此例為:_rainny


DB_FILE_NAME_CONVERT

實際就是目標資料庫和輔助資料的對應目錄,如目標資料庫資料檔案目錄為: D:oracle_homeoradatarainny,輔助資料庫名錄為: F:auxdb,則此

引數值可設為如下:


db_file_name_convert=("D:oracle_homeoradatarainny","F:auxdb")


LOG_FILE_NAME_CONVERT

同上


CONTROL_FILES

目標資料有多少個控制檔案,這裡也要設多少個,只不過目錄改成輔助資料庫的目錄,檔案相同.此例設值為:


control_files=("F:auxdbCONTROL01.CTL","F:auxdbCONTROL02.CTL",


"F:auxdbCONTROL03.CTL")


REMOTE_LOGIN_PASSWORDFILE

設成:EXCLUSIVE


COMPATIBLE

與目標資料庫相同


DB_BLOCK_SIZE

與目標資料庫相同


對主資料庫的準備,包括將日誌歸檔。對包含有待恢復的表空間的回滾段offline,對該表空間本身offline。同時生成控制檔案的生成指令碼

alter system backup controlfile TO TRACE,以便輔助資料庫可以由此來重新對應資料檔案的位置等。

5.在sqlplus中以nomount方式啟輔助資料庫例項


C:>SQLPLUS /NOLOG
SQL> CONN AS SYSDBA;


Connected to an idle instance


SQL> startup nomount pfile='F:auxdbinitaux.ora';


ORACLE instance started.


Total System Global Area 135338868 bytes


Fixed Size 453492 bytes


Variable Size 109051904 bytes


Database Buffers 25165824 bytes


Redo Buffers 667648 bytes


6.在進行表空間時間點恢復之前,首先你要有想要恢復到那個時間點的資料庫備份集,否則,無法進行時間點恢復.


7.連到rman

可以先由控制檔案生成語句為輔助資料建立控制檔案(nomount下)。

再start mount下recover database using backup controlfile until time ‘2002-08-13:17:12:00’;

alter database open resetlogs;

在open下exp 'sys/sys as sysdba' point_in_time_recover=y tablespaces=pooldb_medium
file=exptest.dmp’
( if you got ora-3217, then you are hit a bug which is fixed in 9I, work around: drop
temp tablespace)

把輔助庫的檔案置為離線且複製該檔案到主庫目錄。
以下步驟不知道對否。
C:>rman target catalog auxiliary


RMAN> recover tablespace APP01 UNTIL TIME "TO_DATE('2006/12/22 12:00:00','YYYY/MM/DD HH24:MI:SS')";


Ok,現在就開始進行表空間的時間點恢復啦!

在主庫上執行:
imp 'sys/sys as sysdba' point_in_time_recover=y tablespaces=pooldb_medium file=exptest.dmp
再將表空間置為online的即可。

不過,到了oracle10g,可不用這麼麻煩了,我們會首先選擇database flashback,將整個資料庫rollback到某一個時間點,而不是表空間時間點恢復.

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/288166/viewspace-967585/,如需轉載,請註明出處,否則將追究法律責任。

相關文章