发表于: 2008.10.01 23:57
分类: ORACLE
出处: http://yangtingkun.itpub.net/post/468/471642
---------------------------------------------------------------
利用现有环境创建一个DUPLICATE RAC环境。
由于篇幅限制,这篇描述DUPLICATE命令执行后的收尾操作。
恢复之RAC数据库DUPLICATE(一):http://yangtingkun.itpub.net/post/468/471508
恢复之RAC数据库DUPLICATE(二):http://yangtingkun.itpub.net/post/468/471520
DUPLICATE命令成功执行后,就可以退出RMAN,通过SQLPLUS来进行后续的处理了。
需要修改一下初始化参数CLUSTER_DATABASE为TRUE,并启动实例2;修改LOCAL_LISTENER,设置正确的IP地址;修改spfile的位置,使得SPFILE存放到ASM中:
RMAN> exit
Recovery Manager complete.
bash-3.00$ sqlplus "/ as sysdba"
SQL*Plus: Release 11.1.0.6.0 - Production on Mon Sep 8 20:45:57 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
SQL> show parameter spfile
NAME TYPE VALUE
--------------------- ----------- ------------------------------
spfile string /data/oracle/product/11.1/database/dbs/spfilerac11g1.ora
SQL> show parameter local_listener
NAME TYPE VALUE
--------------------- ----------- ------------------------------
local_listener string (ADDRESS=(PROTOCOL=TCP)(HOST=172.0.2.58)(PORT=1521))
SQL> show parameter cluster_database
NAME TYPE VALUE
-------------------------- ----------- ------------------------------
cluster_database boolean FALSE
cluster_database_instances integer 1
SQL> alter system set cluster_database = true scope = spfile;
System altered.
SQL> alter system set local_listener = '(ADDRESS=(PROTOCOL=TCP)(HOST=172.0.2.62)(PORT=1521))'
2 scope = spfile sid = 'rac11g1';
System altered.
SQL> alter system set local_listener = '(ADDRESS=(PROTOCOL=TCP)(HOST=172.0.2.63)(PORT=1521))'
2 scope = spfile sid = 'rac11g2';
System altered.
设置TEMP表空间:
SQL> alter database tempfile '+DATA/RAC11G/rac11g_temp_1_4g' drop;
Database altered.
SQL> alter tablespace temp add tempfile '+DATA/RAC11G/rac11g_temp_1_4g' size 4096m;
Tablespace altered.
下面关闭数据库,设置spfile和pfile,然后重新启动:
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> create pfile='/data/initrac11g.ora' from spfile;
File created.
SQL> create spfile='+DATA/RAC11G/spfilerac11g.ora' from pfile='/data/initrac11g.ora';
File created.
SQL> host
$ rm /data/oracle/product/11.1/database/dbs/spfilerac11g1.ora
$ echo "spfile=+DATA/RAC11G/spfilerac11g.ora" >> $ORACLE_HOME/dbs/initrac11g1.ora
$ exit
SQL> startup
ORACLE instance started.
Total System Global Area 1.7108E+10 bytes
Fixed Size 2101632 bytes
Variable Size 3747073664 bytes
Database Buffers 1.3355E+10 bytes
Redo Buffers 4431872 bytes
Database mounted.
Database opened.
SQL> show parameter spfile
NAME TYPE VALUE
-------------------------- ----------- ------------------------------
spfile string +DATA/rac11g/spfilerac11g.ora
SQL> show parameter local_listener
NAME TYPE VALUE
-------------------------- ----------- ------------------------------
local_listener string (ADDRESS=(PROTOCOL=TCP)(HOST=172.0.2.62)(PORT=1521))
SQL> show parameter cluster_database
NAME TYPE VALUE
-------------------------- ----------- ------------------------------
cluster_database boolean TRUE
cluster_database_instances integer 2
下面在节点二编辑初始化参数并启动实例:
$ echo "spfile=+DATA/RAC11G/spfilerac11g.ora" >> $ORACLE_HOME/dbs/initrac11g2.ora
$ sqlplus "/ as sysdba"
SQL*Plus: Release 11.1.0.6.0 - Production on 星期一 9月 8 21:04:57 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved.
已连接到空闲例程。
SQL> startup
ORACLE 例程已经启动。
Total System Global Area 1.7108E+10 bytes
Fixed Size 2101632 bytes
Variable Size 3612855936 bytes
Database Buffers 1.3489E+10 bytes
Redo Buffers 4431872 bytes数据库装载完毕。数据库已经打开。
SQL> select instance_name from gv$instance;
INSTANCE_NAME
----------------
rac11g2
rac11g1
SQL> select name from v$database;
NAME
---------
RAC11GS
至此DUPLICATE操作完成。
最后说明一下,由于DUPLICATE操作相对比较负载,难免会在中途出现错误。
这个时候如果直接执行命令,很可能出现下面的错误:
RMAN> duplicate target database to rac11gs
db_file_name_convert '/dev/vx/rdsk/datavg', '+DATA/RAC11G'
2> 3> spfile
4> parameter_value_convert '/dev/vx/rdsk/datavg', '+DATA/RAC11G'
5> set log_file_name_convert '/dev/vx/rdsk/datavg', '+DATA/RAC11G'
6> set log_archive_dest_1='LOCATION=+DATA/RAC11G'
7> set local_listener = ''
8> set cluster_database = 'false'
9> ;
Starting Duplicate Db at 08-SEP-08
using channel ORA_AUX_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 09/08/2008 20:29:16
RMAN-05500: the auxiliary database must be not mounted when issuing a DUPLICATE command
或者这样的错误:
RMAN> duplicate target database to rac11gs
2> db_file_name_convert '/dev/vx/rdsk/datavg', '+DATA/RAC11G'
3> spfile
4> parameter_value_convert '/dev/vx/rdsk/datavg', '+DATA/RAC11G'
5> set log_file_name_convert '/dev/vx/rdsk/datavg', '+DATA/RAC11G'
6> set log_archive_dest_1='LOCATION=+DATA/RAC11G'
7> set local_listener = ''
8> set cluster_database = 'false'
9> ;
Starting Duplicate Db at 08-SEP-08
using channel ORA_AUX_DISK_1
contents of Memory Script:
{
set until scn 26685490;
restore clone spfile to '/data/oracle/product/11.1/database/dbs/spfilerac11g1.ora';
sql clone "alter system set spfile= ''/data/oracle/product/11.1/database/dbs/spfilerac11g1.ora''";
}
executing Memory Script
executing command: SET until clause
Starting restore at 08-SEP-08
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 09/08/2008 20:02:13
RMAN-03015: error occurred in stored script Memory Script
ORA-32011: cannot restore SPFILE to location already being used by the instance
RMAN> duplicate target database to rac11gs
2> db_file_name_convert '/dev/vx/rdsk/datavg', '+DATA/RAC11G'
3> spfile
4> parameter_value_convert '/dev/vx/rdsk/datavg', '+DATA/RAC11G'
5> set log_file_name_convert '/dev/vx/rdsk/datavg', '+DATA/RAC11G'
6> set log_archive_dest_1='LOCATION=+DATA/RAC11G'
7> set local_listener = ''
8> set cluster_database = 'false'
9> ;
Starting Duplicate Db at 08-SEP-08
using channel ORA_AUX_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 09/08/2008 20:02:37
RMAN-06136: ORACLE error from auxiliary database: ORA-01565: error in identifying file '/data/oracle/product/11.1/database/dbs/spfilerac11g1.ora'
ORA-27037: unable to obtain file status
SVR4 Error: 2: No such file or directory
Additional information: 3
当出现这种情况的时候,可以退出rman,然后手工删除spfile:
RMAN> exit
Recovery Manager complete.
bash-3.00$ rm /data/oracle/product/11.1/database/dbs/spfilerac11g1.ora
bash-3.00$ rman target /
Recovery Manager: Release 11.1.0.6.0 - Production on Mon Sep 8 20:02:51 2008
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: RAC11GS (not mounted)
RMAN> shutdown immediate
using target database control file instead of recovery catalog
Oracle instance shut down
RMAN> startup nomount pfile=initrac11g1.ora
connected to target database (not started)
Oracle instance started
Total System Global Area 217219072 bytes
Fixed Size 2093360 bytes
Variable Size 160362192 bytes
Database Buffers 50331648 bytes
Redo Buffers 4431872 bytes
RMAN> exit
Recovery Manager complete.
bash-3.00$ rman target sys/test@172.0.2.54/rac11g.us.oracle.com catalog catalog_user/catalog_user@172.0.2.61/test11g.netdb auxiliary /
通过上面的步骤,就可以恢复到DUPLICATE开始的状态,然后重新执行。
如果DUPLICATE已经完成了RESTORE操作,那么DUPLICATE再次执行的时候会检查到数据文件已经还原过,然后跳过这个步骤,直接进行恢复。
最后的最后,如果CATALOG库以后仍然需要使用的话,应该将备份集的地址重新修改回来,否则rman的catalog方式恢复源数据库时,会找不到备份集:
SQL> conn catalog_user/catalog_user已连接。
SQL> select bp_key, handle from rc_backup_piece;
BP_KEY HANDLE
---------- ------------------------------------------------------------
1475 +DATA/backup/01jpk0bj_1_1
SQL> update rc_backup_piece set handle = '/data/01jpk0bj_1_1'
2 where bp_key = 1475;
已更新 1 行。
SQL> commit;
提交完成。











