Making User-Managed Backups-17.3、Making User-Managed Backups of Offline Tablespaces and Datafiles
17.3、Making User-Managed Backups of Offline Tablespaces and Datafiles
備份離線的表空間時。須要註意下面指導原則:
(1)不能離線system表空間或活動回滾段的表空間
(2)如果一個表在表空間x中,它的索引在表空間y中。y離線,x在線,當運行dml語句時會報錯。
備份離線表空間:
(1)備份表空間前,查詢dba_data_files識別表空間的數據文件。
(2)盡量使用normal選項離線表空間。由於它確保把表空間置為在線時不須要恢復
(3)備份離線的數據文件
(4)把表空間置為在線
註意:假設使用temporary或immediate優先,僅僅有完畢表空間恢復才幹把表空間置為在線
(5)歸檔未歸檔的重做日誌
SQL> alter system archive log current;
模擬1、把表空間testtbs01離線。然後備份離線的數據文件
(1)
SQL> col file_name for a40
SQL> select tablespace_name,file_name from dba_data_files where tablespace_name=‘TESTTBS01‘;
TABLESPACE_NAME FILE_NAME
------------------------------ ----------------------------------------
TESTTBS01 /oracle/oradata/boss/testtbs01_01.dbf
TESTTBS01 /oracle/oradata/boss/testtbs01_02.dbf
(2)
SQL> alter tablespace testtbs01 offline normal;
(3)
$ cp -rf /oracle/oradata/boss/testtbs01_01.dbf /oradata/bossbak/20140604/testtbs01_01_`date "+%y_%m_%d"`.dbf
$ cp -rf /oracle/oradata/boss/testtbs01_02.dbf /oradata/bossbak/20140604/testtbs01_02_`date "+%y_%m_%d"`.dbf
(4)
SQL> alter tablespace testtbs01 online;
(5)
SQL> select group#,members,sequence#,archived,status,first_change# from v$log;
GROUP# MEMBERS SEQUENCE# ARC STATUS FIRST_CHANGE#
---------- ---------- ---------- --- ---------------- -------------
1 1 17 YES INACTIVE 575472
2 1 18 YES INACTIVE 575475
3 1 19 NO CURRENT 575477
SQL> alter system archive log current;
SQL> select group#,members,sequence#,archived,status,first_change# from v$log;
GROUP# MEMBERS SEQUENCE# ARC STATUS FIRST_CHANGE#
---------- ---------- ---------- --- ---------------- -------------
1 1 20 YES ACTIVE 581638
2 1 21 NO CURRENT 581693
3 1 19 YES ACTIVE 575477
SQL> alter system checkpoint; ##檢查點觸發dbwrn寫進程。把臟數據寫入數據文件,此時active的日誌馬上變為inactive。
SQL> select group#,members,sequence#,archived,status,first_change# from v$log;
GROUP# MEMBERS SEQUENCE# ARC STATUS FIRST_CHANGE#
---------- ---------- ---------- --- ---------------- -------------
1 1 20 YES INACTIVE 581638
2 1 21 NO CURRENT 581693
3 1 19 YES INACTIVE 575477
Making User-Managed Backups-17.3、Making User-Managed Backups of Offline Tablespaces and Datafiles