时间:2021-07-01 10:21:17 帮助过:152人阅读
监听器、TNS连接通常是Oracle初学者一个不容易理解的关键。但是,在实际配置过程中如果存在问题,就引起Oracle无法连接的难题。本
Oracle安装是一个复杂的过程,在Linux和AIX等操作系统版本上,进行各种准备的过程和时间经常是超过安装程序、创建数据库本身。而且,一旦有配置项出现错误,在后面Oracle安装和运行中就可能出现意想不到的问题。
监听器、TNS连接通常是Oracle初学者一个不容易理解的关键。但是,在实际配置过程中如果存在问题,就引起Oracle无法连接的难题。本篇介绍一个监听器无法启动报错TNS-00517的小故障。
1、问题说明
进行产品测试,在实验环境上尝试安装最新的11.2.0.4版本。操作系统环境为Red Hat 6.5。
[oracle@SimpleLinux ~]$ uname -r
2.6.32-431.el6.i686
[oracle@SimpleLinux ~]$ cat /etc/RedHat-release
Red Hat Enterprise Linux Server release 6.5 (Santiago)
使用dbca安装完成数据库后,没有明显报错痕迹。检查数据库实例启动正常,也可以支持操作系统验证登陆。
[oracle@SimpleLinux ~]$ ps -ef | grep pmon
oracle 5851 1 0 12:48 ? 00:00:00 ora_pmon_ora11g
oracle 11778 11747 0 12:56 pts/0 00:00:00 grep pmon
监听程序状态查询失效,处在不能启动状态。
[oracle@SimpleLinux ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 01-APR-2014 12:56:53
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=SimpleLinux)(PORT=1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
lsnrctl是监听器操纵平台工具,status会去尝试连接运行的监听程序检查状态。从结果看,监听器没有启动。注意:一般而言,Oracle创建数据库之后,就会自动启动一个监听器。最新的Oracle版本会用默认的方式运行监听器,TNS_ADMIN目录中通常没有tnsnames.ora、listener.ora和sqlnet.ora文件。
启动监听器,报错。
[oracle@SimpleLinux ~]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 01-APR-2014 12:57:06
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Starting /u01/app/oracle/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /u01/app/oracle/network/admin/listener.ora
Log messages written to /u01/app/diag/tnslsnr/SimpleLinux/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=SimpleLinux)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=SimpleLinux)(PORT=1521)))
TNS-12547: TNS:lost contact
TNS-12560: TNS:protocol adapter error
TNS-00517: Lost contact
Linux Error: 104: Connection reset by peer
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
TNS-12547: TNS:lost contact
TNS-12560: TNS:protocol adapter error
TNS-00517: Lost contact
Linux Error: 104: Connection reset by peer
2、问题分析
使用netca重建监听程序,,也没有解决问题。查看listener.ora文件如下:
[oracle@SimpleLinux admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = SimpleLinux)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
ADR_BASE_LISTENER = /u01/app
在笔者之前的文章《监听器listener.ora中HOST参数配置》()中,讨论过HOST参数设置IP地址和主机名称的差异。如果设置IP地址,监听程序只会驻留在指定的IP地址上。如果服务器有多个IP地址,其他IP地址是不能作为监听地址的。
如果设置的是hostname,那么Oracle就会根据网络配置,解析hostname对应的所有IP地址,并且绑定在所有的IP地址上进行连接。
从host参数配置上,指定的名称SimpleLinux解析最直接手段是/etc/hosts文件。
[oracle@SimpleLinux admin]$ cat /etc/hosts
127.0.0.1 SimpleLinux SimpleLinux.localdomain localhost4 localhost4.localdomain4
::1 SimpleLinux SimpleLinux.localdomain localhost6 localhost6.localdomain6
192.168.0.100 SimpleLinux SimpleLinux.localdomain
[root@SimpleLinux ~]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 08:00:27:48:5C:18
inet addr:192.168.0.100 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe48:5c18/64 Scope:Link
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
直观看没有什么问题,两个监控地址都在文件中。修改下hosts文件更加清晰,路径IP解析也没有问题,网络连接也没有问题。
[root@SimpleLinux ~]# vi /etc/hosts
192.168.0.100 SimpleLinux SimipleLinux.localdomain
127.0.0.1 SimpleLinux SimpleLinux.localdomain
::1 SimpleLinux SimpleLinux.localdomain
[root@SimpleLinux ~]# ping SimpleLinux
PING SimpleLinux (192.168.0.100) 56(84) bytes of data.
64 bytes from SimpleLinux (192.168.0.100): icmp_seq=1 ttl=64 time=0.056 ms
64 bytes from SimpleLinux (192.168.0.100): icmp_seq=2 ttl=64 time=0.138 ms
64 bytes from SimpleLinux (192.168.0.100): icmp_seq=3 ttl=64 time=0.132 ms
启动尝试。
[oracle@SimpleLinux ~]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 01-APR-2014 13:09:46
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Starting /u01/app/oracle/bin/tnslsnr: please wait...
(篇幅原因,有省略……)
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=SimpleLinux)(PORT=1521)))
TNS-12547: TNS:lost contact
TNS-12560: TNS:protocol adapter error
TNS-00517: Lost contact
Linux Error: 104: Connection reset by peer
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
TNS-12547: TNS:lost contact
TNS-12560: TNS:protocol adapter error
TNS-00517: Lost contact
Linux Error: 104: Connection reset by peer
问题依旧,尝试弃用hostname,直接使用IP地址连接。
[oracle@SimpleLinux admin]$ cp listener.ora listener.ora.bk
[oracle@SimpleLinux admin]$ vi listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
启动尝试,故障依然。
[oracle@SimpleLinux admin]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 01-APR-2014 13:11:10
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Starting /u01/app/oracle/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /u01/app/oracle/network/admin/listener.ora
Log messages written to /u01/app/diag/tnslsnr/SimpleLinux/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
Listening on:
TNS-12547: TNS:lost contact
TNS-12560: TNS:protocol adapter error
TNS-00517: Lost contact
Linux Error: 104: Connection reset by peer
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
TNS-12547: TNS:lost contact
TNS-12560: TNS:protocol adapter error
TNS-00517: Lost contact
Linux Error: 104: Connection reset by peer
更多详情见请继续阅读下一页的精彩内容: