将Oracle 10g RAC库用rman 的方式备份并恢复到异机单机


转载时请务必以超链接形式标明文章 原始出处和作者信息及 本版权声明
链接: http://www.dbasky.net/archives/2009/04/oracle-10g-racrman.html
上次讲了如何在 RAC环境下通过connect 到数据库的实例,做备份与恢复,今天来说下把 RAC库用rman 的方式备份并恢复到异机单机,其实原理和方法都是大同小异的。
      主RAC库:2个节点 rac1(192.168.1.127),rac2(192.168.1.128) 采用ASM+RAW
备机 standby(192.168.1.240)  文件系统
 一在rac库备份:
rac1-> crs_stat -t
Name           Type           Target    State     Host       
------------------------------------------------------------
ora....SM1.asm application    ONLINE    ONLINE    rac1       
ora....C1.lsnr application    ONLINE    ONLINE    rac1       
ora.rac1.gsd   application    ONLINE    ONLINE    rac1       
ora.rac1.ons   application    ONLINE    ONLINE    rac1       
ora.rac1.vip   application    ONLINE    ONLINE    rac1       
ora....SM2.asm application    ONLINE    ONLINE    rac2       
ora....C2.lsnr application    ONLINE    ONLINE    rac2       
ora.rac2.gsd   application    ONLINE    ONLINE    rac2       
ora.rac2.ons   application    ONLINE    ONLINE    rac2       
ora.rac2.vip   application    ONLINE    ONLINE    rac2       
ora.racdb.db   application    ONLINE    ONLINE    rac1       
ora....b1.inst application    ONLINE    ONLINE    rac1       
ora....b2.inst application    ONLINE    ONLINE    rac2       
rac1->
rac1-> export ORACLE_SID=racdb1
rac1-> rman target / nocatalog
    
RMAN> run{
2>  allocate CHANNEL ch00  type DISK  CONNECT 'sys/oracle@racdb1'; 
3>  allocate CHANNEL ch01  type DISK  CONNECT 'sys/oracle@racdb2'; 
4>  backup database    format '/rmanset/racdb_full_%d%t%s%p'         tag 'fullbackup';
5>  BACKUP FORMAT '/rmanset/%d_arch_%s_%p_%h' ARCHIVELOG ALL;                                         
6>  backup format '/rmanset/cf_%d_%s_%p'
7>          (current controlfile);
8>     RELEASE CHANNEL ch00;                                                         
9>     RELEASE CHANNEL ch01;                                                        
10>   }

allocated channel: ch00
channel ch00: sid=148 instance=racdb1 devtype=DISK

allocated channel: ch01
channel ch01: sid=148 instance=racdb2 devtype=DISK

Starting backup at 02-NOV-08
channel ch00: starting full datafile backupset
channel ch00: specifying datafile(s) in backupset
input datafile fno=00001 name=+RACDATA/racdb/datafile/system.259.669487425
input datafile fno=00005 name=+RACDATA/racdb/datafile/users.264.669487561
input datafile fno=00004 name=+RACDATA/racdb/datafile/undotbs2.263.669487539
channel ch00: starting piece 1 at 02-NOV-08
channel ch01: starting full datafile backupset
channel ch01: 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
channel ch01: starting piece 1 at 02-NOV-08
channel ch00: finished piece 1 at 02-NOV-08
piece handle=/rmanset/racdb_full_RACDB669769770931 tag=FULLBACKUP comment=NONE
channel ch00: backup set complete, elapsed time: 00:02:19
channel ch00: starting full datafile backupset
channel ch00: specifying datafile(s) in backupset
including current control file in backupset
channel ch00: starting piece 1 at 02-NOV-08
channel ch01: finished piece 1 at 02-NOV-08
piece handle=/rmanset/racdb_full_RACDB669769784941 tag=FULLBACKUP comment=NONE
channel ch01: backup set complete, elapsed time: 00:02:28
channel ch01: starting full datafile backupset
channel ch01: specifying datafile(s) in backupset
including current SPFILE in backupset
channel ch01: starting piece 1 at 02-NOV-08
channel ch00: finished piece 1 at 02-NOV-08
piece handle=/rmanset/racdb_full_RACDB669769914951 tag=FULLBACKUP comment=NONE
channel ch00: backup set complete, elapsed time: 00:00:11
channel ch01: finished piece 1 at 02-NOV-08
piece handle=/rmanset/racdb_full_RACDB669769933961 tag=FULLBACKUP comment=NONE
channel ch01: backup set complete, elapsed time: 00:00:05
Finished backup at 02-NOV-08

Starting backup at 02-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=42 recid=141 stamp=669603048
input archive log thread=1 sequence=44 recid=149 stamp=669640424
input archive log thread=1 sequence=45 recid=151 stamp=669675778
input archive log thread=1 sequence=46 recid=152 stamp=669679426
input archive log thread=1 sequence=47 recid=156 stamp=669690456
channel ch00: starting piece 1 at 02-NOV-08
channel ch01: starting archive log backupset
channel ch01: specifying archive log(s) in backup set
input archive log thread=1 sequence=53 recid=170 stamp=669767346
input archive log thread=1 sequence=54 recid=172 stamp=669769357
input archive log thread=2 sequence=44 recid=165 stamp=669764276
input archive log thread=2 sequence=45 recid=167 stamp=669765472
input archive log thread=2 sequence=46 recid=168 stamp=669765474
input archive log thread=2 sequence=47 recid=169 stamp=669767345
input archive log thread=2 sequence=48 recid=171 stamp=669769352
input archive log thread=2 sequence=49 recid=175 stamp=669769944
channel ch01: starting piece 1 at 02-NOV-08
channel ch01: finished piece 1 at 02-NOV-08
piece handle=/rmanset/RACDB_arch_98_1_2 tag=TAG20081102T231211 comment=NONE
channel ch01: backup set complete, elapsed time: 00:00:04
channel ch00: finished piece 1 at 02-NOV-08
piece handle=/rmanset/RACDB_arch_97_1_1 tag=TAG20081102T231211 comment=NONE
channel ch00: backup set complete, elapsed time: 00:00:11
channel ch00: starting archive log backupset
channel ch00: specifying archive log(s) in backup set
input archive log thread=1 sequence=48 recid=158 stamp=669690550
input archive log thread=1 sequence=49 recid=160 stamp=669691146
input archive log thread=1 sequence=50 recid=162 stamp=669755973
input archive log thread=1 sequence=51 recid=163 stamp=669757116
input archive log thread=1 sequence=52 recid=166 stamp=669764278
input archive log thread=1 sequence=55 recid=173 stamp=669769375
input archive log thread=1 sequence=56 recid=174 stamp=669769928
channel ch00: starting piece 1 at 02-NOV-08
channel ch00: finished piece 1 at 02-NOV-08
piece handle=/rmanset/RACDB_arch_99_1_1 tag=TAG20081102T231211 comment=NONE
channel ch00: backup set complete, elapsed time: 00:00:08
Finished backup at 02-NOV-08

Starting backup at 02-NOV-08
channel ch00: starting full datafile backupset
channel ch00: specifying datafile(s) in backupset
including current control file in backupset
channel ch00: starting piece 1 at 02-NOV-08
channel ch00: finished piece 1 at 02-NOV-08
piece handle=/rmanset/cf_RACDB_100_1 tag=TAG20081102T231235 comment=NONE
channel ch00: backup set complete, elapsed time: 00:00:07
Finished backup at 02-NOV-08

released channel: ch00

released channel: ch01

2. 在rac库上创建pfile

SQL> create pfile='/rmanset/initracdb.ora' from spfile;


将rac1,rac2上的备份出来的rman文件和pfile上传到standby 主机   
 

二:  standby  主机做恢复的过程:
0.修改上传好的pfile文件,主要是rac中一些参数去掉:

#*.cluster_database_instances=2
*.cluster_database=false
#racdb2.instance_number=2
#racdb1.instance_number=1
#racdb2.thread=2
#racdb1.thread=1
#racdb2.undo_tablespace='UNDOTBS2'

#*.db_file_name_convert='+RACDATA/racdb/datafile/','/oradata/racdb/'
#*.fal_client='RACDB'
#*.fal_server='STANDBY'
#*.log_archive_config='DG_CONFIG=(racdb,standby)'
#racdb2.log_archive_dest_1='LOCATION=/racdb2_arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=racdb'
#*.log_archive_dest_2='SERVICE=standby LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=standby'
#*.log_archive_dest_state_2='ENABLE'
#*.log_file_name_convert='+RACDATA/racdb/onlinelog/','/oradata/racdb/'
#*.remote_listener='LISTENERS_RACDB'
#*.standby_file_management='AUTO'

1.数据库启动到nomount
    
2.restore controlfile

3.restore archivelog

4.recover database

5.改变logfile 的位置,重新建redo

6.drop 一个undo tablespace.

7.add a temp tablespace

8. 配tnsnames.ora 和listener.ora  (这里主要修改下单机的状态)。


下为操作的过程:
    
    
standby-> rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Sun Nov 2 14:22:39 2008

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: racdb (not mounted)
--恢复controlfile
RMAN> restore controlfile from '/rmanset/cf_RACDB_100_1';

Starting restore at 02-NOV-08
using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:05
output filename=/oradata/racdb/control01.ctl
Finished restore at 02-NOV-08


---restore datafile and archive log

RMAN> sql 'alter database mount';

sql statement: alter database mount
released channel: ORA_DISK_1

RMAN> run{
2> set until sequence 57 thread 1;
3> set newname for datafile 1 to '/oradata/racdb/system01.dbf';
4> set newname for datafile 2 to '/oradata/racdb/undotbs01.dbf';
5> set newname for datafile 3 to '/oradata/racdb/sysaux01.dbf';
6> set newname for datafile 4 to '/oradata/racdb/users01.dbf'; 
7> set newname for datafile 5 to '/oradata/racdb/undotbs02.dbf';
8> restore database;
9> switch datafile all;
10> }

executing command: SET until clause

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 02-NOV-08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /oradata/racdb/system01.dbf
restoring datafile 00004 to /oradata/racdb/users01.dbf
restoring datafile 00005 to /oradata/racdb/undotbs02.dbf
channel ORA_DISK_1: reading from backup piece /rmanset/racdb_full_RACDB669769770931
channel ORA_DISK_1: restored backup piece 1
piece handle=/rmanset/racdb_full_RACDB669769770931 tag=FULLBACKUP
channel ORA_DISK_1: restore complete, elapsed time: 00:00:36
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00002 to /oradata/racdb/undotbs01.dbf
restoring datafile 00003 to /oradata/racdb/sysaux01.dbf
channel ORA_DISK_1: reading from backup piece /rmanset/racdb_full_RACDB669769784941
channel ORA_DISK_1: restored backup piece 1
piece handle=/rmanset/racdb_full_RACDB669769784941 tag=FULLBACKUP
channel ORA_DISK_1: restore complete, elapsed time: 00:00:35
Finished restore at 02-NOV-08

datafile 1 switched to datafile copy
input datafile copy recid=10 stamp=669738296 filename=/oradata/racdb/system01.dbf
datafile 2 switched to datafile copy
input datafile copy recid=11 stamp=669738296 filename=/oradata/racdb/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=12 stamp=669738296 filename=/oradata/racdb/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=13 stamp=669738297 filename=/oradata/racdb/users01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=14 stamp=669738297 filename=/oradata/racdb/undotbs02.dbf

RMAN>

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/90618/viewspace-669739/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/90618/viewspace-669739/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值