1、1、 备份前的准备启动数据库到 mount修改 archive 模式( alter database archivelog; )启动到 open打开 raman连接数据库(connect target /)然后进行备份2、全备份(backup database)0 级分量备份(backup incremental level 0 database)3、Archivelog 的备份(backup database plus archivelog delete input;)表空间的备份(backup tablespace 表空间)控制文件的备份(backup current controlfil
2、e/backup database include current controlfile)4、批命令备份(callocate channel cha1 type disk;backupformat “路径”tag 标签名称database;release channel cha1;)5、自动备份run allocate channel c1 type disk;backupincremental level 1format “/u01/rmanbak/inc0_%u_%T“tag monday_inc1database;release channel c1rootdb-oracle # cr
3、ontab -e -u Oracle45 23 * * 0 rman target/ msglog=bakl0.log cmdfile=bakl045 23 * * 1 rman target/ msglog=bakl2.log cmdfile=bakl245 23 * * 2 rman target/ msglog=bakl2.log cmdfile=bakl245 23 * * 3 rman target/ msglog=bakl1.log cmdfile=bakl145 23 * * 4 rman target/ msglog=bakl2.log cmdfile=bakl245 23 *
4、 * 5 rman target/ msglog=bakl2.log cmdfile=bakl245 23 * * 6 rman target/ msglog=bakl2.log cmdfile=bakl2再启动 service crond restart 就可以了6、备份控制文件Dbid= 1273224634示例:startup failed: ORA-01078: failure in processing system parametersLRM-00109: could not open parameter file /u01/app/Oracle/product/10.2.0/db
5、_1/dbs/initorcl.orastarting Oracle instance without parameter file for retrival of spfileOracle instance startedTotal System Global Area 159383552 bytesFixed Size 1218268 bytesVariable Size 54528292 bytesDatabase Buffers 100663296 bytesRedo Buffers 2973696 bytesRMAN set dbid 1273224634executing comm
6、and: SET DBIDRMAN restore spfile from /u01/app/Oracle/flash_recovery_area/ORCL/autoback RMAN-00571: =RMAN-00569: = ERROR MESSAGE STACK FOLLOWS =RMAN-00571: =RMAN-00558: error encountered while parsing input commandsRMAN-01006: error signalled during parseRMAN-02001: unrecognized punctuation symbol “
7、/“RMAN restore spfile from /u01/app/Oracle/flash_recovery_area/ORCL/autobackup/2011_03_12/o1_mf_s_745580370_6qompo30_.bkp;Starting restore at 12-MAR-11using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: sid=36 devtype=DISKchannel ORA_DISK_1:
8、 autobackup found: /u01/app/Oracle/flash_recovery_area/ORCL/autobackup/2011_03_12/o1_mf_s_745580370_6qompo30_.bkpchannel ORA_DISK_1: SPFILE restore from autobackup completeFinished restore at 12-MAR-11RMAN shutdown immediateOracle instance shut downRMAN startup;connected to target database (not star
9、ted)Oracle instance starteddatabase mounteddatabase openedTotal System Global Area 247463936 bytesFixed Size 1218772 bytesVariable Size 79693612 bytesDatabase Buffers 163577856 bytesRedo Buffers 2973696 bytes7、Controlfile 文件丢失示例RMAN connect target /connected to target database (not started)RMAN star
10、tup nomount;Oracle instance startedTotal System Global Area 247463936 bytesFixed Size 1218772 bytesVariable Size 79693612 bytesDatabase Buffers 163577856 bytesRedo Buffers 2973696 bytesRMAN restore controlfile from autobackup;Starting restore at 12-MAR-11using target database control file instead of
11、 recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: sid=156 devtype=DISKrecovery area destination: /u01/app/Oracle/flash_recovery_areadatabase name (or database unique name) used for search: ORCLchannel ORA_DISK_1: autobackup found in the recovery areachannel ORA_DISK_1: autobackup fou
12、nd: /u01/app/Oracle/flash_recovery_area/ORCL/autobackup/2011_03_12/o1_mf_s_745590355_6qoxgo3y_.bkpchannel ORA_DISK_1: control file restore from autobackup completeoutput filename=/u01/app/Oracle/oradata/orcl/control01.ctloutput filename=/u01/app/Oracle/oradata/orcl/control02.ctloutput filename=/u01/
13、app/Oracle/oradata/orcl/control03.ctlFinished restore at 12-MAR-11RMAN alter database mount;database mountedreleased channel: ORA_DISK_1RMAN recover database;Starting recover at 12-MAR-11Starting implicit crosscheck backup at 12-MAR-11allocated channel: ORA_DISK_1channel ORA_DISK_1: sid=156 devtype=
14、DISKCrosschecked 4 objectsFinished implicit crosscheck backup at 12-MAR-11Starting implicit crosscheck copy at 12-MAR-11using channel ORA_DISK_1Finished implicit crosscheck copy at 12-MAR-11searching for all files in the recovery areacataloging files.cataloging doneList of Cataloged Files=File Name:
15、 /u01/app/Oracle/flash_recovery_area/ORCL/autobackup/2011_03_12/o1_mf_s_745590355_6qoxgo3y_.bkpusing channel ORA_DISK_1starting media recoveryarchive log thread 1 sequence 1 is already on disk as file /u01/app/Oracle/oradata/orcl/redo01.logarchive log filename=/u01/app/Oracle/oradata/orcl/redo01.log
16、 thread=1 sequence=1media recovery complete, elapsed time: 00:00:03Finished recover at 12-MAR-11RMAN alter database open resetlogs;database openedredolog file 丢失(要在 sqlplus 中进行)8、数据库的完全恢复最好恢复了以后做一个全备份示例:RMAN shutdown abort;Oracle instance shut downRMAN connect target /connected to target database (n
17、ot started)RMAN startup nomount;Oracle instance startedTotal System Global Area 247463936 bytesFixed Size 1218772 bytesVariable Size 79693612 bytesDatabase Buffers 163577856 bytesRedo Buffers 2973696 bytesRMAN restore controlfile from autobackup;Starting restore at 12-MAR-11allocated channel: ORA_DI
18、SK_1channel ORA_DISK_1: sid=156 devtype=DISKrecovery area destination: /u01/app/Oracle/flash_recovery_areadatabase name (or database unique name) used for search: ORCLchannel ORA_DISK_1: autobackup found in the recovery areachannel ORA_DISK_1: autobackup found: /u01/app/Oracle/flash_recovery_area/OR
19、CL/autobackup/2011_03_12/o1_mf_s_745580370_6qompo30_.bkpchannel ORA_DISK_1: control file restore from autobackup completeoutput filename=/u01/app/Oracle/oradata/orcl/control01.ctloutput filename=/u01/app/Oracle/oradata/orcl/control02.ctloutput filename=/u01/app/Oracle/oradata/orcl/control03.ctlFinis
20、hed restore at 12-MAR-11RMAN alter database mount;database mountedreleased channel: ORA_DISK_1RMAN restore database;Starting restore at 12-MAR-11Starting implicit crosscheck backup at 12-MAR-11allocated channel: ORA_DISK_1channel ORA_DISK_1: sid=156 devtype=DISKCrosschecked 1 objectsFinished implici
21、t crosscheck backup at 12-MAR-11Starting implicit crosscheck copy at 12-MAR-11using channel ORA_DISK_1Finished implicit crosscheck copy at 12-MAR-11searching for all files in the recovery areacataloging files.cataloging doneList of Cataloged Files=File Name: /u01/app/Oracle/flash_recovery_area/ORCL/
22、autobackup/2011_03_12/o1_mf_s_745580370_6qompo30_.bkpusing channel ORA_DISK_1channel ORA_DISK_1: starting datafile backupset restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setrestoring datafile 00001 to /u01/app/Oracle/oradata/orcl/system01.dbfrestoring datafile 00002 to /u
23、01/app/Oracle/oradata/orcl/undotbs01.dbfrestoring datafile 00003 to /u01/app/Oracle/oradata/orcl/sysaux01.dbfrestoring datafile 00004 to /u01/app/Oracle/oradata/orcl/users01.dbfchannel ORA_DISK_1: reading from backup piece /u01/app/Oracle/flash_recovery_area/ORCL/backupset/2011_03_12/o1_mf_nnndf_TAG
24、20110312T093730_6qomm0b3_.bkpchannel ORA_DISK_1: restored backup piece 1piece handle=/u01/app/Oracle/flash_recovery_area/ORCL/backupset/2011_03_12/o1_mf_nnndf_TAG20110312T093730_6qomm0b3_.bkp tag=TAG20110312T093730channel ORA_DISK_1: restore complete, elapsed time: 00:02:34Finished restore at 12-MAR
25、-11RMAN recover database;Starting recover at 12-MAR-11using channel ORA_DISK_1starting media recoveryunable to find archive logarchive log thread=1 sequence=8RMAN-00571: =RMAN-00569: = ERROR MESSAGE STACK FOLLOWS =RMAN-00571: =RMAN-03002: failure of recover command at 03/12/2011 12:21:14RMAN-06054:
26、media recovery requesting unknown log: thread 1 seq 8 lowscn 552989RMAN alter database open resetlogs;database openedRMAN backup database;Starting backup at 12-MAR-11using channel ORA_DISK_1channel ORA_DISK_1: starting full datafile backupsetchannel ORA_DISK_1: specifying datafile(s) in backupsetinput datafile fno=00001 name=/u01/app/Oracle/oradata/orcl/system01.dbf