温馨提示×

zookeeper日志清理centos怎么操作

小樊
65
2025-08-25 02:00:04
栏目: 智能运维

在CentOS上清理Zookeeper日志,可参考以下方法:

手动清理

  1. 停止Zookeeper服务:sudo systemctl stop zookeeper
  2. 备份日志文件:cp /path/to/zookeeper/logs/* /path/to/backup/logs/
  3. 清理日志文件:find /path/to/zookeeper/logs/ -type f -mtime +7 -exec rm {} \;,可按需修改保留天数。
  4. 重启Zookeeper服务:sudo systemctl start zookeeper

自动清理

  1. 使用zkCleanup.sh脚本:./zkCleanup.sh -n <count> [-d <dataDir>] [-l <dataLogDir>],可设置保留文件数量,通过crontab定时执行。
  2. 配置zoo.cfg文件:设置autopurge.snapRetainCountautopurge.purgeInterval参数,实现自动清理,如autopurge.purgeInterval=24(单位:小时),autopurge.snapRetainCount=5

0