近期公司Zookeeper得log文件将系统占用快满了,查看相关文档,
从3.4.0开始,zookeeper提供了自动清理snapshot和事务日志的功能,
通过配置 autopurge.snapRetainCount 和 autopurge.purgeInterval 这两个参数能够实现定时清理了。
这两个参数都是在zoo.cfg中配置的,将其前面的注释去掉,根据需要修改日志保留个数:
-
# Licensed to the Apache Software Foundation (ASF) under one
-
# or more contributor license agreements. See the NOTICE file
-
# distributed with this work for additional information
-
# regarding copyright ownership. The ASF licenses this file
-
# to you under the Apache License, Version 2.0 (the
-
# "License"); you may not use this file except in compliance
-
# with the License. You may obtain a copy of the License at
-
#
-
# http://www.apache.org/licenses/LICENSE-2.0
-
#
-
# Unless required by applicable law or agreed to in writing,
-
# software distributed under the License is distributed on an
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-
# KIND, either express or implied. See the License for the
-
# specific language governing permissions and limitations
-
# under the License.
-
#
-
#
-
#
-
# The number of milliseconds of each tick
-
tickTime=2000
-
# The number of ticks that the initial
-
# synchronization phase can take
-
initLimit=10
-
# The number of ticks that can pass between
-
# sending a request and getting an acknowledgement
-
syncLimit=5
-
# the directory where the snapshot is stored.
-
dataDir=/diska/hadoop/zookeeper
-
# the port at which the clients will connect
-
clientPort=2181
-
server.1=dn110.104.jx:2888:3888
-
server.2=dn111.104.jx:2888:3888
-
server.3=dn112.104.jx:2888:3888
-
-
# Custom properties
-
autopurge.purgeInterval=1
-
maxClientCnxns=300
-
autopurge.snapRetainCount=3
autopurge.purgeInterval
这个参数指定了清理频率,单位是小时,需要填写一个1或更大的整数,默认是0,表示不开启自己清理功能。
autopurge.snapRetainCount
这个参数和上面的参数搭配使用,这个参数指定了需要保留的文件数目。默认是保留3个。
maxClientCnxns
单个客户端与单台服务器之间的连接数的限制,是ip级别的,默认是60,如果设置为0,那么表明不作任何限制。请注意这个限制的使用范围,仅仅是单台客户端机器与单台ZK服务器之间的连接数限制,不是针对指定客户端IP,也不是ZK集群的连接数限制,也不是单台ZK对所有客户端的连接数限制。
阅读(3425) | 评论(0) | 转发(0) |