去官网下载zookeeper压缩包,并解压到本机,然后修改conf配置文件 如:(D:\\zookeeper3.4.13\\zookeeper-3.4.13\\conf),将zoo.cfg(原zoo_simple.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
dataLogDir=d:\\\\zookeeper3.4.13\\\\zookeeper-3.4.13\\\\log
# 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

然后双击启动D:\\zookeeper3.4.13\\zookeeper-3.4.13\\bin目录下的zkServer.cmd  或者在cmd命令里面cd到目录后执行

\"\"

当看到红色框中的内容后才是server端启动成功的信息

接着启动zkCli.cmd后,可以看到下图的命令窗口

\"\"

同样看到红色框中信息时方为启动成功。

接着就可以在client端各种玩耍了,比如create /zk hello    (创建一个分支)等。

此文仅供参考。

收藏 打印