Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2896169
  • 博文数量: 599
  • 博客积分: 16398
  • 博客等级: 上将
  • 技术积分: 6875
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-30 12:04
个人简介

WINDOWS下的程序员出身,偶尔也写一些linux平台下小程序, 后转行数据库行业,专注于ORACLE和DB2的运维和优化。 同时也是ios移动开发者。欢迎志同道合的朋友一起研究技术。 数据库技术交流群:58308065,23618606

文章分类

全部博文(599)

文章存档

2014年(12)

2013年(56)

2012年(199)

2011年(105)

2010年(128)

2009年(99)

分类: Oracle

2009-12-25 15:55:19

这篇文章描述为RAC环境创建STANDBY数据库。

由于篇幅限制,加上碰到了很多的bug,只能将文章拆分成多篇。

这章记录一下STANDBY数据库创建过程中碰到的问题。

RAC数据库建立STANDBY(一):http://yangtingkun.itpub.net/post/468/484988

RAC数据库建立STANDBY(二):http://yangtingkun.itpub.net/post/468/485013


刚刚在进行RAC环境的DUPLICATE DATABASE的时候,就碰到了很多问题,由于二者命令比较相似,本来认为这次不会碰到太多的问题,没有想到的是,这次碰到的问题居然比DUPLICATE碰到的问题多出一倍。而且基本上所有碰到的问题都是DUPLICATE操作时不曾遇到的。

最开始为了减少麻烦,打算采用SPFILE的方式,并且利用FROM ACTIVE DATABASE,这样可以不用读取备份集:

bash-3.00$ rman target sys/test@172.0.2.54/rac11g.us.oracle.com auxiliary /

恢复管理器: Release 11.1.0.6.0 - Production on 星期二 9 9 14:58:19 2008

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

连接到目标数据库: RAC11G (DBID=1712482917)已连接到辅助数据库: RAC11G (未装载)

RMAN> duplicate target database for standby
2> db_file_name_convert '/dev/vx/rdsk/datavg', '+DATA/RAC11G'
3> dorecover
4> from active database
5> spfile
6> parameter_value_convert '/dev/vx/rdsk/datavg', '+DATA/RAC11G'
7> set log_file_name_convert '/dev/vx/rdsk/datavg', '+DATA/RAC11G'
8> set log_archive_dest_1='LOCATION=+DATA/RAC11G'
9> ;

启动 Duplicate Db 09-9 -08使用目标数据库控制文件替代恢复目录分配的通道: ORA_AUX_DISK_1通道 ORA_AUX_DISK_1: SID=112 设备类型=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: Duplicate Db
命令 ( 09/09/2008 14:58:26 ) 失败

RMAN-06217:
未使用 Net 服务名连接到辅助数据库

这个RMAN-6217错误居然在metalink上都找不到,不过好在错误的描述比较清晰,只需要通过连接服务名的方式连接辅助实例即可。

继续尝试:

bash-3.00$ rman target sys/test@172.0.2.54/rac11g.us.oracle.com auxiliary sys/test@rac11g1

恢复管理器: Release 11.1.0.6.0 - Production on 星期二 9 9 15:16:52 2008

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

连接到目标数据库: RAC11G (DBID=1712482917)
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00554:
内部恢复管理器程序包初始化失败

RMAN-04006:
来自辅助数据库的错误: ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务

不过这里引发一个问题,由于10g以上默认采用动态注册,由于数据库没有启动,因此动态注册无法启用,没有办法通过服务名连接,只能手工编辑一个SID列表,添加到listener.ora文件中:

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = rac11g1)
(ORACLE_HOME = /data/oracle/product/11.1/database)
)
)

下面重启监听:

$ lsnrctl stop

LSNRCTL for Solaris: Version 11.1.0.6.0 - Production on 09-9 -2008 15:20:43

Copyright (c) 1991, 2007, Oracle. All rights reserved.

正在连接到 (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))命令执行成功
$ lsnrctl start

LSNRCTL for Solaris: Version 11.1.0.6.0 - Production on 09-9 -2008 15:20:55

Copyright (c) 1991, 2007, Oracle. All rights reserved.

启动/data/oracle/product/11.1/database/bin/tnslsnr: 请稍候...

TNSLSNR for Solaris: Version 11.1.0.6.0 - Production系统参数文件为/data/oracle/product/11.1/database/network/admin/listener.ora写入/data/oracle/diag/tnslsnr/ser1/listener/alert/log.xml的日志信息监听: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ser1)(PORT=1521)))

正在连接到 (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
LISTENER
STATUS
------------------------
别名
LISTENER版本 TNSLSNR for Solaris: Version 11.1.0.6.0 - Production启动日期 09-9-2008 15:20:55正常运行时间 0 0 小时 0 0 跟踪级别 off安全性 ON: Local OS Authentication
SNMP OFF
监听程序参数文件
/data/oracle/product/11.1/database/network/admin/listener.ora监听程序日志文件 /data/oracle/diag/tnslsnr/ser1/listener/alert/log.xml监听端点概要...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ser1)(PORT=1521)))
服务摘要
..服务 "rac11g1" 包含 1 个例程。
例程 "rac11g1", 状态 UNKNOWN, 包含此服务的 1 个处理程序...命令执行成功

再次连接错误依旧,这是由于默认配置的RAC环境的TNSNAMES中的服务名对当前不适用,添加一个新的服务名:

RAC11G1_S =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.0.2.62)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = rac11g1)
)
)

再次连接,报错没有权限:

bash-3.00$ rman target sys/test@172.0.2.54/rac11g.us.oracle.com auxiliary sys/test@rac11g1_s

恢复管理器: Release 11.1.0.6.0 - Production on 星期二 9 9 15:30:17 2008

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

连接到目标数据库: RAC11G (DBID=1712482917)
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00554:
内部恢复管理器程序包初始化失败

RMAN-04006:
来自辅助数据库的错误: ORA-01031: insufficient privileges

最简单的办法是拷贝源数据库的初始化参数文件到当前的节点的$ORACLE_HOME/dbs目录中,拷贝完成后,终于可以成功连接RMAN

bash-3.00$ rman target sys/test@172.0.2.54/rac11g.us.oracle.com auxiliary sys/test@rac11g1_s

恢复管理器: Release 11.1.0.6.0 - Production on 星期二 9 9 15:37:02 2008

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

连接到目标数据库: RAC11G (DBID=1712482917)已连接到辅助数据库: RAC11G (未装载)

执行DUPLICATE时报错:

RMAN> duplicate target database for standby
2> db_file_name_convert '/dev/vx/rdsk/datavg', '+DATA/RAC11G'
3> dorecover
4> from active database
5> spfile
6> parameter_value_convert '/dev/vx/rdsk/datavg', '+DATA/RAC11G'
7> set log_file_name_convert '/dev/vx/rdsk/datavg', '+DATA/RAC11G'
8> set log_archive_dest_1='LOCATION=+DATA/RAC11G'
9> ;

启动 Duplicate Db 09-9 -08使用目标数据库控制文件替代恢复目录分配的通道: ORA_AUX_DISK_1通道 ORA_AUX_DISK_1: SID=37 设备类型=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: Duplicate Db
命令 ( 09/09/2008 15:38:01 ) 失败

RMAN-06764: Must specify db_unique_name with FOR STANDBY

由于DUPLICATE创建STANDBY的时候会根据命令中指定的参数和源数据库的参数创建出STANDBY数据库的初始化参数,因此这里需要指明DB_UNIQUE_NAME参数,如此之外,应该把所有STANDBY数据库使用的参数配置完成。

除此之外,应该保证STANDBY数据库中配置了源数据库服务名RAC11G,而源数据库中配置了STANDBY数据库服务名RAC11G_S

再次执行DUPLICATE操作:

RMAN> duplicate target database for standby
2> db_file_name_convert '/dev/vx/rdsk/datavg', '+DATA/RAC11G'
3> dorecover
4> from active database
5> spfile
6> parameter_value_convert '/dev/vx/rdsk/datavg', '+DATA/RAC11G'
7> set log_file_name_convert '/dev/vx/rdsk/datavg', '+DATA/RAC11G'
8> set fal_client='RAC11G_S'
9> set fal_server='RAC11G'
10> set log_archive_dest_1='LOCATION=+DATA/RAC11G VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=rac11g_s'
11> set log_archive_dest_2='SERVICE=rac11g LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=rac11g'
12> set standby_archive_dest='+DATA/RAC11G'
13> set db_unique_name='rac11g_s'
14> ;

启动 Duplicate Db 09-9 -08使用通道 ORA_AUX_DISK_1

内存脚本的内容:
{
backup as copy reuse
file '/data/oracle/product/11.1/database/dbs/orapwrac11g2' auxiliary format
'/data/oracle/product/11.1/database/dbs/orapwrac11g1' file
'/dev/vx/rdsk/datavg/rac11g_spfile' auxiliary format
'+DATA/rac11g/spfilerac11g.ora' ;
sql clone "alter system set spfile= ''+DATA/rac11g/spfilerac11g.ora''";
}
正在执行内存脚本

启动 backup 09-9 -08分配的通道: ORA_DISK_1通道 ORA_DISK_1: SID=484 实例=rac11g2 设备类型=DISK
DBGANY: Mismatched message length! [16:06:39.742] (krmiduem)
DBGANY: Mismatched message length! [16:06:39.744] (krmiduem)
MAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00601: fatal error in recovery manager
RMAN-03004:
执行命令期间出现严重错误

RMAN-00600: internal error, arguments [3045] [] [] [] []
RMAN-03009: backup
命令 (ORA_DISK_1 通道上, 09/09/2008 16:06:39 ) 失败
ORA-17629:
无法连接到远程数据库服务器
ORA-17627: ORA-12154: TNS:
无法解析指定的连接标识符
ORA-17629:
无法连接到远程数据库服务器

这个错误是由于配置源数据库时没有使用VIP地址,而指定了一个实例的PUBLIC地址,这里应该使用VIP,确保RMAN可以同时连接到两个实例上:

bash-3.00$ rman target sys/test@rac11g auxiliary sys/test@rac11g1_s

Recovery Manager: Release 11.1.0.6.0 - Production on Tue Sep 9 16:11:23 2008

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

connected to target database: RAC11G (DBID=1712482917)
connected to auxiliary database: RAC11G (not mounted)

RMAN> duplicate target database for standby
2> db_file_name_convert '/dev/vx/rdsk/datavg', '+DATA/RAC11G'
3> dorecover
4> from active database
5> spfile
6> parameter_value_convert '/dev/vx/rdsk/datavg', '+DATA/RAC11G'
7> set log_file_name_convert '/dev/vx/rdsk/datavg', '+DATA/RAC11G'
8> set fal_client='RAC11G_S'
9> set fal_server='RAC11G'
10> set log_archive_dest_1='LOCATION=+DATA/RAC11G VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=rac11g_s'
11> set log_archive_dest_2='SERVICE=rac11g LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=rac11g'
12> set standby_archive_dest='+DATA/RAC11G'
13> set db_unique_name='rac11g_s'
;
14>
Starting Duplicate Db at 09-SEP-08
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=38 device type=DISK

contents of Memory Script:
{
backup as copy reuse
file '/data/oracle/product/11.1/database/dbs/orapwrac11g2' auxiliary format
'/data/oracle/product/11.1/database/dbs/orapwrac11g1' file
'/dev/vx/rdsk/datavg/rac11g_spfile' auxiliary format
'+DATA/rac11g/spfilerac11g.ora' ;
sql clone "alter system set spfile= ''+DATA/rac11g/spfilerac11g.ora''";
}
executing Memory Script

Starting backup at 09-SEP-08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=611 instance=rac11g1 device type=DISK
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 09/09/2008 16:11:41
ORA-17629: Cannot connect to the remote database server
ORA-17627: ORA-12154: TNS:could not resolve the connect identifier specified
ORA-17629: Cannot connect to the remote database server
continuing other job steps, job failed will not be re-run
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 09/09/2008 16:11:41
RMAN-03015: error occurred in stored script Memory Script
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 09/09/2008 16:11:41
ORA-17629: Cannot connect to the remote database server
ORA-17627: ORA-12154: TNS:could not resolve the connect identifier specified
ORA-17629: Cannot connect to the remote database server

采用本地配置的LOAD_BALANCE服务名,仍然出现上面的错误,看来最好的方式还是通过ALLOCATE CHANNEL的方式手工分配CHANNEL

bash-3.00$ rman target sys/test@rac11g auxiliary sys/test@rac11g1_s

Recovery Manager: Release 11.1.0.6.0 - Production on Tue Sep 9 16:17:44 2008

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

connected to target database: RAC11G (DBID=1712482917)
connected to auxiliary database: RAC11G (not mounted)

RMAN> run
2> {
3> allocate channel c1 device type disk connect 'sys/test@rac11g1';
4> allocate channel c2 device type disk connect 'sys/test@rac11g2';
5> allocate auxiliary channel ac1 device type disk;
6> allocate auxiliary channel ac2 device type disk;
7> duplicate target database for standby
8> db_file_name_convert '/dev/vx/rdsk/datavg', '+DATA/RAC11G'
9> dorecover
10> from active database
11> spfile
12> parameter_value_convert '/dev/vx/rdsk/datavg', '+DATA/RAC11G'
13> set log_file_name_convert '/dev/vx/rdsk/datavg', '+DATA/RAC11G'
14> set fal_client='RAC11G_S'
15> set fal_server='RAC11G'
16> set log_archive_dest_1='LOCATION=+DATA/RAC11G VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=rac11g_s'
17> set log_archive_dest_2='SERVICE=rac11g LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=rac11g'
18> set standby_archive_dest='+DATA/RAC11G'
19> set db_unique_name='rac11g_s';
20> }

using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=285 instance=rac11g1 device type=DISK

allocated channel: c2
channel c2: SID=119 instance=rac11g2 device type=DISK

allocated channel: ac1
channel ac1: SID=39 device type=DISK

allocated channel: ac2
channel ac2: SID=36 device type=DISK

Starting Duplicate Db at 09-SEP-08

contents of Memory Script:
{
backup as copy reuse
file '/data/oracle/product/11.1/database/dbs/orapwrac11g2' auxiliary format
'/data/oracle/product/11.1/database/dbs/orapwrac11g1' file
'/dev/vx/rdsk/datavg/rac11g_spfile' auxiliary format
'+DATA/rac11g/spfilerac11g.ora' ;
sql clone "alter system set spfile= ''+DATA/rac11g/spfilerac11g.ora''";
}
executing Memory Script

Starting backup at 09-SEP-08
RMAN-03009: failure of backup command on c1 channel at 09/09/2008 16:18:44
ORA-17629: Cannot connect to the remote database server
ORA-17627: ORA-12154: TNS:could not resolve the connect identifier specified
ORA-17629: Cannot connect to the remote database server
continuing other job steps, job failed will not be re-run
released channel: c1
released channel: c2
released channel: ac1
released channel: ac2
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 09/09/2008 16:18:44
RMAN-03015: error occurred in stored script Memory Script
RMAN-03009: failure of backup command on c2 channel at 09/09/2008 16:18:44
ORA-17629: Cannot connect to the remote database server
ORA-17627: ORA-12154: TNS:could not resolve the connect identifier specified
ORA-17629: Cannot connect to the remote database server

RMAN> exit


Recovery Manager complete.

这个错误是由于远端配置的tnsnames.ora中存在问题,尝试在源数据库连接目标数据库环境也报错ORA-12154,增加RAC11G1_S服务名后,问题解决:

RAC11G1_S =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.0.2.62)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = rac11g1)
)
)

由于错误太多,只能在下一篇文章中继续描述。

阅读(1836) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~