确保系统已经安装JDK,如果未安装,首先需要进行安装JDK,参考Linux(CentOS 7)安装JDK踩坑记录
在ZooKeeper官网下载安装包
现在最新稳定版本为3.6.1,下载地址为:https://www.apache.org/dyn/closer.lua/zookeeper/zookeeper-3.6.1/apache-zookeeper-3.6.1-bin.tar.gz
- 安装ZooKeeper
将下载的压缩文件传输到CentOS中的/usr/local/zookeeper目录下面,进行解压tar zxvf apache-zookeeper-3.6.1-bin.tar.gz
- 编辑配置文件
进入conf目录,将zoo_sample.cfg这个文件复制为zoo.cfg:cp zoo_sample.cfg zoo.cfg
修改zoo.cfg,配置dataDir和DataLogDir
dataDir=/usr/local/zookeeper/apache-zookeeper-3.6.1-bin/data
dadaLogDir=/usr/local/zookeeper/apache-zookeeper-3.6.1-bin/log
※为什么要做这样的修改呢?
看zoo_sample.cfg中的注释,do not use /tmp for storage, /tmp here is just
当然,配置完目录之后别忘了在创建data和log目录
- 配置环境变量
打开配置文件:vim /etc/profile
export ZOOKEEPER_INSTALL=/usr/local/zookeeper/apache-zookeeper-3.6.1-bin/
export PATH=$PATH:$ZOOKEEPER_INSTALL/bin
使其生效:source /etc/profile
-
启动ZooKeeper服务端
命令:sh zkServer.sh start
-
启动ZooKeeper客户端进行连接
命令:sh zkCli.sh