WARNING: This web is not used anymore. Please use PDBService.Logrotation instead!
 

Log rotation setup for Oracle log files

Oracle logs grow without limit and need rotation to be set. The main goal is to keep online only a subset of logs that is useful for troubleshooting. Some historical logs can also be retained for a few months.

A script based on Linux logrotate demon is proposed. This script is installed by copying it into the /etc/logrotate.d directory (for example in /etc/logrotate.d/ora_cern_listener_udump_bdump_adump_rotate)

#!/bin/bash

# logrotate configuration file wrapper
# run as oracle user and check the output 
# to install copy output to /etc/logrotate.d
# a few files are created during installation (see touch below), check permissions
# those files should be owned by oracle

# Usage example:
#  ./logrot_ora_install >ora_cern_listener_udump_bdump_adump_rotate
#  sudo mv ora_cern_listener_udump_bdump_adump_rotate /etc/logrotate.d

# Config Here

NODE_NAME=`hostname -s`
DB_NAME=test1
DB_INSTANCE_NAME=test11
ASM_INSTANCE_NAME=+ASM1
ASM_BDUMP=/ORA/dbs00/oracle/admin/+ASM/bdump
ASM_UDUMP=/ORA/dbs00/oracle/admin/+ASM/udump
DB_BDUMP=/ORA/dbs00/oracle/admin/test1/bdump
DB_UDUMP=/ORA/dbs00/oracle/admin/test1/udump
DB_ADUMP=/ORA/dbs00/oracle/admin/test1/adump

# End Config

echo " 
# Log rotation for Oracle files use on Oracle RACs for PDB services 
# handles listener logs, alert logs, bdump and udump trc files
# not handled: clusterware logs, audit logs
# Luca - cern.ch, 24-1-2006

# Install in /etc/logrotate.d
# Needs configuration:
#   file names and paths have to be edited

# 1. rotates the listener log daily and piggybacks tar creation for vatious log files
#    Note: further log rotation steps wil break without daily tar creation
#    edit the listener log name
$ORACLE_HOME/network/log/listener_$NODE_NAME.log {
 firstaction
   find $DB_ADUMP -name '*.aud' -print|xargs tar ufp $DB_ADUMP/OLD_adump_aud.tar --remove-files 2>/dev/null
   chown oracle:ci $DB_ADUMP/OLD_adump_aud.tar
   find $DB_BDUMP -mtime +7 -name '*.trc' -print|xargs tar ufp $DB_BDUMP/OLD_bdump_trc.tar --remove-files 2>/dev/null
   chown oracle:ci $DB_BDUMP/OLD_bdump_trc.tar
   find $DB_UDUMP -mtime +7 -name '*.trc' -print|xargs tar ufp $DB_UDUMP/OLD_udump_trc.tar --remove-files 2>/dev/null
   chown oracle:ci $DB_UDUMP/OLD_udump_trc.tar
   find $ASM_BDUMP -mtime +7 -name '*.trc' -print|xargs tar ufp $ASM_BDUMP/OLD_bdump_trc.tar --remove-files 2>/dev/null
   chown oracle:ci $ASM_BDUMP/OLD_bdump_trc.tar
   find $ASM_UDUMP -mtime +7 -name '*.trc' -print|xargs tar ufp $ASM_UDUMP/OLD_udump_trc.tar --remove-files 2>/dev/null
   chown oracle:ci $ASM_UDUMP/OLD_udump_trc.tar
 endscript
  rotate 21
  ifempty
  size 0
  copytruncate
  nocompress
}

# 2. rotates the alert log 
#    edit the alert log names (db and asm)

$DB_BDUMP/alert_$DB_INSTANCE_NAME.log {
  rotate 14
  size 20M
  copytruncate
  nocompress
}

$ASM_BDUMP/alert_$ASM_INSTANCE_NAME.log {
  rotate 14
  size 20M
  copytruncate
  nocompress
}

# 3. rotates bdump trc files
#    edit the path and file name values

$DB_BDUMP/OLD_bdump_trc.tar {
 rotate 14
 size 20M
 nocompress
}

$ASM_BDUMP/OLD_bdump_trc.tar {
 rotate 14
 size 20M
 nocompress
}

# 4. rotate udump trc files
#    edit file name values

$DB_UDUMP/OLD_udump_trc.tar {
 rotate 14
 size 20M
 nocompress
 }

$ASM_UDUMP/OLD_udump_trc.tar {
 rotate 14
 size 20M
 nocompress
}

# 4. rotate adump .aud files (does not apply to ASM)
#    edit file name values

$DB_ADUMP/OLD_adump_aud.tar {
 rotate 21
 size 1
 nocompress
 }
"

Edit | Attach | Watch | Print version | History: r12 | r10 < r9 < r8 < r7 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r8 - 2006-02-24 - LucaCanali
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    PSSGroup All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback