Use Logrotator for managing slony files.

Logrotator is a small C program which is well written and available on most of the UNIX based OS. It allows automatic rotation, compression of logfiles and removal of old logfiles. This small file can be use to manage applications logfiles. It can also use for managing slony logfiles.

For managing logfiles using logrotator user has to make a logrotator conf file, and can be scheduled in crontab for managing logile.

Let see how you can make a logrotator configuration file for slony.

I have slony master/slave daemon running on my slave maching has following location for slony logfiles:
/opt/PostgresPlus/9.0AS/slony_test/slony1/node1 -- For master
/opt/PostgresPlus/9.0AS/slony_test/slony1/node2 -- For slave.
For managing logfile, user can make logrotator configuration file similar to given below:
Configuration filename: /etc/logrotate.d/slonylogfiles

"/opt/PostgresPlus/9.0AS/slony_test/slony1/node[12]/*.log"  {
       rotate 5
       mail vibhor.aim@gmail.com
       size 1k
       copytruncate
       delaycompress
       compress
       notifempty
       missingok
       }

Above configuration file has been made to rotate the logfiles of slony as the size of logfile exceeds 1kilo bytes.

Following are the description of parameters used in configuration file:
rotate 5: this parameter directs logrotator to remove/mail to specified address/directory. If value is 0 then, logrotate will remove the old version of logfile at the place of rotate.

mail: this parameter tells logrotator about command which it can use to mail logfiles.

size: this parameter tells logrotator to rotate the logfile when logfile grow bigger than size mentioned with this parameter.

copytruncate: this parameter tells, logrotator to truncate the original logfile after creating a copy of the logfile.

delaycompress: This parameter is for postponing the compression of previous log file to the next rotation cycle.

compress: this tells logrotator to compress the old logfile using gzip.

notifempty: This parameter makes logrotator not to rotate the logfile if it is empty.

missingok: This parameter is for making logrotator to continue for the next logfile, if logfile is missing.

After making above logrotator configuration file, user can schedule logrotator in crontab as given below:
00 00 * * * logrotate -s /opt/PostgresPlus/9.0AS/slony.status //etc/logrotate.d/slonylogfiles 

Other form of configuration file is given below:
For daily Logrotator:
"/opt/PostgresPlus/9.0AS/slony_test/slony1/node[12]/*.log"  {
       daily
       rotate 5
       mail vibhor.aim@gmail.com
       size 1k
       copytruncate
       delaycompress
       compress
       notifempty
       missingok
       }
For monthly logrotator
"/opt/PostgresPlus/9.0AS/slony_test/slony1/node[12]/*.log"  {
       monthly
       rotate 5
       mail vibhor.aim@gmail.com
       size 1k
       copytruncate
       delaycompress
       compress
       notifempty
       missingok
       }
similarly user can make weekly slony configuration file.

Comments

Post a Comment

Popular posts from this blog

xDB Replication from Oracle to PPAS

Does UPDATE Change ROWID in Oracle?

PostgreSQL Database Link to Oracle Database on Linux