Linux AS 5.3
Oracle 10.2.0.4 RAC , 2个节点
要做两个节点的Standby RAC 或单机的Standby .
1. 在RAC节点1上建立一个/u01/backup目录用于存储primary db的rman备份集。
[oracle@chicago_host1 stage]$ rman target /
RMAN> BACKUP DEVICE TYPE DISK FORMAT '/u01/backup/%U' DATABASE PLUS ARCHIVELOG;
RMAN> BACKUP DEVICE TYPE DISK FORMAT '/u01/backup/%U' CURRENT CONTROLFILE FOR STANDBY;
2. 安装Standby的RAC系统,包括cluster, db software, dbca建库,取同样的db名称,
在 Standby RAC节点1 上将数据库shutdown 然后置为
SQL> startup nomount
3. 在RAC Standby 节点1上建立 /u01/backup 同样的目录,拷贝primary db上的rman备份集到
Standby节点1的这个目录。
4. 在Standby节点1上tnsnames.ora 中加入连接primary db节点1的别名比如orcl_pri .
5. 准备开始恢复RMAN备份集到Standby 节点1上。
在主库上执行 SQL> alter system archive log current ;
检查是否有将spfile 及 orapwd 同步到 standby上 。
rac01sty$cd backup/
rac01sty$ls
01l277gl_1_1 03l277i0_1_1 05l277jq_1_1 listener.ora
02l277h6_1_1 04l277i9_1_1 initORCL.ora tnsnames.ora
rac01sty$rman target sys/oracle@orcl_pri auxiliary /
Recovery Manager: Release 10.2.0.4.0 - Production on Wed Dec 30 05:50:35 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1234616916)
connected to auxiliary database: ORCL (not mounted)
RMAN> duplicate target database for standby nofilenamecheck;
Starting Duplicate Db at 30-DEC-09
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=149 instance=orcl1 devtype=DISK
contents of Memory Script.:
{
restore clone standby controlfile;
sql clone 'alter database mount standby database';
}
executing Memory Script
Starting restore at 30-DEC-09
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /u01/backup/05l277jq_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u01/backup/05l277jq_1_1 tag=TAG20091230T143642
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output filename=/ocfs_data/orcl/control01.ctl
output filename=/ocfs_data/orcl/control02.ctl
output filename=/ocfs_data/orcl/control03.ctl
Finished restore at 30-DEC-09
sql statement: alter database mount standby database
released channel: ORA_AUX_DISK_1
contents of Memory Script.:
{
set newname for tempfile 1 to
"/ocfs_data/orcl/temp01.dbf";
switch clone tempfile all;
set newname for datafile 1 to
"/ocfs_data/orcl/system01.dbf";
set newname for datafile 2 to
"/ocfs_data/orcl/undotbs01.dbf";
set newname for datafile 3 to
"/ocfs_data/orcl/sysaux01.dbf";
set newname for datafile 4 to
"/ocfs_data/orcl/users01.dbf";
set newname for datafile 5 to
"/ocfs_data/orcl/undotbs02.dbf";
restore
check readonly
clone database
;
}
executing Memory Script
executing command: SET NEWNAME
renamed temporary file 1 to /ocfs_data/orcl/temp01.dbf in control file
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 30-DEC-09
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=149 instance=orcl1 devtype=DISK
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /ocfs_data/orcl/system01.dbf
restoring datafile 00002 to /ocfs_data/orcl/undotbs01.dbf
restoring datafile 00003 to /ocfs_data/orcl/sysaux01.dbf
restoring datafile 00004 to /ocfs_data/orcl/users01.dbf
restoring datafile 00005 to /ocfs_data/orcl/undotbs02.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/backup/02l277h6_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u01/backup/02l277h6_1_1 tag=TAG20091230T143518
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:25
Finished restore at 30-DEC-09
contents of Memory Script.:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy recid=6 stamp=706945969 filename=/ocfs_data/orcl/system01.dbf
datafile 2 switched to datafile copy
input datafile copy recid=7 stamp=706945969 filename=/ocfs_data/orcl/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=8 stamp=706945969 filename=/ocfs_data/orcl/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=9 stamp=706945969 filename=/ocfs_data/orcl/users01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=10 stamp=706945969 filename=/ocfs_data/orcl/undotbs02.dbf
Finished Duplicate Db at 30-DEC-09
如遇到無法找到備份集文件,則可執行如下命令來設置:
RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/ opt/oracle/stage /%U';
(一般在target備份時已經設置過一般是不需要了,只要確保路徑是一致的就OK)
6. 我们可以在执行dupliate db 的standby 节点1上查看到数据库V$database的open_mode 是mounted standby状态, 查看
它的alert log 为:
Wed Dec 30 05:52:19 2009
ARC0: Becoming the 'no FAL' ARCH
ARC0: Becoming the 'no SRL' ARCH
ARC0: Thread not mounted
ARC1 started with pid=25, OS id=10754
ARC1: Becoming the heartbeat ARCH
ARC1: Thread not mounted
Wed Dec 30 05:52:19 2009
Successful mount of redo thread 1, with mount id 1234721550
Wed Dec 30 05:52:19 2009
Physical Standby Database mounted.
Completed: alter database mount standby database
Wed Dec 30 05:52:24 2009
Full restore complete of datafile 4 /ocfs_data/orcl/users01.dbf. Elapsed time: 0:00:00
checkpoint is 728032
Full restore complete of datafile 2 /ocfs_data/orcl/undotbs01.dbf. Elapsed time: 0:00:00
checkpoint is 728032
last deallocation scn is 722327
Full restore complete of datafile 5 /ocfs_data/orcl/undotbs02.dbf. Elapsed time: 0:00:01
checkpoint is 728032
last deallocation scn is 668928
Wed Dec 30 05:52:38 2009
Full restore complete of datafile 3 /ocfs_data/orcl/sysaux01.dbf. Elapsed time: 0:00:14
checkpoint is 728032
last deallocation scn is 472064
Full restore complete of datafile 1 /ocfs_data/orcl/system01.dbf. Elapsed time: 0:00:19
checkpoint is 728032
last deallocation scn is 475626
Wed Dec 30 05:52:49 2009
Switch of datafile 1 complete to datafile copy
checkpoint is 728032
Switch of datafile 2 complete to datafile copy
checkpoint is 728032
Switch of datafile 3 complete to datafile copy
checkpoint is 728032
Switch of datafile 4 complete to datafile copy
checkpoint is 728032
Switch of datafile 5 complete to datafile copy
checkpoint is 728032
7. ok, 现在已经在RAC Standby 节点1上实现了physical standby, 可以类似单机standby一样操作 。
SQL> alter database open read only;
Database altered.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 339738624 bytes
Fixed Size 1267380 bytes
Variable Size 109054284 bytes
Database Buffers 226492416 bytes
Redo Buffers 2924544 bytes
SQL> alter database mount standby database;
Database altered.
SQL>
8. 如果需要激活, 可能需要修改一些spfile中的参数,加入或修改 redo, undo 等 。
9. 當RAC Standby重啟后,crs默認會自動將database開啟成open read only模式,這時如果下recover命令會
報錯無法close database,因此,對於物理standby來說,最好使用以下命令將crs開啟設置為自動開啟為mount狀態:
Srvctl modify database -d orcl -r PHYSICAL_STANDBY-s mount
10. 激活Physical Standby .
注意: 激活physical standby之前, 需要關閉兩個standby RAC實例, 然后在rac1上激活數據庫并開啟 。
SQL> startup nomount
SQL> alter database mount standby database;
SQL> alter database activate standby database;
SQL> alter database mount;
SQL> alter database open ;
SQL> shutdown immediate ;
SQL> startup
確認spfile沒有問題后,在第二個Standby RAC節點 SQL> startup
同樣, 如果没有使用Data Guard broker,CRS就无法知道primary和standby的角色转换,可能就需要手工
修改OCR的状态信息。 命令如下:
$ srvctl modify database -d wmb2bprd -r PRIMARY -s open
(standby節點1執行即可, RAC以后开启都会自動open)
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/35489/viewspace-624192/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/35489/viewspace-624192/