• zookeeper定时清理log


    在zookeeper的目录下新建一个脚本,内容如下(zookeeper bin下面也有zkCleanup.sh脚本,原理一样,都是调用java类)

    shell_dir=$(cd "$(dirname "$0")"; pwd)
    
    cd $shell_dir && java -cp zookeeper-3.4.5.jar:lib/log4j-1.2.15.jar:lib/slf4j-api-1.6.1.jar:lib/slf4j-log4j12-1.6.1.jar:conf/log4j.properties org.apache.zookeeper.server.PurgeTxnLog /zoo-datadir/ /zoo-datadir/ -n 5

    其中/zoo-datadir对应dataDir和dataLogDir,-n代表保留的snapshot的数量,默认是3,加入crontab,每天执行crontab -e

    0 */1 * * * /root/zookeeper/zookeeper-3.4.5/purgeTxnLog.sh 

    service crond restart

    如果是zookeeper3.4之后的版本,可以通过修改zoo.cfg配置文件的形式,zookeeper自动清理

    # The number of snapshots to retain in dataDir
    autopurge.snapRetainCount=3
    # Purge task interval in hours
    # Set to "0" to disable auto purge feature
    autopurge.purgeInterval=1
  • 相关阅读:
    限制结果集行数
    函数的差异
    运算符的差异
    数据类型的差异
    简介
    Spring源码阅读入门指引
    Spring的三种注入方式
    AOP面向切面编程
    leetcode771
    leetcode669
  • 原文地址:https://www.cnblogs.com/yanghuahui/p/3514225.html
Copyright © 2020-2023  润新知