[[toc]]

适用范围

ORACLE 11g DG Broker 切换报ORA-12545

问题概述

ORACLE RAC 到单机 DG Broker 配置与切换 的切换过程中遇到 ORA-12545: Connect failed because target host or object does not exist 具体报错如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
DGMGRL> switchover to rac11g;
Performing switchover NOW, please wait...
Operation requires a connection to instance "rac11g1" on database "rac11g"
Connecting to instance "rac11g1"...
Connected.
New primary database "rac11g" is opening...
Operation requires startup of instance "RAC11GDG" on database "rac11gdg"
Starting instance "RAC11GDG"...
Unable to connect to database
ORA-12545: Connect failed because target host or object does not exist

Failed.
Warning: You are no longer connected to ORACLE.

Please complete the following steps to finish switchover:
start up instance "RAC11GDG" of database "rac11gdg"

问题原因

DG Broker 中的staticConnectidentifier 配置为hostname,主库无法解析此 hostname,导致无法连接。

处理过程

检查 rac11gdg 详细信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
DGMGRL> show database verbose  rac11gdg

Database - rac11gdg

Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: (unknown)
Apply Lag: (unknown)
Apply Rate: (unknown)
Real Time Query: OFF
Instance(s):
RAC11GDG

Properties:
DGConnectIdentifier = 'rac11gdg_rac11g'
ObserverConnectIdentifier = ''
LogXptMode = 'ASYNC'
DelayMins = '0'
Binding = 'OPTIONAL'
MaxFailure = '0'
MaxConnections = '1'
ReopenSecs = '300'
NetTimeout = '30'
RedoCompression = 'DISABLE'
LogShipping = 'ON'
PreferredApplyInstance = ''
ApplyInstanceTimeout = '0'
ApplyParallel = 'AUTO'
StandbyFileManagement = 'AUTO'
ArchiveLagTarget = '600'
LogArchiveMaxProcesses = '4'
LogArchiveMinSucceedDest = '1'
DbFileNameConvert = ''
LogFileNameConvert = ''
FastStartFailoverTarget = ''
InconsistentProperties = '(monitor)'
InconsistentLogXptProps = '(monitor)'
SendQEntries = '(monitor)'
LogXptStatus = '(monitor)'
RecvQEntries = '(monitor)'
ApplyLagThreshold = '0'
TransportLagThreshold = '0'
TransportDisconnectedThreshold = '30'
SidName = 'RAC11GDG'
StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dgbrok)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=RAC11GDG_DGMGRL)(INSTANCE_NAME=RAC11GDG)(SERVER=DEDICATED)))'
StandbyArchiveLocation = '/oradg'
AlternateLocation = ''
LogArchiveTrace = '0'
LogArchiveFormat = '%t_%s_%r.dbf'
TopWaitEvents = '(monitor)'

Database Status:
DGM-17016: failed to retrieve status for database "rac11gdg"
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
ORA-16625: cannot reach database "rac11gdg"

可以看到在最后报无法连接rac11gdg,检查上面的信息发现

1
StaticConnectIdentifier         = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dgbrok)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=RAC11GDG_DGMGRL)(INSTANCE_NAME=RAC11GDG)(SERVER=DEDICATED)))'

StaticConnectIdentifier中的 HOST 写的是hostname,而在主服务器是无法解析此hostname的。

检查 rac11g 数据库alert 日志发现如下,提示无法连接

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
***********************************************************************

Fatal NI connect error 12514, connecting to:
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.8.8.201)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=rac11gdg_DGB)(CID=(PROGRAM=oracle)(HOST=11g-node1)(USER=grid))))

VERSION INFORMATION:
TNS for Linux: Version 11.2.0.4.0 - Production
TCP/IP NT Protocol Adapter for Linux: Version 11.2.0.4.0 - Production
Time: 08-FEB-2023 10:22:56
Tracing not turned on.
Tns error struct:
ns main err code: 12564

TNS-12564: TNS:connection refused
ns secondary err code: 0
nt main err code: 0
nt secondary err code: 0
nt OS err code: 0

回切过程的提示为:

1
2
Please complete the following steps to finish switchover:
start up instance "RAC11GDG" of database "rac11gdg"

要完成接下来的切换,需要去启动RAC11GDG,接下来手动启动 RAC11GDG ,查看 DG Broker 状态

1
2
3
4
5
6
7
8
9
10
11
12
13
14
DGMGRL>  show configuration;

Configuration - dgbrok

Protection Mode: MaxPerformance
Databases:
rac11g - Primary database
rac11gdg - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
ORA-16610: command "SWITCHOVER TO rac11gdg" in progress
DGM-17017: unable to determine configuration status

可以看到 SWITCHOVER 操作正在执行,无法查看状态,过1-2分钟继续查看,恢复正常。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
DGMGRL>  show configuration;

Configuration - dgbrok

Protection Mode: MaxPerformance
Databases:
rac11g - Primary database
rac11gdg - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

DGMGRL>

首先,手动启动rac11gdg库,会自动回复正常。

那为什么会出现 ORA-12545呢,通过上面的日志可以查看,日志报的连接 172.8.8.201SERVICE_NAME=rac11gdg_DGB 无法连接,我们知道,_DGB 服务是在数据库启动之后动态注册的,目前数据库是关闭的,DGMGRL 切换提示的是启动数据库过程中失败,无法连接数据库

1
2
3
Starting instance "RAC11GDG"...
Unable to connect to database
ORA-12545: Connect failed because target host or object does not exist

那这个连接数据库启动数据库是通过 RAC11GDG_DGMGRL服务连接的,也就是 RAC11GDG_DGMGRL 服务无法连接,_DGMGRL 的连接配置是在 StaticConnectIdentifier 里的,通过查 StaticConnectIdentifier 配置的 host 是主机名称。但是在主库上是无法解析这个主机名称的,所以只要能让主库能解析道这个主机名称即可,所以方案有2个如下:

解决方案

1、修改/etc/hosts ,将 iphostname 写入 /etc/hosts;
或者
2、DGMGRL 中 staticConnectidentifier 中的 HOST 修改为ip地址。
命令类似如下:

1
DGMGRL> edit database rac11gdg set property staticConnectidentifier ='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.8.8.201)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=rac11gdg_DGMGRL)(INSTANCE_NAME=rac11gdg)(SERVER=DEDICATED)))';

原文作者: liups.com

原文链接: http://liups.cn/posts/be693ca6/

许可协议: 知识共享署名-非商业性使用 4.0 国际许可协议