一衩茸、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:用于集群的楞慈,允許節(jié)點連接并同步到master節(jié)點的初始化時間,以tickTime的倍數(shù)來表示啃擦。
-
syncLimit:用于集群囊蓝,master主節(jié)點與 從節(jié)點之間發(fā)送消息,請求和 應答的時間長度令蛉。(心跳機制)
如果從節(jié)點超過一定時間就會被拋棄聚霜。 - dataDir:必須配置。zk的一些數(shù)據(jù)珠叔,如日志啥的俯萎,都會存在此路徑下。
- datalogDir:日志目錄运杭,如果不配置會和dataDir公用夫啊。
- clientPort:連接服務器的端口,默認2181
現(xiàn)在的配置只是單機環(huán)境辆憔,后面集群環(huán)境再配置撇眯。
二、運行zk
在安裝目錄的bin目錄下啟動服務器:
./zkServer.sh start