1、創建表空eygle
2、創建用戶eygle,隸屬於eygle表空間;賦予用戶DBA權限
3、egyle用戶登錄DB,創建表test_egyle
5、rman備份egyle表空間
RMAN> backup tablespace eygle tag="ey_first";
Starting backup at 15-FEB-14
using target database control file instead of recovery catalog ----使用目標庫控制文件替代恢復目錄
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=317 device type=DISK
channel ORA_DISK_1: starting full datafile backup set ----啓動full數據文件備份集
channel ORA_DISK_1: specifying datafile(s) in backup set ----指定備份集中的數據文件
input datafile file number=00029 name=/home/oracle/oradata/temp/eygle.f ----輸入數據文件
channel ORA_DISK_1: starting piece 1 at 15-FEB-14
channel ORA_DISK_1: finished piece 1 at 15-FEB-14
piece handle=/home/oracle/app/flash_recovery_area/ORA11G/backupset/2014_02_15/o1_mf_nnndf_EY_FIRST_9hxyglp2_.bkp tag=EY_FIRST comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 15-FEB-14
Starting Control File and SPFILE Autobackup at 15-FEB-14 ----庫結構發生變化時,controlfile和spfile將自動備份
piece handle=/home/oracle/app/flash_recovery_area/ORA11G/autobackup/2014_02_15/o1_mf_s_839597011_9hxygn23_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 15-FEB-14
6、sys用戶登錄DB,修改表空間egyle狀態offline
SQL> alter tablespace eygle offline;
7、破壞表空間egyle對應數據文件,如刪除或改名
oracle@linux:~/oradata/temp> mv eygle.f eygle_bak.f
8、修改表空間egyle狀態online,報錯
SQL> alter tablespace eygle online;
alter tablespace eygle online
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 29 - see DBWR trace file
ORA-01110: data file 29: '/home/oracle/oradata/temp/eygle.f'
9、rman恢復
RMAN> restore tablespace eygle; 將備份文件恢復到原先位置
Starting restore at 15-FEB-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=261 device type=DISK
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 00029 to /home/oracle/oradata/temp/eygle.f
channel ORA_DISK_1: reading from backup piece /home/oracle/app/flash_recovery_area/ORA11G/backupset/2014_02_15/o1_mf_nnndf_EY_FIRST_9hxyglp2_.bkp
channel ORA_DISK_1: piece handle=/home/oracle/app/flash_recovery_area/ORA11G/backupset/2014_02_15/o1_mf_nnndf_EY_FIRST_9hxyglp2_.bkp tag=EY_FIRST
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 15-FEB-14
RMAN> recover tablespace eygle; 執行恢復操作
Starting recover at 15-FEB-14
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 15-FEB-14
10、檢驗恢復結果
SQL> alter tablespace eygle online;
Tablespace altered.