Moneycontrol Brokerage Recos

Sunday, May 15, 2016

How to compress SCAN_LISTENER log file in Oracle RAC environment?

Sometimes we are in need to compress SCAN listener log files to release space on underline mount point due huge growth of its size.

We follow the below steps to compress a SCAN listener log file.


Step 1 : Login as Grid Infrastructure user (it may be oracle as RDBMS user or oragrid/grid user in your environment, you can easily find it using - ps -ef | grep tns)

In my case ASM/GI is running with oragrid user.


[root@rac1 ~]# ps -ef | grep pmon
oragrid   5734     1  0 14:30 ?        00:00:00 asm_pmon_+ASM1
oracle    6440     1  0 14:31 ?        00:00:00 ora_pmon_ractst1
root      7145  7110  0 14:33 pts/1    00:00:00 grep pmon




[root@rac1 ~]# ps -ef | grep tns
root         9     2  0 14:27 ?        00:00:00 [netns]
oragrid   6279     1  0 14:30 ?        00:00:00 /u01/app/11.2.0/grid/bin/tnslsnr LISTENER_SCAN1 -inherit
oragrid   6281     1  0 14:30 ?        00:00:00 /u01/app/11.2.0/grid/bin/tnslsnr LISTENER -inherit
root      7196  7110  0 14:34 pts/1    00:00:00 grep tns



Step 2 : Invoke LSNRCTL command line utility from GRID_HOME/bin directory.


Step 3 : set the current listener to the appropriate SCAN_LISTENER name you want to compress the log file as depicted below.


LSNRCTL> set current_listener LISTENER_SCAN1
Current Listener is LISTENER_SCAN1
LSNRCTL>


Now, if we check the status of listener then by default it is set to LISTENER_SCAN1 for now.

STATUS of the LISTENER
------------------------
Alias                     LISTENER_SCAN1
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                15-MAY-2016 14:31:00
Uptime                    0 days 0 hr. 5 min. 30 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/11.2.0/grid/network/admin/listener.ora
Listener Log File         /u01/app/11.2.0/grid/log/diag/tnslsnr/rac1/listener_scan1/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_SCAN1)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.105)(PORT=1521)))
Services Summary...
Service "ractst" has 2 instance(s).
  Instance "ractst1", status READY, has 1 handler(s) for this service...
  Instance "ractst2", status READY, has 1 handler(s) for this service...
Service "ractstXDB" has 2 instance(s).
  Instance "ractst1", status READY, has 1 handler(s) for this service...
  Instance "ractst2", status READY, has 1 handler(s) for this service...
The command completed successfully





Step 4 : Set the log_status to OFF for the current listener.


LSNRCTL> set log_status off
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1)))
LISTENER_SCAN1 parameter "log_status" set to OFF
The command completed successfully



Step 5 : Now, go to listener log location ( in my case, current listener is LISTENER_SCAN1 and it;s log file location can be obtained from status of the listener i.e. /u01/app/11.2.0/grid/log/diag/tnslsnr/rac1/listener_scan1).


[oragrid@rac1 trace]$ pwd
/u01/app/11.2.0/grid/log/diag/tnslsnr/rac1/listener_scan1/trace


[oragrid@rac1 trace]$ ls -ltr
total 220
-rw-r----- 1 oragrid oinstall 221096 May 15 14:37 listener_scan1.log


Step 6 : Compress or rename the SCAN LISTENER log file now.

 [oragrid@rac1 trace]$ gzip listener_scan1.log 

[oragrid@rac1 trace]$ ls -ltr
total 12
-rw-r----- 1 oragrid oinstall 11457 May 15 14:37 listener_scan1.log.gz  -- Compressed now.



Step 7 : Go back to the LSNRCTL prompt and turn ON the log_status parameter.

Note : If you are working on the same prompt then again you will have to set current listener to the same SCAN listener name to trun ON logging that you did OFF in step 4

LSNRCTL> set current_listener LISTENER_SCAN1
Current Listener is LISTENER_SCAN1

LSNRCTL> set log_status on
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1)))
LISTENER_SCAN1 parameter "log_status" set to ON
The command completed successfully


Now you would see a new SCAN listener log file is created at that location.

[oragrid@rac1 trace]$ pwd
/u01/app/11.2.0/grid/log/diag/tnslsnr/rac1/listener_scan1/trace

[oragrid@rac1 trace]$ ls -ltr
total 16
-rw-r----- 1 oragrid oinstall 11457 May 15 14:37 listener_scan1.log.gz
-rw-r----- 1 oragrid oinstall    73 May 15 14:53 listener_scan1.log



Hope it would be a help !!





No comments:

Post a Comment