假设在二个节点上进行数据库的备份和恢复,而个节点的实例都正常的运行。大致的操作步骤如下:
1.备份如下:rman备份文件将生成到两台主机的目录下:
run{
allocate CHANNEL ch00 type DISK CONNECT'sys/oracle@rdb1';
allocate CHANNEL ch01 type DISK CONNECT'sys/oracle@rdb2';
backup database format '/rmanset/full_%d%t%s%p' tag 'fullbackup';
sql 'alter system archive log current';
BACKUP FORMAT '/rmanset/%d_arch_%s_%p_%h' ARCHIVELOG ALL delete input;
backup format '/rmanset/cf_%d' current controlfile;
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
}
rac1-> rman target / nocatalog Recovery Manager: Release 10.2.0.4.0 - Production on Wed Nov 26 00:30:03 2008 Copyright (c) 1982, 2005, Oracle. All rights reserved. connected to target database: RACDB (DBID=667104169) using target database control file instead of recovery catalog RMAN> run{ 2> allocate CHANNEL ch00 type DISK CONNECT'sys/oracle@rdb1'; 3> allocate CHANNEL ch01 type DISK CONNECT'sys/oracle@rdb2'; 4> backup database format '/rmanset/full_%d%t%s%p' tag 'fullbackup'; 5> sql 'alter system archive log current'; 6> BACKUP FORMAT '/rmanset/%d_arch_%s_%p_%h' ARCHIVELOG ALL delete input; 7> backup format '/rmanset/cf_%d' current controlfile; 8> RELEASE CHANNEL ch00; 9> RELEASE CHANNEL ch01; 10> } allocated channel: ch00 channel ch00: sid=153 instance=rdb1 devtype=DISK allocated channel: ch01 channel ch01: sid=120 instance=rdb2 devtype=DISK Starting backup at 26-NOV-08 channel ch00: starting full datafile backupset channel ch00: specifying datafile(s) in backupset input datafile fno=00003 name=+RACDATA/racdb/datafile/sysaux.261.669487497 input datafile fno=00002 name=+RACDATA/racdb/datafile/undotbs1.260.669487479 input datafile fno=00004 name=+RACDATA/racdb/datafile/undotbs2.263.669487539 channel ch00: starting piece 1 at 26-NOV-08 channel ch01: starting full datafile backupset channel ch01: specifying datafile(s) in backupset input datafile fno=00001 name=+RACDATA/racdb/datafile/system.259.669487425 input datafile fno=00006 name=+RACDATA/racdb/datafile/rman_backup.268.671103645 input datafile fno=00005 name=+RACDATA/racdb/datafile/users.264.669487561 channel ch01: starting piece 1 at 26-NOV-08 channel ch01: finished piece 1 at 26-NOV-08 piece handle=/rmanset/full_RACDB6717618001931 tag=FULLBACKUP comment=NONE channel ch01: backup set complete, elapsed time: 00:02:10 channel ch01: starting full datafile backupset channel ch01: specifying datafile(s) in backupset including current control file in backupset channel ch01: starting piece 1 at 26-NOV-08 channel ch00: finished piece 1 at 26-NOV-08 piece handle=/rmanset/full_RACDB6717618141921 tag=FULLBACKUP comment=NONE channel ch00: backup set complete, elapsed time: 00:02:22 channel ch00: starting full datafile backupset channel ch00: specifying datafile(s) in backupset including current SPFILE in backupset channel ch00: starting piece 1 at 26-NOV-08 channel ch01: finished piece 1 at 26-NOV-08 piece handle=/rmanset/full_RACDB6717619311941 tag=FULLBACKUP comment=NONE channel ch01: backup set complete, elapsed time: 00:00:13 channel ch00: finished piece 1 at 26-NOV-08 piece handle=/rmanset/full_RACDB6717619571951 tag=FULLBACKUP comment=NONE channel ch00: backup set complete, elapsed time: 00:00:02 Finished backup at 26-NOV-08 sql statement: alter system archive log current Starting backup at 26-NOV-08 current log archived released channel: ch00 released channel: ch01 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of backup command at 11/26/2008 00:32:56 RMAN-06726: could not locate archivelog /rdb1_arch/1_1_671755092.dbf RMAN> crosscheck archivelog all; RMAN> run{ 2> allocate CHANNEL ch00 type DISK CONNECT'sys/oracle@rdb1'; 3> allocate CHANNEL ch01 type DISK CONNECT'sys/oracle@rdb2'; 4> sql 'alter system archive log current'; 5> BACKUP FORMAT '/rmanset/%d_arch_%s_%p_%h' ARCHIVELOG ALL delete input; 6> backup format '/rmanset/cf_%d' current controlfile; 7> RELEASE CHANNEL ch00; 8> RELEASE CHANNEL ch01; 9> } released channel: ORA_DISK_1 allocated channel: ch00 channel ch00: sid=153 instance=rdb1 devtype=DISK allocated channel: ch01 channel ch01: sid=120 instance=rdb2 devtype=DISK sql statement: alter system archive log current Starting backup at 26-NOV-08 current log archived channel ch00: starting archive log backupset channel ch00: specifying archive log(s) in backup set input archive log thread=1 sequence=1 recid=370 stamp=671761661 input archive log thread=1 sequence=2 recid=372 stamp=671761676 input archive log thread=1 sequence=3 recid=373 stamp=671761677 input archive log thread=1 sequence=4 recid=374 stamp=671761683 input archive log thread=1 sequence=5 recid=376 stamp=671761688 input archive log thread=1 sequence=6 recid=379 stamp=671761962 channel ch00: starting piece 1 at 26-NOV-08 channel ch01: starting archive log backupset channel ch01: specifying archive log(s) in backup set input archive log thread=1 sequence=7 recid=380 stamp=671761968 input archive log thread=1 sequence=8 recid=383 stamp=671762080 input archive log thread=1 sequence=9 recid=385 stamp=671762085 input archive log thread=2 sequence=1 recid=368 stamp=671761639 input archive log thread=2 sequence=2 recid=369 stamp=671761644 input archive log thread=2 sequence=3 recid=371 stamp=671761649 input archive log thread=2 sequence=4 recid=375 stamp=671761671 input archive log thread=2 sequence=5 recid=377 stamp=671761676 input archive log thread=2 sequence=6 recid=378 stamp=671761946 channel ch01: starting piece 1 at 26-NOV-08 channel ch00: finished piece 1 at 26-NOV-08 piece handle=/rmanset/RACDB_arch_196_1_1 tag=TAG20081126T003446 comment=NONE channel ch00: backup set complete, elapsed time: 00:00:00 channel ch00: deleting archive log(s) archive log filename=/rdb1_arch/1_1_671761416.dbf recid=370 stamp=671761661 archive log filename=/rdb1_arch/1_2_671761416.dbf recid=372 stamp=671761676 archive log filename=/rdb1_arch/1_3_671761416.dbf recid=373 stamp=671761677 archive log filename=/rdb1_arch/1_4_671761416.dbf recid=374 stamp=671761683 archive log filename=/rdb1_arch/1_5_671761416.dbf recid=376 stamp=671761688 archive log filename=/rdb1_arch/1_6_671761416.dbf recid=379 stamp=671761962 channel ch01: finished piece 1 at 26-NOV-08 piece handle=/rmanset/RACDB_arch_197_1_2 tag=TAG20081126T003446 comment=NONE channel ch01: backup set complete, elapsed time: 00:00:01 channel ch01: deleting archive log(s) archive log filename=/rdb1_arch/1_7_671761416.dbf recid=380 stamp=671761968 archive log filename=/rdb1_arch/1_8_671761416.dbf recid=383 stamp=671762080 archive log filename=/rdb1_arch/1_9_671761416.dbf recid=385 stamp=671762085 archive log filename=/rdb2_arch/2_1_671761416.dbf recid=368 stamp=671761639 archive log filename=/rdb2_arch/2_2_671761416.dbf recid=369 stamp=671761644 archive log filename=/rdb2_arch/2_3_671761416.dbf recid=371 stamp=671761649 archive log filename=/rdb2_arch/2_4_671761416.dbf recid=375 stamp=671761671 archive log filename=/rdb2_arch/2_5_671761416.dbf recid=377 stamp=671761676 archive log filename=/rdb2_arch/2_6_671761416.dbf recid=378 stamp=671761946 channel ch00: starting archive log backupset channel ch00: specifying archive log(s) in backup set input archive log thread=2 sequence=7 recid=381 stamp=671761959 input archive log thread=2 sequence=8 recid=382 stamp=671762064 input archive log thread=2 sequence=9 recid=384 stamp=671762067 channel ch00: starting piece 1 at 26-NOV-08 channel ch00: finished piece 1 at 26-NOV-08 piece handle=/rmanset/RACDB_arch_198_1_2 tag=TAG20081126T003446 comment=NONE channel ch00: backup set complete, elapsed time: 00:00:02 channel ch00: deleting archive log(s) archive log filename=/rdb2_arch/2_7_671761416.dbf recid=381 stamp=671761959 archive log filename=/rdb2_arch/2_8_671761416.dbf recid=382 stamp=671762064 archive log filename=/rdb2_arch/2_9_671761416.dbf recid=384 stamp=671762067
2。数据库关闭后,做恢复:
rac1-> rman target / nocatalog Recovery Manager: Release 10.2.0.4.0 - Production on Wed Nov 26 00:39:23 2008 Copyright (c) 1982, 2005, Oracle. All rights reserved. connected to target database (not started) RMAN> startup nomount; Oracle instance started Total System Global Area 171966464 bytes Fixed Size 1218340 bytes Variable Size 125831388 bytes Database Buffers 41943040 bytes Redo Buffers 2973696 bytes RMAN> restore controlfile from '/rmanset/cf_RACDB'; Starting restore at 26-NOV-08 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=147 instance=rdb1 devtype=DISK channel ORA_DISK_1: restoring control file channel ORA_DISK_1: restore complete, elapsed time: 00:00:11 output filename=+RACDATA/racdb/controlfile/current.256.669487407 Finished restore at 26-NOV-08 RMAN> sql 2> 'alter database mount'; sql statement: alter database mount released channel: ORA_DISK_13.实例2也要启动到mount,才开始做resotre database:
RMAN> run{ 2> allocate CHANNEL ch00 type DISK CONNECT'sys/oracle@rdb1'; 3> allocate CHANNEL ch01 type DISK CONNECT'sys/oracle@rdb2'; 4> restore database; 5> } allocated channel: ch00 channel ch00: sid=147 instance=rdb1 devtype=DISK allocated channel: ch01 channel ch01: sid=151 instance=rdb2 devtype=DISK Starting restore at 26-NOV-08 channel ch00: starting datafile backupset restore channel ch00: specifying datafile(s) to restore from backup set restoring datafile 00002 to +RACDATA/racdb/datafile/undotbs1.260.669487479 restoring datafile 00003 to +RACDATA/racdb/datafile/sysaux.261.669487497 restoring datafile 00004 to +RACDATA/racdb/datafile/undotbs2.263.669487539 channel ch00: reading from backup piece /rmanset/full_RACDB6717618141921 channel ch01: starting datafile backupset restore channel ch01: specifying datafile(s) to restore from backup set restoring datafile 00001 to +RACDATA/racdb/datafile/system.259.669487425 restoring datafile 00005 to +RACDATA/racdb/datafile/users.264.669487561 restoring datafile 00006 to +RACDATA/racdb/datafile/rman_backup.268.671103645 channel ch01: reading from backup piece /rmanset/full_RACDB6717618001931 channel ch01: restored backup piece 1 piece handle=/rmanset/full_RACDB6717618001931 tag=FULLBACKUP channel ch01: restore complete, elapsed time: 00:01:44 channel ch00: restored backup piece 1 piece handle=/rmanset/full_RACDB6717618141921 tag=FULLBACKUP channel ch00: restore complete, elapsed time: 00:02:09 Finished restore at 26-NOV-08 released channel: ch00 released channel: ch01 4.restore archivelogfile RMAN> run{ 2> allocate CHANNEL ch00 type DISK CONNECT'sys/oracle@rdb1'; allocate CHANNEL ch01 type DISK CONNECT'sys/oracle@rdb2'; 3> 4> restore (archivelog sequence between 1 and 10 thread 1); 5> restore (archivelog sequence between 1 and 7 thread 2); 6> } released channel: ORA_DISK_1 allocated channel: ch00 channel ch00: sid=147 instance=rdb1 devtype=DISK allocated channel: ch01 channel ch01: sid=151 instance=rdb2 devtype=DISK Starting restore at 26-NOV-08 archive log thread 1 sequence 6 is already on disk as file /rdb1_arch/1_6_671761416.dbf channel ch00: starting archive log restore to default destination channel ch01: starting archive log restore to default destination channel ch00: restoring archive log archive log thread=1 sequence=1 channel ch00: restoring archive log archive log thread=1 sequence=2 channel ch01: restoring archive log archive log thread=1 sequence=7 channel ch00: restoring archive log archive log thread=1 sequence=3 channel ch00: restoring archive log archive log thread=1 sequence=4 channel ch01: restoring archive log archive log thread=1 sequence=8 channel ch00: restoring archive log archive log thread=1 sequence=5 channel ch00: reading from backup piece /rmanset/RACDB_arch_196_1_1 channel ch01: restoring archive log archive log thread=1 sequence=9 channel ch01: reading from backup piece /rmanset/RACDB_arch_197_1_2 channel ch00: restored backup piece 1 piece handle=/rmanset/RACDB_arch_196_1_1 tag=TAG20081126T003446 channel ch00: restore complete, elapsed time: 00:00:02 channel ch01: restored backup piece 1 piece handle=/rmanset/RACDB_arch_197_1_2 tag=TAG20081126T003446 channel ch01: restore complete, elapsed time: 00:00:02 Finished restore at 26-NOV-08 Starting restore at 26-NOV-08 channel ch00: starting archive log restore to default destination channel ch00: restoring archive log archive log thread=2 sequence=7 channel ch00: reading from backup piece /rmanset/RACDB_arch_198_1_2 channel ch01: starting archive log restore to default destination channel ch01: restoring archive log archive log thread=2 sequence=1 channel ch00: restored backup piece 1 piece handle=/rmanset/RACDB_arch_198_1_2 tag=TAG20081126T003446 channel ch00: restore complete, elapsed time: 00:00:00 channel ch01: restoring archive log archive log thread=2 sequence=2 channel ch01: restoring archive log archive log thread=2 sequence=3 channel ch01: restoring archive log archive log thread=2 sequence=4 channel ch01: restoring archive log archive log thread=2 sequence=5 channel ch01: restoring archive log archive log thread=2 sequence=6 channel ch01: reading from backup piece /rmanset/RACDB_arch_197_1_2 channel ch01: restored backup piece 1 piece handle=/rmanset/RACDB_arch_197_1_2 tag=TAG20081126T003446 channel ch01: restore complete, elapsed time: 00:00:02 Finished restore at 26-NOV-08 released channel: ch00 released channel: ch01 5。recover database: RMAN> run{ 2> allocate CHANNEL ch00 type DISK CONNECT'sys/oracle@rdb1'; 3> allocate CHANNEL ch01 type DISK CONNECT'sys/oracle@rdb2'; 4> recover database; 5> } allocated channel: ch00 channel ch00: sid=147 instance=rdb1 devtype=DISK allocated channel: ch01 channel ch01: sid=151 instance=rdb2 devtype=DISK Starting recover at 26-NOV-08 starting media recovery archive log thread 1 sequence 6 is already on disk as file /rdb1_arch/1_6_671761416.dbf archive log thread 1 sequence 7 is already on disk as file /rdb2_arch/1_7_671761416.dbf archive log thread 1 sequence 8 is already on disk as file /rdb2_arch/1_8_671761416.dbf archive log thread 1 sequence 9 is already on disk as file +RACDATA/racdb/onlinelog/group_2.258.669487419 archive log thread 1 sequence 10 is already on disk as file +RACDATA/racdb/onlinelog/group_1.257.669487411 archive log thread 2 sequence 6 is already on disk as file /rdb2_arch/2_6_671761416.dbf archive log thread 2 sequence 7 is already on disk as file /rdb1_arch/2_7_671761416.dbf archive log thread 2 sequence 9 is already on disk as file +RACDATA/racdb/onlinelog/group_4.266.669489327 archive log thread 2 sequence 10 is already on disk as file +RACDATA/racdb/onlinelog/group_3.265.669489319 archive log filename=/rdb1_arch/1_6_671761416.dbf thread=1 sequence=6 archive log filename=/rdb2_arch/2_6_671761416.dbf thread=2 sequence=6 archive log filename=/rdb1_arch/2_7_671761416.dbf thread=2 sequence=7 archive log filename=/rdb2_arch/1_7_671761416.dbf thread=1 sequence=7 archive log filename=/rdb2_arch/1_8_671761416.dbf thread=1 sequence=8 channel ch00: starting archive log restore to default destination channel ch00: restoring archive log archive log thread=2 sequence=8 channel ch00: reading from backup piece /rmanset/RACDB_arch_198_1_2 channel ch00: restored backup piece 1 piece handle=/rmanset/RACDB_arch_198_1_2 tag=TAG20081126T003446 channel ch00: restore complete, elapsed time: 00:00:04 archive log filename=/rdb1_arch/2_8_671761416.dbf thread=2 sequence=8 archive log filename=+RACDATA/racdb/onlinelog/group_4.266.669489327 thread=2 sequence=9 archive log filename=+RACDATA/racdb/onlinelog/group_2.258.669487419 thread=1 sequence=9 archive log filename=+RACDATA/racdb/onlinelog/group_3.265.669489319 thread=2 sequence=10 archive log filename=+RACDATA/racdb/onlinelog/group_1.257.669487411 thread=1 sequence=10 media recovery complete, elapsed time: 00:00:03 Finished recover at 26-NOV-08 released channel: ch00 released channel: ch01 RMAN> alter database open resetlogs; database opened RMAN>