REMOTE_LISTENER引发的血案

打印 上一主题 下一主题

主题 985|帖子 985|积分 2955

作者:Digital Observer(施嘉伟)
Oracle ACE Pro: Database
PostgreSQL ACE Partner
11年数据库行业经验,现重要从事数据库服务工作
拥有Oracle OCM、DB2 10.1 Fundamentals、MySQL 8.0 OCP、WebLogic 12c OCA、KCP、PCTP、PCSD、PGCM、OCI、PolarDB技能专家、达梦师资认证、数据安全咨询高级等认证
ITPUB认证专家、PolarDB开源社区技能顾问、HaloDB技能顾问、TiDB社区技能布道师、青学会MOP技能社区专家顾问、国内某高校企业实践引导教师
  内容先容

ORACLE数据库是一个巨大的软件,各个部件协同工作,偶尔间一个环节出现问题,往往会导致重大的问题,特别是偶尔间外部情况因素造成的问题,会直接影响数据库的正常运行,比如存储,比如网络,再比如主机。本次案例要分析的就是一次数据库连接异常的问题,而引起数据连接异常的问题,多种多样,不胜罗列,而具体问题具体分析,本能的反应应该是网络造成的连接问题。最终,我们照旧通过ORACLE的网络跟踪技能及数据库信息的查察办理了故障。
故障的起因重要由于使用rman异地规复数据库,remote_listener参数设置问题导致连接异常。
概念普及

sqlnet是oracle提供的与网络层面交互的一个工具,比如如何解析客户端发起的连接,如何对客户端发起的连接举行辨别,如何对客户端连接举行阻隔限制,或者启用日志及跟踪(log and trace)功能等等一系列的功能,sqlnet通过写入文件参数来举行分析并产生作用, sqlnet配置文件的存放位置一般在:$ORACLE_HOME/network/admin目次下,本次处理网络故障我们就是使用了sqlnet的启用日志及跟踪功能。
sqlnet网络连接跟踪具体设置如下:
  1. TRACE_LEVEL_CLIENT=16
  2. TRACE_FILE_CLIENT=CLIENT
  3. TRACE_TIMESTAMP_CLIENT=ON
  4. trace_directory_client=D:\oracle\product\10.2.0\db_1\network\ADMIN
复制代码
具体解释一下以上参数值: TRACE_LEVEL_CLIENT –开启客户端跟踪级别
TRACE_LEVEL_LISTENER的取值范围为0~16,当然级别越高,收集的信息就相对越全面,系统默认是0,即不生成trace信息
   off or 0 for no trace output
user or 4 for user trace information
admin or 10 for administration trace information
support or 16 for Oracle Support Services trace information
TRACE_FILE_CLIENT --设置客户端和服务器端的trace文件的名称
TRACE_TIMESTAMP_CLIENT --是否在trace中写入每条trace信息的dd-mon-yyyy hh:mi:ss:mi时间戳
TRACE_DIRECTORY_CLIENT --设置客户端和服务器端的trace文件的目次
  故障排查

一、客户端操作如下:

1.客户端连接异常

  1. C:\Documents and Settings\Administrator>sqlplus system/abc123@orcl
  2. SQL*Plus: Release 10.2.0.1.0 - Production on 星期二 12月 2 13:21:16 2014
  3. Copyright (c) 1982, 2005, Oracle.  All rights reserved.
  4. ERROR:
  5. ORA-12545: 因目标主机或对象不存在, 连接失败
  6. 请输入用户名:
复制代码
从报错来看好像是监听的问题
2.tnsping检查连接串配置及服务器监听状态

  1. C:\Documents and Settings\Administrator>tnsping orcl
  2. TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 02-12月-2014 13:22:17
  3. Copyright (c) 1997, 2005, Oracle.  All rights reserved.
  4. 已使用的参数文件:
  5. F:\oracle\product\10.2.0\db_1\network\admin\sqlnet.ora
  6. 已使用 TNSNAMES 适配器来解析别名
  7. Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
  8. (HOST = 192.168.0.94)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0
  9. .93)(PORT = 1521)) (LOAD_BALANCE = yes)) (CONNECT_DATA = (SERVER = SHARED) (SERV
  10. ICE_NAME = orcl) (FAILOVER_MODE = (TYPE = SELECT) (METHOD = BASIC))))
  11. OK (30 毫秒)
复制代码
从tnsping的测试来看,连接串监听都正常
3.由于是生产库是rac情况的尝试单节点登入

  1. C:\Documents and Settings\Administrator>sqlplus system/abc123@orcl1
  2. SQL*Plus: Release 10.2.0.1.0 - Production on 星期二 12月 2 13:26:17 2014
  3. Copyright (c) 1982, 2005, Oracle.  All rights reserved.
  4. 连接到:
  5. Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
  6. With the Partitioning, Real Application Clusters, OLAP, Data Mining
  7. and Real Application Testing options
  8. SQL> exit
  9. 从 Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
  10. With the Partitioning, Real Application Clusters, OLAP, Data Mining
  11. and Real Application Testing options 断开
复制代码
  1. C:\Documents and Settings\Administrator>sqlplus system/abc123@orcl2
  2. SQL*Plus: Release 10.2.0.1.0 - Production on 星期二 12月 2 13:26:24 2014
  3. Copyright (c) 1982, 2005, Oracle.  All rights reserved.
  4. 连接到:
  5. Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
  6. With the Partitioning, Real Application Clusters, OLAP, Data Mining
  7. and Real Application Testing options
复制代码
从单节点的登入来看配置都正常而且可以正常连接,问题很奇怪为了进一步排查开启开启客户端跟踪
在客户端的sqlnet.ora文件中添加如下内容:
  1. TRACE_LEVEL_CLIENT=16
  2. TRACE_FILE_CLIENT=CLIENT
  3. TRACE_TIMESTAMP_CLIENT=ON
  4. trace_directory_client=D:\oracle\product\10.2.0\db_1\network\ADMIN
复制代码
4. 重新用客户端登入收集跟踪信息

跟踪信息如下:
  1. [02-12月-2014 14:10:32:968] nsmfr: normal exit
  2. [02-12月-2014 14:10:32:968] nsmfr: entry
  3. [02-12月-2014 14:10:32:968] nsmfr: 736 bytes at 0xe4b9d8
  4. [02-12月-2014 14:10:32:968] nsmfr: normal exit
  5. [02-12月-2014 14:10:32:968] nsclose: normal exit
  6. [02-12月-2014 14:10:32:968] nscall: connecting...
  7. [02-12月-2014 14:10:32:968] nsc2addr: entry
  8. [02-12月-2014 14:10:32:968] nsc2addr: (ADDRESS=(PROTOCOL=tcp)(HOST=hp)(PORT=3554))
  9. [02-12月-2014 14:10:32:968] nttbnd2addr: entry
  10. [02-12月-2014 14:10:32:968] snlinGetAddrInfo: entry
  11. [02-12月-2014 14:10:32:968] snlinGetAddrInfo: Invalid IP address string hp
  12. [02-12月-2014 14:10:32:968] snlinFreeAddrInfo: entry
  13. [02-12月-2014 14:10:32:968] snlinFreeAddrInfo: exit
  14. [02-12月-2014 14:10:32:968] snlinGetAddrInfo: exit
  15. [02-12月-2014 14:10:32:968] nttbnd2addr: looking up IP addr for host: hp
  16. [02-12月-2014 14:10:32:968] snlinGetAddrInfo: entry
  17. [02-12月-2014 14:10:35:218] snlinGetAddrInfo: Name resolution failed for hp
  18. [02-12月-2014 14:10:35:218] snlinFreeAddrInfo: entry
  19. [02-12月-2014 14:10:35:218] snlinFreeAddrInfo: exit
  20. [02-12月-2014 14:10:35:218] snlinGetAddrInfo: exit
  21. [02-12月-2014 14:10:35:218] nttbnd2addr:  *** hostname lookup failure! ***
  22. [02-12月-2014 14:10:35:218] nttbnd2addr: exit
  23. [02-12月-2014 14:10:35:218] nserror: entry
  24. [02-12月-2014 14:10:35:218] nserror: nsres: id=0, op=77, ns=12545, ns2=12560; nt[0]=515, nt[1]=1001, nt[2]=0; ora[0]=0, ora[1]=0, ora[2]=0
  25. [02-12月-2014 14:10:35:218] nsc2addr: error exit
复制代码
从以上跟踪信息,当我们尝试使用orcl连接勾通接时被路由到了HP这个主机,可是tnsnames.ora连接串里面根本没有配置干系的信息,那怎么会呢从客户端的配置好像查不出什么原因,尝试从生产库查找。
二、服务器端配置查察

1.查察生产库的local_listener和remote_listener配置

  1. SQL> show parameter local   
  2. NAME                          TYPE    VALUE
  3. ---------------------------  ---------------------------------------
  4. local_listener                string  (address=(protocol=tcp)(host=192.168.0.93)(port=1521))
  5. SQL> show parameter remote   
  6. NAME                          TYPE    VALUE
  7. ---------------------------  ---------------------------------------
  8. remote_listener               string  LISTENERS_ORCL
复制代码
从配置上来看都没有任何异常
2.查察生产库的监听状态

  1. C:\Documents and Settings\Administrator>lsnrctl status
  2. LSNRCTL for 64-bit Windows: Version 10.2.0.4.0 - Production on 02-12月-2014 14:15:29
  3. Copyright (c) 1991, 2007, Oracle.  All rights reserved.
  4. 正在连接到 (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
  5. LISTENER 的 STATUS
  6. ------------------------
  7. 别名                      LISTENER
  8. 版本                      TNSLSNR for 64-bit Windows: Version 10.2.0.4.0 - Production
  9. 启动日期                  24-11月-2014 20:52:17
  10. 正常运行时间              7 天 17 小时 23 分 13 秒
  11. 跟踪级别                  off
  12. 安全性                    ON: Local OS Authentication
  13. SNMP                      OFF
  14. 监听程序参数文件          D:\oracle\product\10g\network\admin\listener.ora
  15. 监听程序日志文件          D:\oracle\product\10g\network\log\listener.log
  16. 监听端点概要...
  17.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=svr01)(PORT=1521)))
  18. 服务摘要..
  19. 服务 "+ASM" 包含 1 个例程。
  20.   例程 "+asm2", 状态 BLOCKED, 包含此服务的 1 个处理程序...
  21. 服务 "+ASM_XPT" 包含 1 个例程。
  22.   例程 "+asm2", 状态 BLOCKED, 包含此服务的 1 个处理程序...
  23. 服务 "orcl" 包含 3 个例程。
  24.   例程 "orcl1", 状态 READY, 包含此服务的 31 个处理程序...
  25.   例程 "orcl2", 状态 READY, 包含此服务的 32 个处理程序...
  26.   例程 "orclstd", 状态 READY, 包含此服务的 2 个处理程序...
  27. 服务 "orcl_XPT" 包含 3 个例程。
  28.   例程 "orcl1", 状态 READY, 包含此服务的 31 个处理程序...
  29.   例程 "orcl2", 状态 READY, 包含此服务的 32 个处理程序...
  30.   例程 "orclstd", 状态 READY,
  31. 包含此服务的 2 个处理程序...
  32. 命令执行成功
复制代码
从监听来看好像也看不出什么端倪
3.生产库尝试用orcl连接勾通接

  1. C:\Documents and Settings\Administrator>sqlplus  system/abc123@orcl
  2. SQL*Plus: Release 10.2.0.4.0 - Production on 星期二 12月 2 13:45:51 2014
  3. Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
  4. 连接到:
  5. SQL> select instance_name from v$instance;
  6. INSTANCE_NAME
  7. ----------------
  8. orclstd
  9. SQL> show parameter remote
  10. NAME                                 TYPE        VALUE
  11. ------------------------------------ ----------- ------------------------------
  12. remote_listener                      string      LISTENERS_ORCL
  13. C:\Documents and Settings\Administrator>tnsping listeners_orcl
  14. TNS Ping Utility for 64-bit Windows: Version 10.2.0.4.0 - Production on 02-12月-2014 14:01:53
  15. Copyright (c) 1997,  2007, Oracle.  All rights reserved.
  16. 已使用的参数文件:
  17. D:\oracle\product\10g\network\admin\sqlnet.ora
  18. 已使用 TNSNAMES 适配器来解析别名
  19. Attempting to contact (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = svr02-vip)(PORT = 1521)) (ADDRESS = (
  20. PROTOCOL = TCP)(HOST = svr01-vip)(PORT = 1521)))
  21. OK (20 毫秒)
复制代码
  1. C:\Documents and Settings\Administrator>sqlplus / as sysdba
  2. SQL*Plus: Release 10.2.0.4.0 - Production on 星期二 12月 2 14:01:02 2014
  3. Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
  4. 连接到:
  5. Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
  6. With the Partitioning, Real Application Clusters, OLAP, Data Mining
  7. and Real Application Testing options
  8. SQL> select instance_name from gv$instance;
  9. INSTANCE_NAME
  10. ----------------
  11. orcl2
  12. orcl1
复制代码
从以上的连接来看着实已经很明显了,当时用orcl连接勾通接时连接到orclstd,由于orclstd库remote_listener参数所引起,orclstd库在长途注册实例状态了,然后路由到备机了,导致生产使用orcl报错。
orclstd这个库是使用生产的rman备份规复回来的数据库)
4.查察生产监听状态正式以上判断
  1. C:\Documents and Settings\Administrator>lsnrctl status
  2. LSNRCTL for 64-bit Windows: Version 10.2.0.4.0 - Production on 02-12月-2014 14:15:29
  3. Copyright (c) 1991, 2007, Oracle.  All rights reserved.
  4. 正在连接到 (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
  5. LISTENER 的 STATUS
  6. ------------------------
  7. 别名                      LISTENER
  8. 版本                      TNSLSNR for 64-bit Windows: Version 10.2.0.4.0 - Production
  9. 启动日期                  24-11月-2014 20:52:17
  10. 正常运行时间              7 天 17 小时 23 分 13 秒
  11. 跟踪级别                  off
  12. 安全性                    ON: Local OS Authentication
  13. SNMP                      OFF
  14. 监听程序参数文件          D:\oracle\product\10g\network\admin\listener.ora
  15. 监听程序日志文件          D:\oracle\product\10g\network\log\listener.log
  16. 监听端点概要...
  17.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=svr01)(PORT=1521)))
  18. 服务摘要..
  19. 服务 "+ASM" 包含 1 个例程。
  20.   例程 "+asm2", 状态 BLOCKED, 包含此服务的 1 个处理程序...
  21. 服务 "+ASM_XPT" 包含 1 个例程。
  22.   例程 "+asm2", 状态 BLOCKED, 包含此服务的 1 个处理程序...
  23. 服务 "orcl" 包含 3 个例程。
  24.   例程 "orcl1", 状态 READY, 包含此服务的 31 个处理程序...
  25.   例程 "orcl2", 状态 READY, 包含此服务的 32 个处理程序...
  26.   例程 "orclstd", 状态 READY, 包含此服务的 2 个处理程序...
  27. 服务 "orcl_XPT" 包含 3 个例程。
  28.   例程 "orcl1", 状态 READY, 包含此服务的 31 个处理程序...
  29.   例程 "orcl2", 状态 READY, 包含此服务的 32 个处理程序...
  30.   例程 "orclstd", 状态 READY, 包含此服务的 2 个处理程序...   --确实证实了之前的判断,罪魁祸首水落石出
  31. 命令执行成功
复制代码
5.证实备机是否主机名为hp
  1. C:\Documents and Settings\Administrator>hostname
  2. hp
  3. C:\Documents and Settings\Administrator>ping hp
  4. Pinging hp [192.168.0.80] with 32 bytes of data:
  5. Reply from 192.168.0.80: bytes=32 time<1ms TTL=128
复制代码
故障后期处理

1.注销备机的remote_listener

  1. alter system set remote_listener='' scope=both;
复制代码
2.生产库重新加载监听

  1. C:\Documents and Settings\Administrator>lsnrctl reload
  2. LSNRCTL for 64-bit Windows: Version 10.2.0.4.0 - Production on 02-12月-2014 14:18:51
  3. Copyright (c) 1991, 2007, Oracle.  All rights reserved.
  4. 正在连接到 (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
  5. 命令执行成功
  6. C:\Documents and Settings\Administrator>lsnrctl status
  7. LSNRCTL for 64-bit Windows: Version 10.2.0.4.0 - Production on 02-12月-2014 14:18:57
  8. Copyright (c) 1991, 2007, Oracle.  All rights reserved.
  9. 正在连接到 (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
  10. LISTENER 的 STATUS
  11. ------------------------
  12. 别名                      LISTENER
  13. 版本                      TNSLSNR for 64-bit Windows: Version 10.2.0.4.0 - Production
  14. 启动日期                  24-11月-2014 20:52:17
  15. 正常运行时间              7 天 17 小时 26 分 40 秒
  16. 跟踪级别                  off
  17. 安全性                    ON: Local OS Authentication
  18. SNMP                      OFF
  19. 监听程序参数文件          D:\oracle\product\10g\network\admin\listener.ora
  20. 监听程序日志文件          D:\oracle\product\10g\network\log\listener.log
  21. 监听端点概要...
  22.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=svr01)(PORT=1521)))
  23. 服务摘要..
  24. 服务 "+ASM" 包含 1 个例程。
  25.   例程 "+asm2", 状态 BLOCKED, 包含此服务的 1 个处理程序...
  26. 服务 "+ASM_XPT" 包含 1 个例程。
  27.   例程 "+asm2", 状态 BLOCKED, 包含此服务的 1 个处理程序...
  28. 服务 "orcl" 包含 2 个例程。
  29.   例程 "orcl1", 状态 READY, 包含此服务的 31 个处理程序...
  30.   例程 "orcl2", 状态 READY, 包含此服务的 1 个处理程序...
  31. 服务 "orcl_XPT" 包含 2 个例程。
  32.   例程 "orcl1", 状态 READY, 包含此服务的 31 个处理程序...
  33.   例程 "orcl2", 状态 READY, 包含此服务的 1 个处理程序...  
复制代码
–orclstd 已经消散了
命令实验乐成
3.客户端再次使用orcl连接数据库正常
  1. D:\>sqlplus system/abc123@orcl
  2. SQL*Plus: Release 10.2.0.1.0 - Production on 星期二 12月 2 14:21:01 2014
  3. Copyright (c) 1982, 2005, Oracle.  All rights reserved.
  4. 连接到:
  5. Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
  6. With the Partitioning, Real Application Clusters, OLAP, Data Mining
  7. and Real Application Testing options
  8. SQL> show parameter name
  9. NAME                                 TYPE        VALUE
  10. ------------------------------------ ----------- ------------------------------
  11. db_file_name_convert                 string
  12. db_name                              string      orcl
  13. db_unique_name                       string      orcl
  14. global_names                         boolean     FALSE
  15. instance_name                        string      orcl2
  16. lock_name_space                      string
  17. log_file_name_convert                string
  18. service_names                        string      orcl
复制代码
到此处问题已经办理
技能结论

通过以上一步步的推敲,终于发现了问题的根本原因,由于使用rman异机规复时remote_listener参数所引起。orclstd库在长途注册实例状态了,然后路由到80备机了,导致生产使用orcl报错。


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

万万哇

金牌会员
这个人很懒什么都没写!
快速回复 返回顶部 返回列表