共计 7815 个字符,预计需要花费 20 分钟才能阅读完成。
最近部署一个两节点 Oracle RAC 环境,刚刚开始没怎么留意,但当在使用的时候竟然 scan-ip 无法通过客户端登陆使用,但是在两个节点上可正常使用,此外 vip 无论在节点上还是其他客户端使用完全ok 。
在安装 GI 的时候最后报错,但经查看官方文档说是可能 scan-ip 写到 hosts 文件中了,但本人环境中三个 scan-ip 均为加入到 hosts 文件中,故此直接忽略掉该报错。
下面是本人详细的排错过程:
1. 在 任意节点 上使用 tnsnames.ORA 透过 scan-ip 登陆数据库:
[grid@RAC01 admin]$ tnsping RACDB
TNS Ping Utility for Linux: Version 11.2.0.1.0 – Production on 02-JAN-2014 18:41:16
Copyright (c) 1997, 2009, Oracle. All rights reserved.
Used parameter files:
/u/app/11.2.0/grid/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.134.30.50)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = RACDB)))
OK (0 msec)
[grid@RAC01 admin]$ sqlplus scott/testpassword@RACDB
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jan 2 18:41:27 2014
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
SQL>
2. 检查 RAC 上的 scan-ip 配置:
[grid@RAC01 ~]$ srvctl config scan
SCAN name: RACSCAN.localdomain., Network: 1/10.134.30.0/255.255.255.0/eth0
SCAN VIP name: scan1, IP: /RACSCAN.localdomain/10.134.30.50
SCAN VIP name: scan2, IP: /RACSCAN.localdomain/10.134.30.51
SCAN VIP name: scan3, IP: /RACSCAN.localdomain/10.134.30.52
[grid@RAC01 ~]$ srvctl config scan_listener
SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1521
SCAN Listener LISTENER_SCAN2 exists. Port: TCP:1521
SCAN Listener LISTENER_SCAN3 exists. Port: TCP:1521
3. DNS测试:
[root@RAC01 ~]# nslookup RACSCAN.localdomain.
Server: 10.134.30.27
Address: 10.134.30.27#53
Name: RACSCAN.localdomain
Address: 10.134.30.52
Name: RACSCAN.localdomain
Address: 10.134.30.50
Name: RACSCAN.localdomain
Address: 10.134.30.51
[grid@RAC01 ~]$ nslookup 10.134.30.50
Server: 10.134.30.27
Address: 10.134.30.27#53
50.30.134.10.in-addr.arpa name = RACSCAN.localdomain.
[grid@RAC01 ~]$ nslookup 10.134.30.51
Server: 10.134.30.27
Address: 10.134.30.27#53
51.30.134.10.in-addr.arpa name = RACSCAN.localdomain.
[grid@RAC01 ~]$ nslookup 10.134.30.52
Server: 10.134.30.27
Address: 10.134.30.27#53
52.30.134.10.in-addr.arpa name = RACSCAN.localdomain.
多次运行 nslookup RACSCAN.localdomain. 可观察到 scan-ip 轮询没有任何问题,反向解析亦没有任何问题。
4. Ping三个 scan-ip 没有任何问题:
primary$ping 10.134.30.47
PING 10.134.30.47 (10.134.30.47) 56(84) bytes of data.
64 bytes from 10.134.30.47: icmp_seq=1 ttl=63 time=0.508 ms
primary$ping 10.134.30.48
PING 10.134.30.48 (10.134.30.48) 56(84) bytes of data.
64 bytes from 10.134.30.48: icmp_seq=1 ttl=63 time=0.522 ms
primary$ping 10.134.30.50
PING 10.134.30.50 (10.134.30.50) 56(84) bytes of data.
64 bytes from 10.134.30.50: icmp_seq=1 ttl=63 time=0.514 ms
5. 在任意客户端测试可否登陆:
primary$tnsping guijian
TNS Ping Utility for Linux: Version 11.2.0.1.0 – Production on 02-JAN-2014 19:12:15
Copyright (c) 1997, 2009, Oracle. All rights reserved.
Used parameter files:
/u/app/oracle/product/11g/db/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = RACSCAN.localdomain.)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = RACDB)))
OK (0 msec)————————-à此处透过 scan-ip 的tnsping正常
primary$
primary$sqlplus scott/Testpassword@guijian
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jan 2 19:08:06 2014
Copyright (c) 1982, 2009, Oracle. All rights reserved.
ERROR:
ORA-12170: TNS:Connect timeout occurred
primary$
等待 N 久之后提示超时,但此时的 tnsping 正常,起初测试也曾提示提示 no listener。
6. 检查监听器配置:
[grid@RAC01 admin]$ cat listener.ora
LISTENER_SCAN3=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN3)))) # line added by Agent
LISTENER_SCAN2=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN2)))) # line added by Agent
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
LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN2)))) # line added by Agent
LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN3)))) # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN2=ON # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN3=ON # line added by Agent
ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent
监听器配置没有问题,为了方便本人讲两个节点的 listener.ora 文件内容修改为一模一样的配置。
[grid@RAC01 admin]$
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
STATUS of the LISTENER
————————
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 – Production
Start Date 02-JAN-2014 16:56:51
Uptime 0 days 1 hr. 36 min. 54 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u/app/11.2.0/grid/network/admin/listener.ora
Listener Log File /u/app/grid/diag/tnslsnr/RAC01/listener/alert/log.xml
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.134.30.27)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.134.30.47)(PORT=1521)))
The listener supports no services
The command completed successfully
此时看到监听器 no services,其实所有的问题都是与这个no services 有关的,后续的内容中我会重点关注解决这个问题。
经过初步的检测个人感觉问题不可能出在服务器监听这一块。故此怀疑可能出在与监听相关的初始化参数上。
7. 检查数据库两个与监听相关的参数:
SQL> show parameter local_lis
NAME TYPE VALUE
———————————— ———– ——————————
local_listener string (DESCRIPTION=(ADDRESS_LIST=(AD
DRESS=(PROTOCOL=TCP)(HOST=RAC0
2-vip)(PORT=1521))))
SQL> show parameter remote_lis
NAME TYPE VALUE
———————————— ———– ——————————
remote_listener string RACSCAN.localdomain.:1521
SQL> show parameter local_lis
NAME TYPE VALUE
———————————— ———– ——————————
local_listener string (DESCRIPTION=(ADDRESS_LIST=(AD
DRESS=(PROTOCOL=TCP)(HOST=RAC0
1-vip)(PORT=1521))))
SQL> show parameter remote_lis
NAME TYPE VALUE
———————————— ———– ——————————
remote_listener string RACSCAN.localdomain.:1521
SQL>
注意上述中的 local_listener 参数的配置,发现时指向 vip 的;
8. 修改该参数指向scan-ip。
SQL> alter system set local_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=RACSCAN.localdomain.)(PORT=1521))))’;
System altered.
9. 客户端再次测试:
primary$tnsping guijian
TNS Ping Utility for Linux: Version 11.2.0.1.0 – Production on 02-JAN-2014 19:39:25
Copyright (c) 1997, 2009, Oracle. All rights reserved.
Used parameter files:
/u/app/oracle/product/11g/db/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = RACSCAN.localdomain.)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = RACDB)))
OK (10 msec)
primary$
primary$sqlplus scott/testpassword@guijian
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jan 2 19:40:26 2014
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
SCOTT@guijian>
此时可以看到顺利登陆。此外该参数修改为 scan-ip 后,在此再客户端尝试着使用 vip 登陆时开始报错:
primary$sqlplus scott/Testpassword@guijian
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jan 2 19:42:54 2014
Copyright (c) 1982, 2009, Oracle. All rights reserved.
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor
Enter user-name:
primary$
上述情况说明了一个重要的问题:local_listener参数的设置关系到今后客户端是使用什么类型的 ip 地址进行登陆数据库。
接下来我们重点分析在本文中第六点中提到的 no listener 问题 见 http://www.linuxidc.com/Linux/2017-11/148976.htm
更多 Oracle 相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12
本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-11/148975.htm