linux 下 zookeeper 的安装配置与 windows 下基本相同,仅启动方式有细微差异,本文以 windows 下安装为例。linux 下安装 zookeeper 可参考 dubbo 的官方文档,地址为:http://dubbo.io/books/dubbo-admin-book/install/zookeeper.html
一、下载 zookeeper
下载地址:https://mirrors.cnnic.cn/apache/zookeeper/zookeeper-3.4.11/zookeeper-3.4.11.tar.gz
解压后得到文件夹 zookeeper-3.4.11
假设保存路径为:E:\zookeeper\zookeeper-3.4.11
二、配置
进入 conf 文件夹,新建文件 zoo.cfg,文件内容如下:
# The number of milliseconds of each tick 心跳检测时间间隔/ms
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=E:\zookeeper\data
#日志位置,此目录位置需要设置为自己服务器的真实路径
dataLogDir=E:\zookeeper\logs
# 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
#如果需要集群,可使用以下配置
#server.1=10.20.153.10:2555:3555
#server.2=10.20.153.11:2555:3555
如果使用了集群配置,需要在 data 目录下放置 myid
文件。
进入 E:\zookeeper\data 目录,新建文件 myid
,myid
指明自己的 id,对应上面 zoo.cfg
中 server.
后的数字,第一台的内容为 1,第二台的内容为 2。
即可编辑 ip:10.20.153.10 下的 zookeeper 下的 myid
文件内容为:
1
三、启动
进入 bin 文件夹下,双击启动 zkServer.cmd
另外开启一个命令行窗口,输入命令 jps
,可以看到 QuorumPeerMain 的进程,如下图:
此时启动客户端查看一下,在 bin 目录下打开命令行窗口,执行:
zkCli.cmd -server 127.0.0.1:2181
可以看到 zkServer.cmd 对应的命令行窗口中相关日志信息,如下图:
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于