现象
Oracle 11.2.0.4的rac不能监听public ip,很奇怪:
[root@abrac1 admin]# srvctl stop listener
[root@abrac1 admin]# srvctl start listener
[root@abrac1 admin]# lsnrctl status
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 01-DEC-2022 16:24:34
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 01-DEC-2022 16:24:29
Uptime 0 days 0 hr. 0 min. 5 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/11.2.0.4/grid/network/admin/listener.ora
Listener Log File /u01/app/grid/diag/tnslsnr/abrac1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1522)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.30.7.83)(PORT=1522)))
Services Summary...
Service "abclogy" has 1 instance(s).
Instance "abclogy1", status READY, has 1 handler(s) for this service...
Service "abclogyXDB" has 1 instance(s).
Instance "abclogy1", status READY, has 1 handler(s) for this service...
The command completed successfully
[root@abrac1 admin]# ll
total 32
-rw-r--r-- 1 grid oinstall 182 Dec 1 16:24 endpoints_listener.ora
-rw-r--r-- 1 grid oinstall 171 Dec 1 16:24 endpoints_listener.ora.bak.abrac1
-rw-r--r-- 1 grid oinstall 184 Nov 24 19:22 listener2211247PM2235.bak
-rw-r--r-- 1 grid oinstall 350 Nov 24 19:22 listener.ora
-rw-r--r-- 1 grid oinstall 184 Nov 24 19:10 listener.ora.bak.abrac1
drwxr-xr-x 2 grid oinstall 4096 Nov 24 18:58 samples
-rw-r--r-- 1 grid oinstall 381 Dec 17 2012 shrept.lst
-rw-r--r-- 1 grid oinstall 218 Nov 24 19:22 sqlnet.ora
[root@abrac1 admin]# more endpoints_listener.ora
LISTENER_abRAC1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=abrac1-vip)(PORT=1522))(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1522)(IP=FIRST)))) # line added by Agent
[root@abrac1 admin]#
[oracle@abrac1 ~]$ sas
SQL*Plus: Release 11.2.0.4.0 Production on Thu Dec 1 16:27:32 2022
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
SQL> show parameter local
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
local_listener string (DESCRIPTION=(ADDRESS=(PROTOCO
L=tcp)(HOST=172.30.7.83)(PORT=
1522))), (DESCRIPTION=(ADDRESS
=(PROTOCOL=tcp)(HOST=172.30.7.
81)(PORT=1522)))
log_archive_local_first boolean TRUE
parallel_force_local boolean FALSE
解决
修改监听文件/u01/app/11.2.0.4/grid/network/admin/listener.ora
文件,增加如下内容:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.30.7.81)(PORT = 1522))
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.30.7.83)(PORT = 1522))
)
)
查看:
[root@abrac1 admin]# cat endpoints_listener.ora
LISTENER_OARAC1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=abrac1-vip)(PORT=1522))(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1522)(IP=FIRST)))) # line added by Agent
[root@oarac1 admin]# cat listener.ora
LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))) # line added by Agent
LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1)))) # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.30.7.81)(PORT = 1522))
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.30.7.83)(PORT = 1522))
)
)
[root@abrac1 admin]# pwd
/u01/app/11.2.0.4/grid/network/admin
[root@abrac1 admin]#
然后重启监听即可:
srvctl stop listener
srvctl start listener
-- 检查
tnsping 172.30.7.81:1522/abclogy
tnsping 172.30.7.82:1522/abclogy
tnsping 172.30.7.83:1522/abclogy
tnsping 172.30.7.84:1522/abclogy
tnsping 172.30.7.85:1522/abclogy
结果:
[root@abrac1 admin]# lsnrctl status
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 01-DEC-2022 16:59:18
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.30.7.82)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 01-DEC-2022 16:56:23
Uptime 0 days 0 hr. 2 min. 55 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/11.2.0.4/grid/network/admin/listener.ora
Listener Log File /u01/app/grid/diag/tnslsnr/oarac2/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.30.7.81)(PORT=1522)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.30.7.83)(PORT=1522)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1522)))
Services Summary...
Service "abclogy" has 1 instance(s).
Instance "abclogy2", status READY, has 1 handler(s) for this service...
Service "abclogyXDB" has 1 instance(s).
Instance "abclogy2", status READY, has 1 handler(s) for this service...
The command completed successfully
[root@abrac1 admin]# cat /etc/hosts
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1 localhost abrac2 localhost.localdomain localhost4 localhost4.localdomain4
172.30.7.81 abrac1
172.30.7.82 abrac2
172.30.7.83 abrac1-vip
172.30.7.84 abrac2-vip
1.1.4.1 abrac1-priv
1.1.4.2 abrac2-priv
172.30.7.85 abrac-scan
[root@abrac1 admin]#
可见,public和vip都已经被监听了。
其它原因 (Doc ID 1597716.1)
文件/etc/nsswitch.conf
的权限问题:
chmod 666 /etc/nsswitch.conf
日志文件:/u01/app/11.2.0.4/grid/log/oarac2/agent/crsd/oraagent_grid/oraagent_grid.log
文件endpoints_listener.ora
不能直接修改,因为重启监听又回到最初的状态了。
Public IP Endpoint is not registered for Listener in 11.2 RAC (Doc ID 1597716.1)
APPLIES TO:
Oracle Database - Enterprise Edition - Version 11.2.0.1 to 11.2.0.4 [Release 11.2]
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Oracle Database Backup Service - Version N/A and later
Generic (Platform Independent)
SYMPTOMS
This is two node RAC, ONS fails to start, listener starts successful, but Public IP ENDPOINT is not dynamically registered to the Listener.
- lsnrctl status shows only VIP Endpoint registered, Public IP Endpoint not registered.
$ lsnrctl status
...
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))) <<<<< only VIP Endpoint
- oraagent_grid.log shows ONS fails to start.
2013-08-26 13:14:11.097: AGFW {2:27079:629} Agent sending reply for: RESOURCE_START[ora.ons 1] ID 4098:744107
2013-08-26 13:14:11.098: ora.ons {2:27079:629} [check] OnsAgent::check {
2013-08-26 13:14:11.098: ora.ons {2:27079:629} [check] getOracleHomeAttrib: oracle_home = <GRID_HOME>
2013-08-26 13:14:11.099: AGFW {2:27079:629} Agent sending reply for: RESOURCE_START[ora.ons 1] ID 4098:744107
2013-08-26 13:14:11.099: ora.ons {2:27079:629} [check] Utils:execCmd action = 3 flags = 6 ohome = <GRID_HOME>/opmn/ cmdname = onsctli.
2013-08-26 13:14:11.213: ora.ons {2:27079:629} [check] (:CLSN00010:)getaddrinfo(localhost, 6100, 1) failed (host nor service provided, or not known):
2013-08-26 13:14:11.214: ora.ons {2:27079:629} [check] (:CLSN00010:)Can not resolve localhost for interface any
2013-08-26 13:14:11.214: ora.ons {2:27079:629} [check] (:CLSN00010:)ons is not running ...
- oraagent_grid.log shows VIP is registered, but public IP is Null.
2013-08-26 13:17:00.537: USRTHRD {2:27079:638} Thread:RegEndpointThread:LISTENER start {
2013-08-26 13:17:00.537: USRTHRD {2:27079:638} Thread:RegEndpointThread:LISTENER start }
2013-08-26 13:17:00.538: USRTHRD {2:27079:638} Thread:RegEndpointThread:LISTENER Registering Endpoint nsgfei_EndpointInit() (ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521))
2013-08-26 13:17:00.538: USRTHRD {2:27079:638} Thread:RegEndpointThread:LISTENER Registering Endpoint nsgfei_EndpointInit() (ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521)(IP=FIRST))
2013-08-26 13:17:00.551: USRTHRD {2:27079:638} Thread:RegEndpointThread:LISTENER LsnrAgent, registered endpoint (ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521))
2013-08-26 13:17:00.551: USRTHRD {2:27079:638} Thread:RegEndpointThread:LISTENER LsnrAgent, registered endpoint (ADDRESS=(PROTOCOL=TCP)(*HOST=*)(PORT=1521)(IP=FIRST))
- Normally both Public IP and VIP should register to the listener dynamically. For Example:
$ lsnrctl status
...
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))) <<<<<<< Public IP Endpoint registered
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))) <<<<<<< VIP Endpoint registered
CHANGES
New Installation.
CAUSE
Start from 11.2 GRID Agent dynamically registers endpoints (VIP and Public IP) with the listener. Agent gets Public IP from /etc/hosts (if no DNS). If Agent fails to get Public IP, then the listener end point will not be created.
In this case, the root cause is incorrect permission of /etc/nsswitch.conf, which prevent Agent to get correct Public IP:
-rw-r----- 1 root sys 23 Oct 30 2012 /etc/nsswitch.conf
SOLUTION
Please contact OS Admin to check and correct the permission of /etc/nsswitch.conf. It should be like:
-rw-rw-rw- 1 root sys 23 Oct 30 2012 /etc/nsswitch.conf
The correct permission allows ora.ons to start and the end point of Public IP created for the listener.
REFERENCES
NOTE:1107295.1 - Linux: How to Configure the DNS Server for 11gR2 SCAN
总结
1、检查local_listener和remote_listener的值,且必须使用sid参数
alter system set local_listener='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.20.7.83)(PORT=1522)))' sid='rac1';
alter system set local_listener='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.20.7.84)(PORT=1522)))' sid='rac2';
alter system set remote_listener='rac-scan:1522' sid='*';
alter system register;
2、检查/u01/app/11.2.0.4/grid/network/admin/listener.ora
文件,添加如下内容,注意是grid用户,而不是oracle用户
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.30.7.81)(PORT = 1522))
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.30.7.83)(PORT = 1522))
)
)
3、启动和关闭监听需要使用srvctl命令:
srvctl stop listener
srvctl start listener
crsctl stat res -t
srvctl config listener -a