hostname配置不切当导致TNS-12542错误
一、监听异常现象
[oracle@gongantest ~]$ lsnrctl start LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 15-DEC-2011 14:15:06 Copyright (c) 1991, 2007, Oracle. All rights reserved. Starting /opt/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 10.2.0.4.0 - Production System parameter file is /opt/oracle/product/10.2.0/db_1/network/admin/listener.ora Log messages written to /opt/oracle/product/10.2.0/db_1/network/log/listener.log Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=gongantest)(PORT=1521))) Error listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.11.60)(PORT=1521))) TNS-12542: TNS:address already in use TNS-12560: TNS:protocol adapter error TNS-00512: Address already in use Linux Error: 98: Address already in use Listener failed to start. See the error message(s) above... [oracle@gongantest ~]$ more /opt/oracle/product/10.2.0/db_1/network/admin/listener.ora # listener.ora Network Configuration File: /opt/oracle/product/10.2.0/db_1/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/db_1) (PROGRAM = extproc) ) ) LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = gongantest)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.60)(PORT = 1521)) ) )
二、相关网络配置
[oracle@gongantest ~]$ ping gongantest -c 2 PING gongantest (127.0.0.1) 56(84) bytes of data. 64 bytes from gongantest (127.0.0.1): icmp_seq=1 ttl=64 time=0.040 ms 64 bytes from gongantest (127.0.0.1): icmp_seq=2 ttl=64 time=0.016 ms --- gongantest ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1000ms rtt min/avg/max/mdev = 0.016/0.028/0.040/0.012 ms [oracle@gongantest ~]$ more /etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 gongantest localhost.localdomain localhost [oracle@gongantest ~]$ cd /etc/sysconfig/network-scripts [oracle@gongantest network-scripts]$ more ifcfg-eth0 # Intel Corporation 82541GI Gigabit Ethernet Controller DEVICE=eth0 BOOTPROTO=static BROADCAST=192.168.11.255 HWADDR=00:14:22:10:96:C9 IPADDR=192.168.11.60 NETMASK=255.255.252.0 NETWORK=192.168.8.0 ONBOOT=yes [oracle@gongantest network-scripts]$ more ifcfg-eth1 # Intel Corporation 82541GI Gigabit Ethernet Controller DEVICE=eth1 BOOTPROTO=dhcp HWADDR=00:14:22:10:96:CA ONBOOT=no HOTPLUG=no DHCP_HOSTNAME=gongantest [oracle@gongantest network-scripts]$ hostname gongantest [oracle@gongantest network-scripts]$ more /etc/sysconfig/network NETWORKING=yes NETWORKING_IPV6=no HOSTNAME=gongantest GATEWAY=192.168.8.1
三、解决问题
[oracle@gongantest ~]$ more /opt/oracle/product/10.2.0/db_1/network/admin/listener.ora # listener.ora Network Configuration File: /opt/oracle/product/10.2.0/db_1/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/db_1) (PROGRAM = extproc) ) ) LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.11.60)(PORT = 1521)) ) ) [oracle@gongantest etc]$ lsnrctl start LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 15-DEC-2011 14:17:54 Copyright (c) 1991, 2007, Oracle. All rights reserved. Starting /opt/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 10.2.0.4.0 - Production System parameter file is /opt/oracle/product/10.2.0/db_1/network/admin/listener.ora Log messages written to /opt/oracle/product/10.2.0/db_1/network/log/listener.log Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521))) Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.11.60)(PORT=1521))) Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 10.2.0.4.0 - Production Start Date 15-DEC-2011 14:17:54 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/db_1/network/admin/listener.ora Listener Log File /opt/oracle/product/10.2.0/db_1/network/log/listener.log Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.11.60)(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
四、补充说明
如果把hostname配置在hosts中的127.0.0.1项,那么如果在监听中使用了hostname,再配置一个host监听该机器的ip地址(非127.0.0.1),那么会报文章开头的错误,解决方法有两种:
1、监听中全部采用ip地址
2、在hosts中配置hostname对应ip地址(非127.0.0.1)