原创转载请注明出处
rac rman 备份和恢复
和单实例的备份和恢复稍有不同,ORACLE RAC主要是有多个实例,但是千万不要把多实例和多数据库搞混淆,在RAC中通常情况下一台服务器就是一个实例,多台服务器有一个共享存储,存储可以用RAW AMS OCFS2,而每个实例都有自己的后台进程,比如DBWR LGWR等,当然也包含RAC特有的进程LMSX LMD0等,rac 通过CACHE FUSION机制达到了多节点的BUFFER CACHE共享,通过广播机制达到shared_pool的共享。这些是通过私有IP进行传递的。
但是RAC中其实数据文件,控制文件只有一份,但是日志文件每个节点都有。我一般使用控制文件来存储RMAN备份信息,所以从这里可以知道不管你再哪个节点进行RMAN备份但是其备份信息的记录都是存储在共用的控制文件中的,因此不管在哪个节点进行备份都没有影响,但是如果是归档模式,就要注意归档日志文件是每个节点都有的,但是在恢复的时候需要用到各个节点的归档日志文件,所以必须要使用NFS,OCFS或者log_archive_dest_N 来设置各个节点都能访问这个目录,同时如果要在每个节点都能恢复,最好备份的备份集每个节点都能访问,并且在各个节点相同,当然这些不是必须只是为了恢复起来方便。
下面是一个测试,测试目的
1、在节点1进行备份,节点2进行恢复的测试
2、用较新的控制文件,来恢复较旧的备份集合,测试归档日志备份集的应用。
3、测试所有的控制文件和数据文件都已经丢失的不完全恢复
环境:
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Prod
PL/SQL Release 10.2.0.5.0 - Production
CORE 10.2.0.5.0 Production
TNS for Linux: Version 10.2.0.5.0 - Production
NLSRTL Version 10.2.0.5.0 - Production
设置NFS目录在2个节点*享
/archivelog
设置归档存储在/archivelog中
log_archive_dest_1 string location=/archivelog
1、 首先在节点1中执行全备份
RMAN> backup database format='/archivelog/bak_%s_%p_%t.bak';
Starting backup at 14-MAR-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=151 instance=ppzhu2 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00004 name=/dev/raw/raw10
input datafile fno=00005 name=/dev/raw/raw8
input datafile fno=00001 name=/dev/raw/raw5
input datafile fno=00003 name=/dev/raw/raw6
input datafile fno=00002 name=/dev/raw/raw7
channel ORA_DISK_1: starting piece 1 at 14-MAR-11
channel ORA_DISK_1: finished piece 1 at 14-MAR-11
piece handle=/archivelog/bak_10_1_745770568.bak tag=TAG20110314T142928 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 14-MAR-11
channel ORA_DISK_1: finished piece 1 at 14-MAR-11
piece handle=/archivelog/bak_11_1_745770603.bak tag=TAG20110314T142928 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 14-MAR-11
2、 在2个节点同时进行多次日志切换,生成多个日志文件。
SQL> alter system switch logfile;
System altered.
SQL> r
1* alter system switch logfile
System altered.
3、 再次在节点1进行全备份,这次备份归档备份集,并且删除备份了的归档日志文件
RMAN> backup format='/archivelog/bak_%t_%s_%p.bak' database plus archivelog delete all input
2> format '/archivelog/arch_%t_%s_%p.bak';
Starting backup at 14-MAR-11
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=125 instance=ppzhu2 devtype=DISK
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=119 recid=11 stamp=745538439
input archive log thread=1 sequence=120 recid=12 stamp=745556408
input archive log thread=1 sequence=121 recid=14 stamp=745572399
input archive log thread=1 sequence=122 recid=15 stamp=745606815
input archive log thread=1 sequence=123 recid=17 stamp=745639858
input archive log thread=1 sequence=124 recid=18 stamp=745659904
input archive log thread=1 sequence=125 recid=20 stamp=745693234
input archive log thread=1 sequence=126 recid=21 stamp=745725639
input archive log thread=1 sequence=127 recid=23 stamp=745761352
input archive log thread=1 sequence=128 recid=24 stamp=745761422
input archive log thread=1 sequence=129 recid=28 stamp=745770653
input archive log thread=1 sequence=130 recid=31 stamp=745770712
input archive log thread=1 sequence=131 recid=32 stamp=745770718
input archive log thread=1 sequence=132 recid=33 stamp=745771003
input archive log thread=2 sequence=94 recid=13 stamp=745556395
input archive log thread=2 sequence=95 recid=16 stamp=745619079
input archive log thread=2 sequence=96 recid=19 stamp=745680236
input archive log thread=2 sequence=97 recid=22 stamp=745744528
input archive log thread=2 sequence=98 recid=25 stamp=745761454
input archive log thread=2 sequence=99 recid=26 stamp=745761459
input archive log thread=2 sequence=100 recid=27 stamp=745770635
input archive log thread=2 sequence=101 recid=29 stamp=745770643
input archive log thread=2 sequence=102 recid=30 stamp=745770654
input archive log thread=2 sequence=103 recid=34 stamp=745770987
channel ORA_DISK_1: starting piece 1 at 14-MAR-11
channel ORA_DISK_1: finished piece 1 at 14-MAR-11
piece handle=/archivelog/arch_745770993_12_1.bak tag=TAG20110314T143632 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:36
channel ORA_DISK_1: deleting archive log(s)
archive log filename=/archivelog/1_119_743871413.dbf recid=11 stamp=745538439
archive log filename=/archivelog/1_120_743871413.dbf recid=12 stamp=745556408
archive log filename=/archivelog/1_121_743871413.dbf recid=14 stamp=745572399
archive log filename=/archivelog/1_122_743871413.dbf recid=15 stamp=745606815
archive log filename=/archivelog/1_123_743871413.dbf recid=17 stamp=745639858
archive log filename=/archivelog/1_124_743871413.dbf recid=18 stamp=745659904
archive log filename=/archivelog/1_125_743871413.dbf recid=20 stamp=745693234
archive log filename=/archivelog/1_126_743871413.dbf recid=21 stamp=745725639
archive log filename=/archivelog/1_127_743871413.dbf recid=23 stamp=745761352
archive log filename=/archivelog/1_128_743871413.dbf recid=24 stamp=745761422
archive log filename=/archivelog/1_129_743871413.dbf recid=28 stamp=745770653
archive log filename=/archivelog/1_130_743871413.dbf recid=31 stamp=745770712
archive log filename=/archivelog/1_131_743871413.dbf recid=32 stamp=745770718
archive log filename=/archivelog/1_132_743871413.dbf recid=33 stamp=745771003
archive log filename=/archivelog/2_94_743871413.dbf recid=13 stamp=745556395
archive log filename=/archivelog/2_95_743871413.dbf recid=16 stamp=745619079
archive log filename=/archivelog/2_96_743871413.dbf recid=19 stamp=745680236
archive log filename=/archivelog/2_97_743871413.dbf recid=22 stamp=745744528
archive log filename=/archivelog/2_98_743871413.dbf recid=25 stamp=745761454
archive log filename=/archivelog/2_99_743871413.dbf recid=26 stamp=745761459
archive log filename=/archivelog/2_100_743871413.dbf recid=27 stamp=745770635
archive log filename=/archivelog/2_101_743871413.dbf recid=29 stamp=745770643
archive log filename=/archivelog/2_102_743871413.dbf recid=30 stamp=745770654
archive log filename=/archivelog/2_103_743871413.dbf recid=34 stamp=745770987
Finished backup at 14-MAR-11
Starting backup at 14-MAR-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00004 name=/dev/raw/raw10
input datafile fno=00005 name=/dev/raw/raw8
input datafile fno=00001 name=/dev/raw/raw5
input datafile fno=00003 name=/dev/raw/raw6
input datafile fno=00002 name=/dev/raw/raw7
channel ORA_DISK_1: starting piece 1 at 14-MAR-11
channel ORA_DISK_1: finished piece 1 at 14-MAR-11
piece handle=/archivelog/bak_745771030_13_1.bak tag=TAG20110314T143709 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 14-MAR-11
channel ORA_DISK_1: finished piece 1 at 14-MAR-11
piece handle=/archivelog/bak_745771065_14_1.bak tag=TAG20110314T143709 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 14-MAR-11
Starting backup at 14-MAR-11
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=133 recid=36 stamp=745771084
input archive log thread=2 sequence=104 recid=35 stamp=745771067
channel ORA_DISK_1: starting piece 1 at 14-MAR-11
channel ORA_DISK_1: finished piece 1 at 14-MAR-11
piece handle=/archivelog/arch_745771069_15_1.bak tag=TAG20110314T143749 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
channel ORA_DISK_1: deleting archive log(s)
archive log filename=/archivelog/1_133_743871413.dbf recid=36 stamp=745771084
archive log filename=/archivelog/2_104_743871413.dbf recid=35 stamp=745771067
Finished backup at 14-MAR-11
可以看到这里我的归档日志文件和备份集都存放在/archivelog中。