Skip to content
Visit booth 3171 at Google Cloud Next to see how to unlock real-time decisions at scaleMore info

Manage log rotation

Aerospike manages log rotation with the Linux logrotate tool, which is installed by default on most versions of Linux. If your OS does not include logrotate, this page describes how to install it.

Install the logrotate binary

Install on CentOS
sudo yum install logrotate
Install on Debian and Ubuntu
sudo apt-get install logrotate

Configure logrotate policy for Aerospike

If your system is configured with logrotate.d to manage log rotation, use <logrotate.d>/aerospike as the filename. On Aerospike installation, a log rotation policy file is set up at /etc/logrotate.d/aerospike that specifies:

  • The log should be rotated every day
  • Compress the old log files
  • Retain files for 90 days
  • Use date as the suffix
  • Use sharedscripts when rotating multiple files.

Logrotate policy

If there are no pid files (on systemd based installations, if logrotate is preferred over journald), the postrotate kill -HUP command should use either pidof asd or pgrep -x asd.

Terminal window
/var/log/aerospike/aerospike.log {
daily
rotate 90
dateext
compress
olddir /var/log/aerospike/
sharedscripts
postrotate
/bin/kill -HUP `pgrep -x asd`
endscript
}

Logrotate policy with multiple files

Multiple log sync files can be configured to be rotated and use the same logrotate configuration and postrotate script.

Terminal window
/var/log/aerospike/aerospike.log /var/log/aerospike/xdr.log {
daily
rotate 90
dateext
compress
olddir /var/log/aerospike/
sharedscripts
postrotate
/bin/kill -HUP `pgrep -x asd`
endscript
}

Force run a logrotate to test

sudo logrotate -f -v /etc/logrotate.d/aerospike

Example output:

logrotate -f -v /etc/logrotate.d/aerospike
reading config file /etc/logrotate.d/aerospike
olddir is now /var/log/aerospike/
Allocating hash table for state file, size 15360 B
Handling 1 logs
rotating pattern: /var/log/aerospike/aerospike.log forced from command line (90 rotations)
olddir is /var/log/aerospike/, empty log files are rotated, old logs are removed
considering log /var/log/aerospike/aerospike.log
log needs rotating
rotating log /var/log/aerospike/aerospike.log, log->rotateCount is 90
dateext suffix '-20171101'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
glob finding old rotated logs failed
renaming /var/log/aerospike/aerospike.log to /var/log/aerospike//aerospike.log-20171101
running postrotate script
compressing log with: /bin/gzip
Feedback

Was this page helpful?

What type of feedback are you giving?

What would you like us to know?

+Capture screenshot

Can we reach out to you?