Category : How-to
You’ll be glad to know that GlusterFS has built in log rotation! This means that you can use a simple gluster command to rotate the log for a specific volume. This is very helpful when troubleshooting where it can be easiest to truncate logs before regenerating the issue.
For enduring log rotation I recommend using logrotate which I will cover in a future blog post.
Logs are rotated per volume, so you will need to know the volume name before issuing the command to rotate the log. Use the below command to list all the volumes available on your server:
gluster volume info all | grep "Volume Name"
Use the gluster command, replacing [VOL_NAME] with the volume name of the log file you would like to rotate.
gluster volume log rotate [VOL_NAME]
In the below example, the logs for volume datastore will be rotated.
gluster volume log rotate datastore
Below is the result on the file system displayed with the ls command.
ls -l /var/log/glusterfs/bricks/ total 28 -rw------- 1 root root 119 Nov 1 19:06 mnt-gfs_block.log -rw------- 1 root root 9085 Nov 1 13:46 mnt-gfs_block.log.1383313581 -rw------- 1 root root 236 Nov 1 13:48 mnt-gfs_block.log.1383313684 -rw------- 1 root root 236 Nov 1 13:49 mnt-gfs_block.log.1383313742 -rw------- 1 root root 236 Nov 1 19:06 mnt-gfs_block.log.1383332808
And that’s it! Your log file will be moved and have a time stamp appended, and a new log will be started for the volume.
See my other post on using logrotate for more advanced log rotation.