说明:以下操作,均在 macOS 系统下进行
1、下载 ZooKeeper
官网下载地址
![193660e3f653a0a85a3f34c53cd9cb65.png](https://i-blog.csdnimg.cn/blog_migrate/01bdb86eefa7b63d225326c82d294259.jpeg)
目前最新版本为 3.6.2,本文以 3.6.0 为例,点击 Apache ZooKeeper 3.6.0 (asc, sha512) 下载。
apache-zookeeper-[version].tar.gz Contains all the source files which can be built by running: mvn clean install To generate an aggregated apidocs for zookeeper-server and zookeeper-jute: mvn javadoc:aggregate (generated files will be at target/site/apidocs) apache-zookeeper-[version]-bin.tar.gz Contains all the jar files required to run ZooKeeper Full documentation can also be found in the docs folder
2、安装
无需安装,解压后进行配置即可。
- 解压
tar -zxvf apache-zookeeper-3.6.0.tar.gz
![7992e7a365fc17305104d1a683df2339.png](https://i-blog.csdnimg.cn/blog_migrate/3048039d9253e020b7e7f5291644edc7.jpeg)
- 配置
进入 conf 目录,复制 zoo_sample.cfg 为 zoo.cfg
![5c82c09e562232328eb2b7db3a94b062.png](https://i-blog.csdnimg.cn/blog_migrate/6e180b396ee201c898e7272fc53f88a1.jpeg)
cp zoo_sample.cfg zoo.cfg
简单看一下配置:
tickTime=2000initLimit=10syncLimit=5dataDir=/tmp/zookeeperclientPort=2181
配置暂时,全部使用默认,不做任何调整。
dataDir:事务日志和快照日志的存储位置。
启动
cd apache-zookeeper-3.6.0-bin# 方式一bin/zkServer.sh start# 方式二bin/zkServer.sh start conf/zoo.cfg
![762746ec2132c9df62899bc4fd431efb.png](https://i-blog.csdnimg.cn/blog_migrate/cf292c269f1852e62079e4b71906e187.jpeg)
停止
bin/zkServer.sh stop
验证
jcm
![2edd996ec522e5193fd34f412c3793da.png](https://i-blog.csdnimg.cn/blog_migrate/ea693a8a8d264b06e2f9a8a086346ca8.jpeg)
使用客服端连接服务端进行验证
bin/zkCli.sh -server 127.0.0.1:2181
![a341ebee509e6005b364490b81d6735d.png](https://i-blog.csdnimg.cn/blog_migrate/993d1f622a983fc364b93ed7c87d6a0c.jpeg)
总结
主要介绍了,单机版 ZooKeeper 的安装及验证,内容比较简单。ZooKeeper 的安装,很简单,下载后,简单复制一份配置文件即可使用。
参考文档
Difference between Binary release and source release?
Welcome to Apache ZooKeeper™
14.1 zookeeper日志查看