1、两台机器环境一致。
2、在源服务器上使用rman备份数据库,包括数据文件,归档日志文件和控制文件,参数文件的备份。
RMAN> run { 2> allocate channel c1 device type disk; 3> backup incremental level 0 4> format '/u01/dbbackup/db_full_%U.bkp' 5> tag '2011-11-17-FULL' 6> database plus archivelog; 7> release channel c1; 8> } using target database control file instead of recovery catalog allocated channel: c1 channel c1: sid=142 devtype=DISK Starting backup at 2012-11-17 12:07:52 current log archived channel c1: starting archive log backupset channel c1: specifying archive log(s) in backup set input archive log thread=1 sequence=3 recid=1 stamp=799589280 channel c1: starting piece 1 at 2012-11-17 12:08:03 channel c1: finished piece 1 at 2012-11-17 12:08:58 piece handle=/u01/dbbackup/db_full_01nqhgt2_1_1.bkp tag=2011-11-17-FULL comment=NONE channel c1: backup set complete, elapsed time: 00:00:57 Finished backup at 2012-11-17 12:08:59 Starting backup at 2012-11-17 12:09:04 channel c1: starting incremental level 0 datafile backupset channel c1: specifying datafile(s) in backupset input datafile fno=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf input datafile fno=00003 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf input datafile fno=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf input datafile fno=00002 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf input datafile fno=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf channel c1: starting piece 1 at 2012-11-17 12:09:04 channel c1: finished piece 1 at 2012-11-17 12:23:44 piece handle=/u01/dbbackup/db_full_02nqhgv0_1_1.bkp tag=2011-11-17-FULL comment=NONE channel c1: backup set complete, elapsed time: 00:14:40 Finished backup at 2012-11-17 12:23:44 Starting backup at 2012-11-17 12:23:44 current log archived channel c1: starting archive log backupset channel c1: specifying archive log(s) in backup set input archive log thread=1 sequence=4 recid=2 stamp=799590225 channel c1: starting piece 1 at 2012-11-17 12:23:49 channel c1: finished piece 1 at 2012-11-17 12:23:50 piece handle=/u01/dbbackup/db_full_03nqhhqh_1_1.bkp tag=2011-11-17-FULL comment=NONE channel c1: backup set complete, elapsed time: 00:00:05 Finished backup at 2012-11-17 12:23:50 Starting Control File and SPFILE Autobackup at 2012-11-17 12:23:50 piece handle=/u01/app/oracle/flash_recovery_area/ORCL/autobackup/2012_11_17/o1_mf_s_799590231_8bg4bsfl_.bkp comment=NONE Finished Control File and SPFILE Autobackup at 2012-11-17 12:23:57 released channel: c1
RMAN> backup current controlfile format '/u01/dbbackup/control20121117.bak'; Starting backup at 2012-11-17 14:32:38 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=144 devtype=DISK channel ORA_DISK_1: starting full datafile backupset channel ORA_DISK_1: specifying datafile(s) in backupset including current control file in backupset channel ORA_DISK_1: starting piece 1 at 2012-11-17 14:32:43 channel ORA_DISK_1: finished piece 1 at 2012-11-17 14:32:46 piece handle=/u01/dbbackup/control20121117.bak tag=TAG20121117T143239 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07 Finished backup at 2012-11-17 14:32:46 Starting Control File and SPFILE Autobackup at 2012-11-17 14:32:46 piece handle=/u01/app/oracle/flash_recovery_area/ORCL/autobackup/2012_11_17/o1_mf_s_799597966_8bgcwh2d_.bkp comment=NONE Finished Control File and SPFILE Autobackup at 2012-11-17 14:32:49
RMAN> backup spfile format '/u01/dbbackup/spfile20121117.bak'; Starting backup at 2012-11-17 14:33:32 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backupset channel ORA_DISK_1: specifying datafile(s) in backupset including current SPFILE in backupset channel ORA_DISK_1: starting piece 1 at 2012-11-17 14:33:32 channel ORA_DISK_1: finished piece 1 at 2012-11-17 14:33:33 piece handle=/u01/dbbackup/spfile20121117.bak tag=TAG20121117T143332 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 2012-11-17 14:33:33 Starting Control File and SPFILE Autobackup at 2012-11-17 14:33:33 piece handle=/u01/app/oracle/flash_recovery_area/ORCL/autobackup/2012_11_17/o1_mf_s_799598013_8bgcxy20_.bkp comment=NONE Finished Control File and SPFILE Autobackup at 2012-11-17 14:33:41
3、拷贝备份文件到目标服务器上。
[oracle@edrsr9p1 ~]$ scp -rp 192.168.253.10:/u01/dbbackup/* /u01/dbbackup/ oracle@192.168.253.10's password: control20121117.bak 100% 6944KB 6.8MB/s 00:01 db_full_01nqhgt2_1_1.bkp 100% 46MB 2.9MB/s 00:16 db_full_02nqhgv0_1_1.bkp 100% 599MB 592.2KB/s 17:15 db_full_03nqhhqh_1_1.bkp 100% 91KB 90.5KB/s 00:00 spfile20121117.bak 100% 96KB 96.0KB/s 00:00
4、目标服务器上恢复。
RMAN> restore spfile to '/u01/dbbackup/spfileorcl.ora' from '/u01/dbbackup/spfile20121117.bak'; Starting restore at 2012-11-17 15:19:19 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=159 devtype=DISK channel ORA_DISK_1: autobackup found: /u01/dbbackup/spfile20121117.bak channel ORA_DISK_1: SPFILE restore from autobackup complete Finished restore at 2012-11-17 15:19:21
RMAN> restore controlfile from '/u01/dbbackup/control20121117.bak'; Starting restore at 2012-11-17 15:21:35 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=156 devtype=DISK channel ORA_DISK_1: restoring control file channel ORA_DISK_1: restore complete, elapsed time: 00:00:05 output filename=/u01/app/oracle/oradata/orcl/control01.ctl output filename=/u01/app/oracle/oradata/orcl/control02.ctl output filename=/u01/app/oracle/oradata/orcl/control03.ctl Finished restore at 2012-11-17 15:21:40
RMAN> restore database; Starting restore at 2012-11-17 15:22:42 Starting implicit crosscheck backup at 2012-11-17 15:22:42 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=153 devtype=DISK Crosschecked 4 objects Finished implicit crosscheck backup at 2012-11-17 15:22:46 Starting implicit crosscheck copy at 2012-11-17 15:22:46 using channel ORA_DISK_1 Finished implicit crosscheck copy at 2012-11-17 15:22:46 searching for all files in the recovery area cataloging files... no files cataloged using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile backupset restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set restoring datafile 00001 to /u01/app/oracle/oradata/orcl/system01.dbf restoring datafile 00002 to /u01/app/oracle/oradata/orcl/undotbs01.dbf restoring datafile 00003 to /u01/app/oracle/oradata/orcl/sysaux01.dbf restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf restoring datafile 00005 to /u01/app/oracle/oradata/orcl/example01.dbf channel ORA_DISK_1: reading from backup piece /u01/dbbackup/db_full_02nqhgv0_1_1.bkp channel ORA_DISK_1: restored backup piece 1 piece handle=/u01/dbbackup/db_full_02nqhgv0_1_1.bkp tag=2011-11-17-FULL channel ORA_DISK_1: restore complete, elapsed time: 00:05:22 Finished restore at 2012-11-17 15:28:10
RMAN> recover database; Starting recover at 2012-11-17 15:35:19 using channel ORA_DISK_1 starting media recovery channel ORA_DISK_1: starting archive log restore to default destination channel ORA_DISK_1: restoring archive log archive log thread=1 sequence=4 channel ORA_DISK_1: reading from backup piece /u01/dbbackup/db_full_03nqhhqh_1_1.bkp channel ORA_DISK_1: restored backup piece 1 piece handle=/u01/dbbackup/db_full_03nqhhqh_1_1.bkp tag=2011-11-17-FULL channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_11_17/o1_mf_1_4_8bghkr36_.arc thread=1 sequence=4 channel default: deleting archive log(s) archive log filename=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2012_11_17/o1_mf_1_4_8bghkr36_.arc recid=3 stamp=799601720 unable to find archive log archive log thread=1 sequence=5 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 11/17/2012 15:35:24 RMAN-06054: media recovery requesting unknown log: thread 1 seq 5 lowscn 500144
SQL> alter database open resetlogs; Database altered.
5、检查。
SQL> select member from v$logfile; MEMBER -------------------------------------------------------------------------------- /u01/app/oracle/oradata/orcl/redo03.log /u01/app/oracle/oradata/orcl/redo02.log /u01/app/oracle/oradata/orcl/redo01.log SQL> select file_name from dba_data_files; FILE_NAME -------------------------------------------------------------------------------- /u01/app/oracle/oradata/orcl/users01.dbf /u01/app/oracle/oradata/orcl/sysaux01.dbf /u01/app/oracle/oradata/orcl/undotbs01.dbf /u01/app/oracle/oradata/orcl/system01.dbf /u01/app/oracle/oradata/orcl/example01.dbf