(六)zk配置文件介绍及运行zk

一、zk配置文件 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=/Users/huluwa/data
# 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
  • tickTime:用于计算的时间单元。比如session超时:N*tickTime。
  • initLimit:用于集群的,允许节点连接并同步到master节点的初始化时间,以tickTime的倍数来表示。
  • syncLimit:用于集群,master主节点与 从节点之间发送消息,请求和 应答的时间长度。(心跳机制)
    如果从节点超过一定时间就会被抛弃。
  • dataDir:必须配置。zk的一些数据,如日志啥的,都会存在此路径下。
  • datalogDir:日志目录,如果不配置会和dataDir公用。
  • clientPort:连接服务器的端口,默认2181

现在的配置只是单机环境,后面集群环境再配置。

二、运行zk

在安装目录的bin目录下启动服务器:

./zkServer.sh start

你可能感兴趣的:((六)zk配置文件介绍及运行zk)