--========================
-- Oracle 监听器日志配置与管理
--========================
Oracle 监听器是一个服务器端程序,用于监听所有来自客户端的请求,并为其提供数据库服务。因此对监听器的管理与维护相当重要。
本文主要描述对Oracle监听器日志文件的配置与管理。有关监听器的描述请参考
配置 ORACLE 客户端连接到数据库
配置非默认端口的动态服务注册
一、监听器日志特性
1. 监听器日志是一个纯文本文件,通常位于$ORACLE_HOME/network/log目录下,与sqlnet.log日志文件处于同一路径
2. 其缺省的文件名为listener.log。对于非缺省的监听器,则产生的日志文件通常为listenername.log
3. 该文件缺省由监听器自动创建,当日志文件丢失时或不存在时,会自动重新创建一个同名的文件,与alert_<SID>.log文件类似
4. 该文件的尺寸会不断自动增长,当尺寸过大时或不便于阅读时,考虑将其备份
5. Oracle监听器在运行时不允许对日志文件做删除,重命名操作
6. 可以设置日志状态为ON或OFF来实现启用或关闭日志
二、设置日志文件目录及路径
1. 设置日志文件目录的两种方法
[sql] view plain copy
print?
-
lsnrctl SET LOG_DIRECTORY directory
-
-
LSNRCTL> SET LOG_DIRECTORY /usr/oracle/admin/log
2. 设置日志文件的两种方法
[sql] view plain copy
print?
-
lsnrctl SET LOG_FILE file_name
-
-
LSNRCTL> SET LOG_FILE file_name
3. 设置日志的状态
[sql] view plain copy
print?
-
lsnrctl SET LOG_STATUS {on | off}
-
-
LSNRCTL> SET LOG_STATUS {on | off}
4. 演示设置
a. 切换到日志目录查看日志文件
[sql] view plain copy
print?
-
[oracle@test ~]$ cd $ORACLE_HOME/network/log
-
[oracle@test log]$ ls -hltr
-
total 348K
-
-rw-r--r-- 1 oracle oinstall 305K Apr 6 05:30 listener.log
-
-rw-r--r-- 1 oracle oinstall 26K Jun 27 01:52 listener_demo92.log
b. 查看当前监听器的状态
[sql] view plain copy
print?
-
[oracle@test log]$ lsnrctl status listener_demo92
-
-
LSNRCTL for Linux: Version 9.2.0.8.0 - Production on 27-JUN-2011 01:54:31
-
-
Copyright (c) 1991, 2006, Oracle Corporation. All rights reserved.
-
-
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test)(PORT=1521)))
-
STATUS of the LISTENER
-
------------------------
-
Alias listener_demo92
-
Version TNSLSNR for Linux: Version 9.2.0.8.0 - Production
-
Start Date 27-JUN-2011 01:52:18
-
Uptime 0 days 0 hr. 2 min. 13 sec
-
Trace Level off
-
Security ON
-
SNMP OFF
-
Listener Parameter File /oracle/92/network/admin/listener.ora
-
Listener Log File /oracle/92/network/log/listener_demo92.log
-
Listening Endpoints Summary...
-
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=test)(PORT=1521)))
-
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))
-
Services Summary...
-
Service "demo92" has 1 instance(s).
-
Instance "demo92", status READY, has 1 handler(s) for this service...
-
The command completed successfully
-
c. 设置监听器目录及日志文件
[sql] view plain copy
print?
-
LSNRCTL> set current_listener listener_demo92
-
Current Listener is listener_demo92
-
LSNRCTL> set password
-
Password:
-
The command completed successfully
-
LSNRCTL> set log_directory /home/oracle/log
-
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test)(PORT=1521)))
-
listener_demo92 parameter "log_directory" set to /home/oracle/log
-
The command completed successfully
-
LSNRCTL> set log_file listener_test.log
-
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test)(PORT=1521)))
-
listener_demo92 parameter "log_file" set to listener_test.log
-
The command completed successfully
-
LSNRCTL> set log_status on
-
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test)(PORT=1521)))
-
listener_demo92 parameter "log_status" set to ON
-
The command completed successfully
-
LSNRCTL> save_config
-
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=test)(PORT=1521)))
-
Saved listener_demo92 configuration parameters.
-
Listener Parameter File /oracle/92/network/admin/listener.ora
-
Old Parameter File /oracle/92/network/admin/listener.bak
-
The command completed successfully
-
LSNRCTL> exit
d. 查看新路径下产生的日志文件
[sql] view plain copy
print?
-
[oracle@test admin]$ cd /home/oracle/log
-
[oracle@test log]$ ls -hltr
-
total 16K
-
-rw-r--r-- 1 oracle oinstall 41 Jun 27 02:11 listener_demo92.log -->设置目录之后生成的
-
-rw-r--r-- 1 oracle oinstall 113 Jun 27 02:12 listener_test.log -->设置日志文件名之后的新日志文件
-
-
[oracle@test log]$ ls -hltr -->隔段时间查看,原来的日志文件不再增长,使用设定的日志文件名记录日志
-
total 16K
-
-rw-r--r-- 1 oracle oinstall 41 Jun 27 02:11 listener_demo92.log
-
-rw-r--r-- 1 oracle oinstall 1.3K Jun 27 02:17 listener_test.log
e. 查看listener.ora配置文件的变化
[sql] view plain copy
print?
-
[oracle@test admin]$ more listener.ora
-
#----ADDED BY TNSLSNR 27-JUN-2011 02:12:37---
-
LOG_DIRECTORY_listener_demo92 = /home/oracle/log
-
LOG_FILE_listener_demo92 = listener_test.log
-
LOGGING_listener_demo92 = ON
-
#--------------------------------------------
三、日志文件的备份与重命名
通常情况下,需要停止监听器来对日志文件进行备份,下面使用不停止监听的情况下对日志文件重命名以实现备份
1. Windows平台的处理
[sql] view plain copy
print?
-
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 -->联机监听器日志文件,会自动重新创建一个新的日志文件
2. Unix/Linux平台的处理
[sql] view plain copy
print?
-
$ lsnrctl set log_status off
-
$ mv listener.log listener.old -->另一种方法,cp listener.log /log/bak/. 然后 cp /dev/null >listener.log
-
$ lsnrctl set log_status on
3. 演示Linux平台下重命名日志文件
[sql] view plain copy
print?
-
[oracle@test ~]$ cd /home/oracle/log
-
[oracle@test log]$ lsnrctl set log_status off -->如果存在密码,应使用LSNRCTL界面来完成
-
-
LSNRCTL for Linux: Version 9.2.0.8.0 - Production on 27-JUN-2011 02:41:09
-
-
Copyright (c) 1991, 2006, Oracle Corporation. All rights reserved.
-
-
Connecting to (ADDRESS=(PROTOCOL=tcp)(PORT=1521))
-
LISTENER parameter "log_status" set to OFF
-
The command completed successfully
-
[oracle@test log]$ mv listener_test.log listener_test.old
-
[oracle@test log]$ lsnrctl set log_status on
-
-
LSNRCTL for Linux: Version 9.2.0.8.0 - Production on 27-JUN-2011 02:41:31
-
-
Copyright (c) 1991, 2006, Oracle Corporation. All rights reserved.
-
-
Connecting to (ADDRESS=(PROTOCOL=tcp)(PORT=1521))
-
LISTENER parameter "log_status" set to ON
-
The command completed successfully
...............................................................................................................................
● 本文来自于CSDN转载文章,若有侵权,请联系小麦苗及时删除,非常感谢原创作者Leshami的无私奉献
● 本文在itpub(http://blog.itpub.net/26736162)、博客园(http://www.cnblogs.com/lhrbest)和个人微信公众号(xiaomaimiaolhr)上有同步更新
● QQ群:230161599 微信群:私聊
● 原文地址:http://blog.csdn.net/leshami/article/details/6629043
● 小麦苗云盘地址:http://blog.itpub.net/26736162/viewspace-1624453/
● QQ群: 230161599 微信群:私聊
● 联系我请加QQ好友(642808185),注明添加缘由
●【版权所有,文章允许转载,但须以链接方式注明源地址,否则追究法律责任】
...............................................................................................................................
手机长按下图识别二维码或微信客户端扫描下边的二维码来关注小麦苗的微信公众号:xiaomaimiaolhr,免费学习最实用的数据库技术。
|