0%

Oracle TNS-12541、TNS-00511 无监听程序

一台Windows服务器上安装的oralce服务器很卡,于是同事就重启了一下,然后……,你想到了,起不来了。折腾了好久,服务器终于起来了,oracle起不来,记录一下故障原因

提示错误信息

如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Fatal NI connect error 12541, connecting to:
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=WIN-EPRQ7FK9EK2)(PORT=1521))(CONNECT_DATA=(SID=orcl)(CID=(PROGRAM=E:\app\Administrator\product\11.2.0\dbhome_4\bin\emagent.exe)(HOST=WIN-EPRQ7FK9EK2)(USER=SYSTEM))))

VERSION INFORMATION:
TNS for 64-bit Windows: Version 11.2.0.1.0 - Production
Windows NT TCP/IP NT Protocol Adapter for 64-bit Windows: Version 11.2.0.1.0 - Production
Time: 13-6月 -2017 10:58:58
Tracing not turned on.
Tns error struct:
ns main err code: 12541
TNS-12541: TNS: 无监听程序
ns secondary err code: 12560
nt main err code: 511
TNS-00511: 无监听程序
nt secondary err code: 61
nt OS err code: 0

故障原因

oracle运行时间过长,listener.log日志超过4G导致,此为oracle bug;BUG号为9879101 : THE CONNECT THROUGH LISTENER WAS SLOW WHEN LISTNER LOG GROWED 4GB

解决方法

  1. 找到日志文件 E:\app\Administrator\diag\tnslsnr**WIN-EPRQ7FK9EK2**\listener\trace\listener.log
  2. 经查看,该日志大小为4.00 GB (4,294,967,340 字节)
  3. 删除该文件,启动监听、服务,恢复正常

顺手写个脚本放计划任务里

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
@echo off   
echo ================================================
echo E:\app\Administrator\diag\tnslsnr\WIN-EPRQ7FK9EK2\listener\trace\listener.log 备份文件,用来解决日志问超过4G,数据库监听死掉问题
echo ================================================
::以“YYYYMMDD”格式取出当前时间。
set BACKUPDATE=%date:~0,4%%date:~5,2%%date:~8,2%
set DATADIR=E:\app\Administrator\diag\tnslsnr\WIN-EPRQ7FK9EK2\listener\trace\

echo 备份日志文件
e:
cd %DATADIR%
lsnrctl set log_status off
rename listener.log listener.log_%BACKUPDATE%
lsnrctl set log_status on
echo 删除30天以前的日志文件
forfiles -p %DATADIR% -s -m listener.log_* -d -30 -c "cmd /c del @path"