ITPub博客

首页 > 数据库 > Oracle > oracle 启动监听报错TNS-12547: TNS:lost contact

oracle 启动监听报错TNS-12547: TNS:lost contact

Oracle 作者:lsfzly 时间:2013-12-03 15:41:04 0 删除 编辑
转载地址:http://blog.csdn.net/liqfyiyi/article/details/7534018

监听启动出错,报以下错误:
lsnrctl start
LSNRCTL for Linux: Version 9.2.0.4.0 - Production on 06-JUL-2009 14:37:59
Copyright (c) 1991, 2002, Oracle Corporation.  All rights reserved.
Starting /opt/oracle/product/9ir2/bin/tnslsnr: please wait...
TNS-12547: TNS:lost contact
TNS-12560: TNS:protocol adapter error
TNS-00517: Lost contact
Linux Error: 32: Broken pipe





数据库服务器操作系统为Red Hat AS4,属于32位操作系统,最大文本文件不能超过2G。

当$ORACLE_HOME/network/log中listener.log大小等于2G的时候,无法继续写入日志,监听服务会自动停掉,启动或停止listener时都会报错

:

数据库服务器操作系统为Red Hat AS4,属于32位操作系统,最大文本文件不能超过2G。

当$ORACLE_HOME/network/log中listener.log大小等于2G的时候,无法继续写入日志,监听服务会自动停掉,启动或停止listener时都会报错

解决办法:

1.经常手工去清除listener.log文件的内容,在数据库服务器执行以下命令

       cd $ORACLE_HOME/network/log

       cat listener.log

2、让命令lsnrctl不记录log,在数据库服务器执行以下命令

       lsnrctl

       set log_status off


       quit

     也可以在listener.ora文件中加入logging_listener=off,即可关闭监听日志

 

可能跟这个问题相关的第二种情况,错误信息如下:
TNS-12547: TNS:lost contact
TNS-12560: TNS:protocol adapter error
TNS-00517: Lost contact
Linux Error: 104: Connection reset by peer

这个问题应该跟主机名有关了,查看/etc/hosts文件
[root@olivenan root]# more /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost

然后查看listener.ora文件,发现HOST=ixdba

应该是这里的问题了,那么只需在/etc/hosts增加如下即可

[root@olivenan root]# more /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1  localhost
127.0.0.1  ixdba


 

以下是另外一种情况


 今天上午,遇到一个问题,客户容灾库其中一个节点启动监听报错 TNS-12547: TNS:lost contact (另外一个节点启动正常)

根据抱错,怀疑是lintener.log日志文件太大了,超过2G了,所以无法启动,还有一个可能是/etc/hosts 目录下没有 127.0.0.1     loopback localhost 记录,这是通常导致此错误的常见原因

查看lintener.log日志文件,大小远不足2G,第一种可能排除;

r2:/oracle/app/oracle/product/9.2.0/network/log>ls -lrt
total 24
drwxr-xr-x   2 oracle   dba             256 Nov 15 2007  bak
-rw-r--r--   1 oracle   dba            6414 Feb 24 15:32 sqlnet.log
-rw-r--r--   1 oracle   dba            3025 Jul 09 11:38 listener.log

查看/etc/hosts的内容:127.0.0.1     loopback localhost      # loopback (lo0) name/address也正常,第二种可能排除

/etc/hosts
#
# This file contains the hostnames and their address for hosts in the
# network.  This file is used to resolve a hostname into an Internet
# address. 
#
# At minimum, this file must contain the name and address for each
# device defined for TCP in your /etc/net file.  It may also contain
# entries for well-known (reserved) names such as timeserver
# and printserver as well as any other host name and address.
#
# The format of this file is:
# Internet Address      Hostname        # Comments
# Items are separated by any number of blanks and/or tabs.  A '#'
# indicates the beginning of a comment; characters up to the end of the
# line are not interpreted by routines which search this file.  Blank
# lines are allowed.

# Internet Address      Hostname        # Comments
# 192.9.200.1           net0sample      # ethernet name/address
# 128.100.0.1           token0sample    # token ring name/address
# 10.2.0.2              x25sample       # x.25 name/address
127.0.0.1               loopback localhost      # loopback (lo0) name/address

这里依旧尝试了一下,rm lintener.log,在touch一个listener.log,在启动监听

Lsnrctl stop  -----先停掉listener
rm listener.log ----cd $ORACLE_HOME/network/log
touch listener.log
lsnrctl start

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=135.10.34.38)(PORT=1521)))
TNS-12547: TNS:lost contact
 TNS-12560: TNS rotocol adapter error
  TNS-00517: Lost contact
   IBM/AIX RISC System/6000 Error: 73: Connection reset by peer

报错依旧,查看lintener.log里的记录
09-JUL-2008 12:17:05 * 12546
TNS-12546: TNS ermission denied
 TNS-12560: TNS rotocol adapter error
  TNS-00516: Permission denied


查看其进程:
r2:/oracle/app/oracle/product/9.2.0/network/admin>ps -ef |grep lsnr
  oracle 192870 168578   0 12:16:13  pts/9  0:00 grep lsnr
  oracle 254244 274714   0 11:06:44  pts/0  0:00 lsnrctl
  oracle 242390      1   0 11:06:57  pts/0  0:00 /oracle/app/oracle/product/9.2.0/bin/tnslsnr LISTENER -inherit
rzyzdb2:/oracle/app/oracle/product/9.2.0/network/admin>

kill -9 242390


r2:/oracle/app/oracle/product/9.2.0/network/log>lsnrctl start

LSNRCTL for IBM/AIX RISC System/6000: Version 9.2.0.8.0 - Production on 09-JUL-2008 12:24:21

Copyright   1991, 2006, Oracle Corporation.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=135.10.34.38)(PORT=1521)))
TNS-12537: TNS:connection closed
 TNS-12560: TNS rotocol adapter error
  TNS-00507: Connection closed

查看节点2的sqlnet.ora发现:
问题就在此(sqlnet.ora里面有ip限制的,38这个ip,也就是出故障的这个ip不再sqlnet.ora内容里,将38添加到sqlnet.ora后,启动正常)




自我总结:
服务端:
1、
在修改完/etc/hosts文件后,需将hostname临时重置一下。
[root@localhost ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 zwl localhost



(这个可以忽略)
2、/u01/oracle/product/10.2.0/network/admin/sqlnet.ora
tcp.validnode_checking=no    SQLNET.AUTHENTICATION_SERVICES= (ALL)


3、检查实例名
[root@localhost ~]# su - oracle
[oracle@localhost ~]$ cat .bash_profile 
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
export ORACLE_BASE=/u01/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0
export ORACLE_SID=ora10g  
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib


4、检查监听
[oracle@localhost ~]$ cat /u01/oracle/product/10.2.0/network/admin/listener.ora
# listener.ora Network Configuration File: /u01/oracle/product/10.2.0/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = ora10g)
      (ORACLE_HOME = /u01/oracle/product/10.2.0)
      (SID_NAME = ora10g)
    )
  )

LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.46.131)(PORT = 1521))
  )

[oracle@localhost ~]$ lsnrctl status


LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 17-DEC-2013 16:50:40


Copyright (c) 1991, 2005, Oracle.  All rights reserved.


Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.46.131)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                17-DEC-2013 16:31:26
Uptime                    0 days 0 hr. 19 min. 14 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/oracle/product/10.2.0/network/admin/listener.ora
Listener Log File         /u01/oracle/product/10.2.0/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.46.131)(PORT=1521)))
Services Summary...
Service "ora10g" has 1 instance(s).
  Instance "ora10g", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

客户端:
1、tnsnames.ora可以手动添加
D:\app\Administrator\product\11.1.0\client_1\NETWORK\ADMIN\tnsnames.ora

ORA10G =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.46.131)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = ora10g)
    )
  )
2、客户端cmd   tnsping ora10g  能解析即OK,或者使用Net manager 配置一下tns也一样,和第一步效果是一样的,然后就可以使用pl/sql访问了。
注意tnsping 的有可能是网络服务名,这个可以看一下Net manager 配置。但是也可能是实例名与网络服务名是一样的。直接写文件tnaname.ora也是一样的道理。

C:\Documents and Settings\Administrator> tnsping ora10g_clone2
TNS Ping Utility for 32-bit Windows: Version 11.1.0.6.0 - Production on 17-12月-
2013 16:33:50
Copyright (c) 1997, 2007, Oracle.  All rights reserved.
已使用的参数文件:
D:\app\Administrator\product\11.1.0\client_1\network\admin\sqlnet.ora
已使用 TNSNAMES 适配器来解析别名
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = 192.168.46.131)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = ora10g)))
OK (10 毫秒)

C:\Documents and Settings\Administrator> tnsping ora10g_clone3
TNS Ping Utility for 32-bit Windows: Version 11.1.0.6.0 - Production on 17-12月-
2013 16:38:27
Copyright (c) 1997, 2007, Oracle.  All rights reserved.
已使用的参数文件:
D:\app\Administrator\product\11.1.0\client_1\network\admin\sqlnet.ora
已使用 TNSNAMES 适配器来解析别名
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = 192.168.46.128)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = ora10g)))
OK (0 毫秒)





3、客户端监听与tns

D:\app\Administrator\product\11.1.0\client_1\NETWORK\ADMIN\tnsnames.ora

ORA10G_CLONE2 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.46.131)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = ora10g)
    )
  )


ORA10G_CLONE3 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.46.128)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = ora10g)
    )
  )

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = Oracle8)
      (SID_NAME = ora10g)
    )
  )


LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.46.128)(PORT = 1521))
    )
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.46.131)(PORT = 1521))
    )
  )



一般监听发生问题需检查如下五项:

1、/etc/hosts及域名解析配置文件(注意hostname要和tnsname.ora的host一致,实在搞不清楚就直接使用固定的IP地址吧)

2、监听日志大小

3、监听状态

4、$ORACLE_HOME/oracle可执行文件权限
5、检查数据库配置show parameter local_listener


总结:
show parameter local_listener查到的参数
NAME                                     TYPE          VALUE
------------------------------------ ----------- ------------------------------
local_listener                         string          ORA11G

该VALUE参数对应了tnsnames.ora文件中的监听配置
ORA11G =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.111)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ORA11G)
    )
  )

LISTENER_ORA11G =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.111)(PORT = 1521))










来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29362142/viewspace-1062047/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2013-12-02

  • 博文量
    122
  • 访问量
    97505