您好,登錄后才能下訂單哦!
十一假期間,某客戶因?yàn)楸O(jiān)聽日志問題導(dǎo)致系統(tǒng)登錄掛起,當(dāng)時(shí)在返京的路上,因客戶業(yè)務(wù)不允許中斷,無奈之下,借了個(gè)本子幫客戶做了緊急處理,今天恰好有空,在網(wǎng)上搜了下有關(guān)監(jiān)聽日志的內(nèi)容,發(fā)現(xiàn)一個(gè)不錯(cuò)的帖子,內(nèi)容比較全,且比較準(zhǔn)確,記錄一下,以便同學(xué)和自己今后研究學(xué)習(xí)。該貼轉(zhuǎn)自:https://blog.csdn.net/leshami/article/details/6629043。
--========================
-- Oracle listener log配置與管理
--========================
Oracle 監(jiān)聽器是一個(gè)服務(wù)器端程序,用于監(jiān)聽所有來自客戶端的請(qǐng)求,并為其提供數(shù)據(jù)庫(kù)服務(wù)。因此對(duì)監(jiān)聽器的管理與維護(hù)相當(dāng)重要。
本文主要描述對(duì)Oracle listener log的配置與管理。有關(guān)監(jiān)聽器的描述請(qǐng)參考
配置 ORACLE 客戶端連接到數(shù)據(jù)庫(kù)
配置非默認(rèn)端口的動(dòng)態(tài)服務(wù)注冊(cè)
一、 listener log特性
1. listener log是一個(gè)純文本文件,通常位于$ORACLE_HOME/network/log目錄下,與sqlnet.log日志文件處于同一路徑
2. 其缺省的文件名為listener.log。對(duì)于非缺省的監(jiān)聽器,則產(chǎn)生的日志文件通常為listenername.log
3. 該文件缺省由監(jiān)聽器自動(dòng)創(chuàng)建,當(dāng)日志文件丟失時(shí)或不存在時(shí),會(huì)自動(dòng)重新創(chuàng)建一個(gè)同名的文件,與alert_<SID>.log文件類似
4. 該文件的尺寸會(huì)不斷自動(dòng)增長(zhǎng),當(dāng)尺寸過大時(shí)或不便于閱讀時(shí),考慮將其備份
5. Oracle監(jiān)聽器在運(yùn)行時(shí)不允許對(duì)日志文件做刪除,重命名操作
6. 可以設(shè)置日志狀態(tài)為ON或OFF來實(shí)現(xiàn)啟用或關(guān)閉日志
二、設(shè)置日志文件目錄及路徑
1. 設(shè)置日志文件目錄的兩種方法
lsnrctl SET LOG_DIRECTORY directory
LSNRCTL> SET LOG_DIRECTORY /usr/oracle/admin/log
2. 設(shè)置日志文件的兩種方法
lsnrctl SET LOG_FILE file_name
LSNRCTL> SET LOG_FILE file_name
3. 設(shè)置日志的狀態(tài)
lsnrctl ET LOG_STATUS {on | off}
LSNRCTL> SET LOG_STATUS {on | off}
4. 演示設(shè)置
a. 切換到日志目錄查看日志文件
[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. 查看當(dāng)前監(jiān)聽器的狀態(tài)
[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. 設(shè)置監(jiān)聽器目錄及日志文件
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. 查看新路徑下產(chǎn)生的日志文件
[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 -->設(shè)置目錄之后生成的
-rw-r--r-- 1 oracle oinstall 113 Jun 27 02:12 listener_test.log -->設(shè)置日志文件名之后的新日志文件
[oracle@test log]$ ls -hltr -->隔段時(shí)間查看,原來的日志文件不再增長(zhǎng),使用設(shè)定的日志文件名記錄日志
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配置文件的變化
[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
#--------------------------------------------
三、日志文件的備份與重命名
通常情況下,需要停止監(jiān)聽器來對(duì)日志文件進(jìn)行備份,下面使用不停止監(jiān)聽的情況下對(duì)日志文件重命名以實(shí)現(xiàn)備份
1. Windows平臺(tái)的處理
C:\>cd \oracle\ora92\network\log -->切換到 listener log所在目錄
C:\oracle\ora92\network\log> lsnrctl set log_status off -->暫停或脫機(jī)記錄日志文件
C:\oracle\ora92\network\log> rename listener.log listener.old -->重命名日志文件,一般加上日期
C:\oracle\ora92\network\log> lsnrctl set log_status on -->聯(lián)機(jī) listener log,會(huì)自動(dòng)重新創(chuàng)建一個(gè)新的日志文件
2. Unix/Linux平臺(tái)的處理
$ 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平臺(tái)下重命名日志文件
[oracle@test ~]$ cd /home/oracle/log
[oracle@test log]$ lsnrctl set log_status off -->如果存在密碼,應(yīng)使用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
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。