一、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:用于計(jì)算的時(shí)間單元。比如session超時(shí):N*tickTime。
- initLimit:用于集群的,允許節(jié)點(diǎn)連接并同步到master節(jié)點(diǎn)的初始化時(shí)間,以tickTime的倍數(shù)來(lái)表示。
-
syncLimit:用于集群,master主節(jié)點(diǎn)與 從節(jié)點(diǎn)之間發(fā)送消息,請(qǐng)求和 應(yīng)答的時(shí)間長(zhǎng)度。(心跳機(jī)制)
如果從節(jié)點(diǎn)超過(guò)一定時(shí)間就會(huì)被拋棄。 - dataDir:必須配置。zk的一些數(shù)據(jù),如日志啥的,都會(huì)存在此路徑下。
- datalogDir:日志目錄,如果不配置會(huì)和dataDir公用。
- clientPort:連接服務(wù)器的端口,默認(rèn)2181
現(xiàn)在的配置只是單機(jī)環(huán)境,后面集群環(huán)境再配置。
二、運(yùn)行zk
在安裝目錄的bin目錄下啟動(dòng)服務(wù)器:
./zkServer.sh start