Overview
Proper log retention is essential for monitoring, troubleshooting, and managing storage in a YugabyteDB environment. This article provides guidance on configuring log retention settings for TServer, Master, and PostgreSQL logs.
Note: Currently, these steps must be executed on each database node one at a time.
TServer and Master Logs Configuration
YugabyteDB provides a script, zip_purge_yb_logs.sh
, to manage log retention by setting disk usage thresholds. The script is located at:
/home/yugabyte/bin/zip_purge_yb_logs.sh
This script allows you to specify retention parameters via systemd unit files or crontab, depending on the system configuration.
Steps to Configure Log Retention for systemd install:
- Locate the systemd service file (for systemd-based systems):
sudo nano /etc/systemd/system/yb-zip_purge_yb_logs.service
- Modify the ExecStart line by adding relevant parameters to zip_purge_yb_logs.sh. Example:
ExecStart=/home/yugabyte/bin/zip_purge_yb_logs.sh -p 15 -t 15
This configuration sets:-p 15
: Maximum 15% of disk space for logs.-t 15
: Maximum 15GB for server logs.
- Restart the service to apply changes:
sudo systemctl daemon-reload sudo systemctl restart yb-zip_purge_yb_logs.service
Steps to Configure Log Retention for cron-based install:
- Open the crontab configuration:
crontab -e
- Add or modify an entry like:
0 0 * * * /home/yugabyte/bin/zip_purge_yb_logs.sh -p 15 -t 15
PostgreSQL Logs Configuration
PostgreSQL logs can be managed using the same script with the -s
flag:
/home/yugabyte/bin/zip_purge_yb_logs.sh -s 200
This sets the maximum PostgreSQL log storage size to 200MB.
To update this setting:
- Open the systemd service file:
sudo nano /etc/systemd/system/yb-zip_purge_yb_logs.service
- Modify the ExecStart line:
ExecStart=/home/yugabyte/bin/zip_purge_yb_logs.sh -s 200
- Restart the service:
sudo systemctl daemon-reload sudo systemctl restart yb-zip_purge_yb_logs.service
Best Practices for Log Retention Management
- Balance retention and storage: Set appropriate thresholds to avoid excessive disk usage while retaining enough logs for debugging.
- Use log compression: Enable
-z
flag to gzip logs instead of deleting them. - Monitor disk space: Regularly check disk utilization and adjust parameters as needed.
- Automate cleanup: Use systemd or cron jobs to ensure periodic log rotation and purging.
By following these steps, you can effectively manage log retention in your YugabyteDB environment, ensuring optimal performance and storage utilization.
Comments
0 comments
Please sign in to leave a comment.