前言
我自以为对oracle的监听这一块的知识还是比较扎实的,直到这次遇到了lsnrctl start 报错,经过我初步检查之后没有发现什么可疑之处,于是我开始认识到我的知识的不足,便开始查找资料,各种关于oracle listener的文件,博客,网站的介绍。但是让我感觉奇怪的是,我找了半天的listener启动失败的博客,竟然没有一个是符合我这种条件的,于是我开始了自解之路 ,直到我真正发现了问题的所在地,我才恍然大屋--我的监听程序没有配置监听端口。
关于我的这个监听端口号的问题,我想一般情况下不会有第二个我了,在安装数据库的时候oracle报告了一些错误,当时我并没有在意,当我启动oracle listener的时候问题出现了于是有了我的一趟弯路之行。
[oracle@BaiFei]$ lsnrctl start
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 14-SEP-2012 17:33:28
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Starting /opt/oracle/product/10.2.0/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /opt/oracle/product/10.2.0/network/admin/listener.ora
Log messages written to /opt/oracle/product/10.2.0/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
TNS-01150: The address of the specified listener name is incorrect
TNS-01153: Failed to process string: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=pro)(PORT=null)))
Listener failed to start. See the error message(s) above...
[oracle@BaiFei$
检查监听程序的配置文件内容
[oracle@BaiFei]$ cat /opt/oracle/product/10.2.0/network/admin/listener.ora
# listener.ora Network Configuration File: /opt/oracle/product/10.2.0/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST = (SID_DESC =(SID_NAME = PLSExtProc)
(ORACLE_HOME = /opt/oracle/product/10.2.0)
(PROGRAM = extproc))
)
LISTENER =
(DESCRIPTION_LIST =(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = pro)(PORT = null))
)
)
[oracle@]$
检查日志文件
[oracle@BaiFei]$ cat /opt/oracle/product/10.2.0/network/log/listener.log
TNSLSNR for Linux: Version 10.2.0.1.0 - Production on 13-SEP-2012 13:42:46
Copyright (c) 1991, 2005, Oracle. All rights reserved.
System parameter file is /opt/oracle/product/10.2.0/network/admin/listener.ora
Log messages written to /opt/oracle/product/10.2.0/network/log/listener.log
Trace information written to /opt/oracle/product/10.2.0/network/trace/listener.trc
Trace level is currently 0
Started with pid=7839
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
TNS-01150: The address of the specified listener name is incorrect
TNS-01153: Failed to process string: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=pro)(PORT=null)))
No longer listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
[oracle@BaiFei]$
检查主机名
[oracle@BaiFei]$ hostname
BaiFei
[oracle@BaiFei$
检查hosts文件
[oracle@BaiFei]$ cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
192.168.128.128 BaiFei localhost
[oracle@BaiFei]$
检查网络配置文件
[oracle@BaiFeitrace]$ cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=BaiFei
执行ifconfig 命令,查看IP
[oracle@BaiFei]$ ifconfig
-bash: ifconfig: command not found
查看PATH
[oracle@BaiFei]$ echo $PATH
/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/opt//bin:/sbin/ifconfig:/opt/oracle/product/10.2.0/bin:/opt//bin:/opt//bin:/opt/oracle/product/10.2.0/bin:/opt//bin
[oracle@BaiFei]$
发现没有/sbin 于是在.bash_profile 文件添加 /sbin
PATH=$PATH:$HOME/bin:/sbin
执行source .bash_profile 让刚才修改的内容生效
再次执行ifconfig命令
[oracle@BaiFei]$ ifconfig | grep inet
inet addr:192.168.128.129 Bcast:192.168.128.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe2d:db9b/64 Scope:Link
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
[oracle@BaiFei]$
再次执行lsnrctl start
[oracle@BaiFei]$ lsnrctl start
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 14-SEP-2012 18:16:09
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Starting /opt/oracle/product/10.2.0/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /opt/oracle/product/10.2.0/network/admin/listener.ora
Log messages written to /opt/oracle/product/10.2.0/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
TNS-01150: The address of the specified listener name is incorrect
TNS-01153: Failed to process string: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=pro)(PORT=null)))
Listener failed to start. See the error message(s) above...
[oracle@BaiFei]$
重新启动linux ,并执行lsnrctl start
[oracle@BaiFei]$ lsnrctl start
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 14-SEP-2012 18:20:46
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Starting /opt/oracle/product/10.2.0/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /opt/oracle/product/10.2.0/network/admin/listener.ora
Log messages written to /opt/oracle/product/10.2.0/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
TNS-01150: The address of the specified listener name is incorrect
TNS-01153: Failed to process string: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=pro)(PORT=null))
Listener failed to start. See the error message(s) above..
查看网关是否能通
[oracle@BaiFei]$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=0 ttl=128 time=82.6 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=128 time=60.3 ms
[oracle@BaiFei]$ ping pro
PING BaiFei(192.168.128.128) 56(84) bytes of data.
From 192.168.128.129 icmp_seq=1 Destination Host Unreachable
From 192.168.128.129 icmp_seq=2 Destination Host Unreachable
From 192.168.128.129 icmp_seq=3 Destination Host Unreachable
From 192.168.128.129 icmp_seq=5 Destination Host Unreachable
From 192.168.128.129 icmp_seq=6 Destination Host Unreachable
From 192.168.128.129 icmp_seq=7 Destination Host Unreachable
再次发现问题,主机不可达,,
修改文件 /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 BaiFei localhost.localdomain localhost
192.168.128.129 BaiFei localhost
再次ping自己的主机名
[root@BaiFei]# ping pro
PING BaiFei (127.0.0.1) 56(84) bytes of data.
64 bytes from BaiFei (127.0.0.1): icmp_seq=0 ttl=64 time=0.024 ms
64 bytes from BaiFei (127.0.0.1): icmp_seq=1 ttl=64 time=0.027 ms
--- BaiFei ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.024/0.025/0.027/0.005 ms, pipe 2
[root@BaiFei]#
[root@BaiFei]#
启动监听程序
~[oracle@BaiFei]$ lsnrctl start
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 14-SEP-2012 18:32:50
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Starting /opt/oracle/product/10.2.0/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /opt/oracle/product/10.2.0/network/admin/listener.ora
Log messages written to /opt/oracle/product/10.2.0/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
TNS-01150: The address of the specified listener name is incorrect
TNS-01153: Failed to process string: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=pro)(PORT=null)))
Listener failed to start. See the error message(s) above...
[oracle@BaiFei]$
再次查看监听listener.ora文件。;
[oracle@BaiFei]$ cat /opt/oracle/product/10.2.0/network/admin/listener.ora
# listener.ora Network Configuration File: /opt/oracle/product/10.2.0/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /opt/oracle/product/10.2.0)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = BaiFei)(PORT = null))
)
)
发现没有监听端口,,于是添加监听端口1521
[oracle@BaiFei]$ vi /opt/oracle/product/10.2.0/network/admin/listener.ora
# listener.ora Network Configuration File: /opt/oracle/product/10.2.0/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /opt/oracle/product/10.2.0)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = pro)(PORT = 1521))
)
)
再次启动监听程序
~ [oracle@BaiFei]$ lsnrctl start
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 14-SEP-2012 18:37:52
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Starting /opt/oracle/product/10.2.0/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /opt/oracle/product/10.2.0/network/admin/listener.ora
Log messages written to /opt/oracle/product/10.2.0/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=pro)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 14-SEP-2012 18:37:52
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/oracle/product/10.2.0/network/admin/listener.ora
Listener Log File /opt/oracle/product/10.2.0/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=pro)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@BaiFei]$
成功启动
后记
从一开始的马虎开始,没有仔细的查看listener.ora文件,理由是:这个文件不是由我自己创建而是由 DBCA创建的,但是在后来又记起在DBCA创建数据库的时候好像报了一个错误。但是创建完数据库时,我查看了一下数据库的状态,发现是open状态也就没怎么过问了,心想估计只是一个小小的错误吧,也就没有过多的追究了。
后来我想远程连接数据库,我就不必须的启动监听程序,于是我就lsnrctl start ,但是接下来的就让我傻眼了,监听程序竟然启动不起来。于是我看了看日志文件,也没看出个所以然来,查看trace文件,竟然这个文件不存在。我就只有,一边凭着自己的经验,一边搜索资料,自行解决监听程序启动报错的问题。
虽然这次的错误排除确实走了不少的弯路,但是这次的收获不可否认,首先我明确了listener.ora sqlnet.ora,tnsnames.ora 这三个文件的关系,以及作用和每个文件每一行的作用。加深了我对监听的理解,以及对本地命名服务的认识。相信以后出现类似的问题,我可以在比较短的时间内解决的。其次,我确实是在这次的排错的过程中找到不少的错误,也逐一改正了过来,以后再次碰到这种问题,就不会到处跑弯路了:最后,一次小小的报错让我明白,应该对每个小小的错误引起足够的注意,以免酿成不良后果。