How to delete or rename listener.log based on Windows or Unix platforms
来源:互联网 发布:传智播客java老师 编辑:程序博客网 时间:2024/06/05 17:00
As the listener.log file grows, the DBA will want to either remove or rename this log file. If you have ever tried to remove or rename the listener.log file on Windows while the TNS listener process was running you will quickly notice that Windows holds a lock on this file and returns an error:
C:\> del C:\oracle\ora92\network\log\listener.log
C:\oracle\ora92\network\log\listener.log
The process cannot access the file because it is being used by another process.
Most DBAs simply stop the TNS listener process, rename (or remove) the file, then restart the TNS listener process. This can, however, cause potention connection errors for users that are attempting to connect while the listener process is down.
Even under UNIX, problems exist when attempting to rename the listener.log file while the TNS listener process is running. Just like under Windows, the Oracle TNS listener process holds an open handle to the file. Under UNIX, you CAN remove the file, but Oracle will not re-create the file when it attempts to write to it again. The TNS listener will need to be stopped and restarted in order for it to create the new listener.log file.
Well, here is a solution for renaming (or removing) the listener.log file without having to stop and start the TNS listener process under either Windows or UNIX:
Windows:
C:\> cd \oracle\ora92\network\log
C:\oracle\ora92\network\log> lsnrctl set log_status off
C:\oracle\ora92\network\log> rename listener.log listener.old
C:\oracle\ora92\network\log> lsnrctl set log_status on
UNIX:
% cd /u01/app/oracle/product/9.2.0/network/log
% lsnrctl set log_status off
% mv listener.log listener.old
% lsnrctl set log_status on
Also, you can reference Matelink :
OpenVMS: How to delete or refresh/recycle a SQL*Net Listener log file while the Listener is active. [ID 739530.1]
Applies to:
Oracle Net Services - Version: 8.1.7.0.0 to 10.2.0.4.0 - Release: 8.1.7 to 10.2
HP OpenVMS Itanium
HP OpenVMS Alpha
Goal
How can I recycle the listener log file without shutting down the listener.
Solution
The LSNRCTL utility can be used to do this.
The following is based on an example using the OpenVMS platform.
The same principles can be used on other platforms. However, the order in which things are done may have to be changed. (see comment at the end)
First, at the OS level, rename the existing Listener log file.
$ RENAME ORA_ROOT:[NETWORK.LOG]LISTENER.LOG ORA_ROOT:[NETWORK.LOG]OLD_LISTENER.LOG
Then use the LSNRCTL utility to recycle the log file.
$ LSNRCTL
SET CURRENT_LISTENER LISTENER
SET LOG_FILE OLD_LISTENER
SET LOG_FILE LISTENER
EXIT
The first SET command tells the LSNRCTL utility which Listener we are handling (e.g LISTENER).
The second SET command opens a new log file called OLD_LISTENER.LOG.
(This now matches with the file we renamed at the OS level).
The third SET command opens a new log file called LISTENER.LOG.
This last step results in closing the OLD_LISTENER.LOG file and opening a new file called
LISTENER.LOG.
The net result is that we have now refreshed the Listener log file without any interruptions.
The original file (now called OLD_LISTENER.LOG in the above example) can be reviewed/deleted as required.
The actions above can be done using an OS script.
For example, on OpenVMS platforms:
$! If no listener name is provided, exit
$ if p1 .eqs. ""
$ then
$ write sys$output " Please provide the listener name"
$ exit
$ endif
$!
$! Create a file containing the required LSNRCTL commands
$!
$ close/nolog opt
$ open/write opt rename.txt
$ write opt "set current_listener ''p1'"
$ write opt "set log_file old_''p1'"
$ write opt "set log_file ''p1'"
$ write opt "exit"
$ close/nolog opt
$!
$! Convert the file to ensure it can be used against all Oracle releases
$!
$ CONVERT/FDL=SYS$INPUT rename.txt rename.txt
RECORD
CARRIAGE_CONTROL carriage_return
FORMAT stream_LF
$!
$! Now execute the commands
$!
$ rename 'p1'.log old_'p1'.log
$ lsnrctl @rename.txt
The above script is then executed with a parameter of the listener to be handled.
Other platforms
+++++++++++
On some platforms (WINDOWS for example) , you can not rename an open file.
Therefore the above method will not work.
However, the following steps could be done to achieve the same goal.
Use LSNRCTL to open a new file (SET LOG_FILE) called TEMP_LISTENER.LOG.
Then back at the OS level, rename the now closed file LISTENER.LOG to OLD_LISTENER.LOG
Then use LSNRCTL again to open a new file (SET LOG_FILE) called LISTENER.LOG
The Listener log file has now been refreshed but you have two old files left on disk (TEMP_LISTENER.LOG and OLD_LISTENER.LOG) which can be reviewed/deleted as required.
- How to delete or rename listener.log based on Windows or Unix platforms
- How to rename a VOB or view
- How to update or delete db
- How to: Linux delete or remove kernel
- How to rename ASM instances in RAC or clustered environment
- eXtremeDB shared memory using in Unix-based OS or Windows
- How To Remove Or Delete PPA In Ubuntu
- 【翻译自mos文章】How to Set or Switch Oracle Homes on Windows (Doc ID 969581.1)
- Implementing Address Windowing Extensions (AWE) or VLM on 32-bit Windows Platforms [ID 225349.1]
- Based on or Basing on, 为何写作多用 Based on?
- How to create the index on view or table
- How to create desktop shortcut or launcher on Linux
- How to diff and merge files or directories on Linux
- How to fix yum errors on CentOS, RHEL or Fedora
- How to Install OSSEC on Red Hat or CentOS 6
- How to disable PackageKit on CentOS, Fedora or RHEL
- How to show or hide filename extensions on Mac
- How to work around a possible XNA Game Studio or Windows Phone SDK install failure on Windows 8
- C语言中一些关键字的作用
- python_给框架增加窗口控件
- 从1-10000中找出2个缺失的数
- 交叉验证
- 我的现实啊
- How to delete or rename listener.log based on Windows or Unix platforms
- Assigned Internet Protocol Numbers
- 但他坚持扛到了最后
- 利用 JAVA 操作 EXCEL 文件
- 项目与库文件链接引用
- 比赛态度很好
- javascript倒计时(45分钟)
- word中怎样在一段文字的右边加注释,修订的具体用法及作用
- UVA 10970 - Big Chocolate