1. zoo.cfg配置

完整的zoo.cfg

# 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.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/tmp/zookeeper
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# 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

## Metrics Providers
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true

2.tickTime

tickTime:用于计算的时间单元,单位为毫秒。比如session超时:N* tickTime。

3. initLimit

initLimit :用于集群,允许从节点连接并同步到master节点的初始化连接时间,以tickTime的倍数来表示。

4. syncLimit

syncLimit :用于集群,master主节点与从节点之间发送消息,请求和应答时间长度,超过一定的时间从节点就会被抛弃。(心跳机制)

5. dataDir

dataDir:必须配置,比如用来存储事务文件的数据等。

6. dataLogDir

dataLogDir:日志目录,如果不配置会和dataDir公用

  • 注意:linux常常这样存放
    在这里插入图片描述

7. clientPort

clientPort :连接服务器的端口,默认2181

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐