Backup And Recovery User's Guide-執行完全資料庫恢復-執行表空間的完全恢復

LuiseDalian發表於2014-02-27

執行表空間的完全恢復

場景:                                                                                    

資料庫處於OPEN狀態,只有部分並不是所有的資料檔案損壞了。

當在資料庫處於開啟狀態時還原和恢復損壞的表空間,這樣資料庫的其它部分仍然可用。

這裡假設trgt資料庫丟失了users表空間。

練習:還原和恢復表空間

--1. 啟動RMAN連線到目標資料庫

--2. 如果資料庫是OPEN狀態,則使需要恢復的資料檔案離線

SQL "ALTER TABLESPACE users OFFLINE IMMEDIATE";

--3. 使用SHOW命令檢視預先配置的channel

--   如果需要的裝置和通道已經被配置了,則不需要其它的操作;否則 使用CONFIGURE命令配置自動通道或在RUN塊中包含ALLOCATE CHANNEL命令

SHOW ALL;

 

 

RMAN configuration parameters for database with db_unique_name PROD1 are:

.

.

.

CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default

CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default

CONFIGURE DEVICE TYPE SBT_TAPE PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default

CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS "SBT_LIBRARY=/usr/local/oracle/backup/lib/libobk.so";

--4. 如果還原口令加密的備份,則指定口令; 如果使用了多個不同的口令建立備份,則需要執行SET DECRYPTION IDENTIFIED BY多次

--   指定還原備份可能需要的所有口令。

SET DECRYPTION IDENTIFIED BY password;

--5. 還原和恢復表空間

--5.1 如果還原資料檔案到原來的位置,則執行RESTORE TABLESPACERECOVER TABLESPACE命令

RMAN> RESTORE TABLESPACE users;

 

Starting restore at 20-JUN-06

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=37 device type=DISK

allocated channel: ORA_SBT_TAPE_1

channel ORA_SBT_TAPE_1: SID=38 device type=SBT_TAPE

channel ORA_SBT_TAPE_1: Oracle Secure Backup

 

channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00012 to /disk1/oracle/dbs/users01.f

channel ORA_DISK_1: restoring datafile 00013 to /disk1/oracle/dbs/users02.f

channel ORA_DISK_1: restoring datafile 00021 to /disk1/oracle/dbs/users03.f

channel ORA_DISK_1: reading from backup piece /disk1/oracle/work/orcva/TKRM/backupset/2007_06_20/o1_mf_nnndf_TAG20070620T105435_29jflwor_.bkp

channel ORA_DISK_1: piece handle=/disk1/oracle/work/orcva/TKRM/backupset/2007_06_20/o1_mf_nnndf_TAG20070620T105435_29jflwor_.bkp tag=TAG20070620T105435

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

Finished restore at 20-JUN-06

 

RMAN> RECOVER TABLESPACE users;

 

Starting recover at 20-JUN-06

using channel ORA_DISK_1

using channel ORA_SBT_TAPE_1

 

starting media recovery

 

archived log for thread 1 with sequence 27 is already on disk as file /disk1/oracle/work/orcva/TKRM/archivelog/2007_06_20/o1_mf_1_27_29jjmtc9_.arc

archived log for thread 1 with sequence 28 is already on disk as file /disk1/oracle/work/orcva/TKRM/archivelog/2007_06_20/o1_mf_1_28_29jjnc5x_.arc

.

.

.

channel ORA_DISK_1: starting archived log restore to default destination

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=5

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=6

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=7

.

.

.

channel ORA_DISK_1: reading from backup piece /disk1/oracle/work/orcva/TKRM/backupset/2007_06_20/o1_mf_annnn_TAG20070620T113128_29jhr197_.bkp

channel ORA_DISK_1: piece handle=/disk1/oracle/work/orcva/TKRM/backupset/2007_06_20/o1_mf_annnn_TAG20070620T113128_29jhr197_.bkp tag=TAG20070620T113128

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:02

archived log file name=/disk1/oracle/work/orcva/TKRM/archivelog/2007_06_20/o1_mf_1_5_29jkdvjq_.arc thread=1 sequence=5

channel default: deleting archived log(s)

archived log file name=/disk1/oracle/work/orcva/TKRM/archivelog/2007_06_20/o1_mf_1_5_29jkdvjq_.arc RECID=91 STAMP=593611179

archived log file name=/disk1/oracle/work/orcva/TKRM/archivelog/2007_06_20/o1_mf_1_6_29jkdvbz_.arc thread=1 sequence=6

channel default: deleting archived log(s)

.

.

.

media recovery complete, elapsed time: 00:00:01

Finished recover at 20-JUN-06

 

--5.2 還原資料檔案到新的位置,則必須在RUN塊中執行RESTORERECOVER命令,使用SET NEWNAME來重新命名資料檔案。

RUN

{

  # 對每個資料檔案指定新的位置

  SET NEWNAME FOR DATAFILE '/disk1/oracle/dbs/users01.f' TO

                           '/disk2/users01.f';

  SET NEWNAME FOR DATAFILE '/disk1/oracle/dbs/users02.f' TO

      &n

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

相關文章