–========================
— Oracle Listener log configuration and management
–========================
Oracle The listener is a server-side program , Used to listen for all requests from clients , And provide database services for it . Therefore, the management and maintenance of the monitor is very important .
In this paper, we mainly describe the relationship between Oracle Configuration and management of listener log files . For a description of the listener, please refer to
To configure ORACLE The client connects to the database
Configure dynamic service registration for non default ports
One 、 Listener logging features
1. The listener log is a plain text file , Usually located in $ORACLE_HOME/network/log Under the table of contents , And sqlnet.log Log files are in the same path
2. The default file name is listener.log. For non default listeners , The generated log file is usually listenername.log
3. This file is automatically created by the listener by default , When the log file is missing or does not exist , Will automatically recreate a file with the same name , And alert_<SID>.log File similar
4. The size of the file will continue to grow automatically , When the size is too large or not easy to read , Consider backing it up
5. Oracle The listener is not allowed to delete log files at runtime , Rename operation
6. You can set the log status to ON or OFF To enable or disable logging
Two 、 Set the log file directory and path
1. Two ways to set the log file directory
[sql] view plain copy print ?
- lsnrctl SET LOG_DIRECTORY directory
- LSNRCTL> SET LOG_DIRECTORY /usr/oracle/admin/log
2. Two ways to set up log files
[sql] view plain copy print ?
- lsnrctl SET LOG_FILE file_name
- LSNRCTL> SET LOG_FILE file_name
3. Set the status of the log
[sql] view plain copy print ?
- lsnrctl SET LOG_STATUS {on | off}
- LSNRCTL> SET LOG_STATUS {on | off}
4. Demo settings
a. Switch to the log directory to view the log file
[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. View the status of the current listener
[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. Set listener directory and log file
[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. View the log file generated under the new path
[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 –> After setting the directory
- -rw-r–r– 1 oracle oinstall 113 Jun 27 02:12 listener_test.log –> Set the new log file after the log file name
- [oracle@test log]$ ls -hltr –> Check every other time , The original log file no longer grows , Log with the set log file name
- 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. see listener.ora Changes in configuration files
[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
- #——————————————–
3、 … and 、 Backup and rename of log files
Usually , You need to stop the listener to back up the log file , Next, rename the log file without stopping listening to realize backup
1. Windows Platform handling
[sql] view plain copy print ?
- C:\>cd \oracle\ora92\network\log –> Switch to the directory where the listener log file is located
- C:\oracle\ora92\network\log> lsnrctl set log_status off –> Pause or log files offline
- C:\oracle\ora92\network\log> rename listener.log listener.old –> Rename log file , Usually with dates
- C:\oracle\ora92\network\log> lsnrctl set log_status on –> Online listener log file , A new log file will be created automatically
2. Unix/Linux Platform handling
[sql] view plain copy print ?
- $ lsnrctl set log_status off
- $ mv listener.log listener.old –> Another way ,cp listener.log /log/bak/. then cp /dev/null >listener.log
- $ lsnrctl set log_status on
3. demonstration Linux Rename log files under the platform
[sql] view plain copy print ?
- [oracle@test ~]$ cd /home/oracle/log
- [oracle@test log]$ lsnrctl set log_status off –> If there is a password , You should use LSNRCTL Interface
- 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