oracle数据库恢复与备份(二)
e LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1037059 31-AUG-13 /app/oracle/oradata/orcl/system01.dbf
2 Full 1037059 31-AUG-13 /app/oracle/oradata/orcl/sysaux01.dbf
3 Full 1037059 31-AUG-13 /app/oracle/oradata/orcl/undotbs01.dbf
4 Full 1037059 31-AUG-13 /app/oracle/oradata/orcl/users01.dbf
5 Full 1037059 31-AUG-13 /app/oracle/oradata/orcl/bank_data01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2 Full 9.33M DISK 00:00:04 31-AUG-13
BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20130831T030251
Piece Name: /app/oracle/flash_recovery_area/ORCL/autobackup/2013_08_31/o1_mf_n_824870625_923htgw8_.bkp
Control File Included: Ckp SCN: 1037059 Ckp time: 31-AUG-13
三、oracle数据库全库恢复
数据库启动过程
找到初始化spfile或pfile,处于nomount状态;
根据初始化文件找到控制文件Contral File,处于mount状态;
根据控制文件找到数据文件Data File、重做日志文件Redo File,处于open状态;
恢复数据库的前提是
Oracle数据库的初始化spfile文件、控制文件、重做日志、归档日志、备份都可以正常使用
恢复原则:根据丢失的文件情况,启动数据库到相应状态,然后通过RMAN恢复相应文件,再将数据库启动到下一状态
查看是否有备份
RMAN> list backup summary;
1.仅丢失数据文件情况
删除数据文件
# rm -rf *.dbf
启动数据库
SQL> startup
ORACLE instance started.
Total System Global Area 527290368 bytes
Fixed Size 1337660 bytes
Variable Size 318768836 bytes
Database Buffers 201326592 bytes
Redo Buffers 5857280 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/app/oracle/oradata/orcl/system01.dbf'
进入RMAN
$ rman target/
恢复数据文件
RMAN> restore database;
Starting restore at 31-AUG-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 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 00001 to /app/oracle/oradata/orcl/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /app/oracle/oradata/orcl/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /app/oracle/oradata/orcl/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /app/oracle/oradata/orcl/bank_data01.dbf
channel ORA_DISK_1: reading from backup piece /app/oracle/flash_recovery_area/ORCL/backupset/2013_08_31/o1_mf_nnndf_TAG20130831T025434_923hbw6f_.bkp
channel ORA_DISK_1: piece handle=/app/oracle/flash_recovery_area/ORCL/backupset/2013_08_31/o1_mf_nnndf_TAG20130831T025434_923hbw6f_.bkp tag=TAG20130831T025434
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:05:58
Finished restore at 31-AUG-13
RMAN> recover database;
Starting recover at 31-AUG-13
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:07
Finished recover at 31-AUG-13
进入SQL将状态改为open即恢复成功
SQL> alter database open;
2.丢失重做日志文件
# rm -rf *.log
SQL> recover