基础环境
JDK1.8
Centos7
下载
下载地址:https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/
wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.8.0/apache-zookeeper-3.8.0-bin.tar.gz
安装
解压
tar -zxvf apache-zookeeper-3.8.0-bin.tar.gz
修改配置文件
- 进去Zookeeper目录
[root apache-zookeeper-3.8.0-bin]# pwd
/opt/apache-zookeeper-3.8.0-bin
- 复制配置文件
[root apache-zookeeper-3.8.0-bin]# cd conf/
[root conf]# ls
configuration.xsl logback.xml zoo_sample.cfg
[root conf]# cp zoo_sample.cfg zoo.cfg
[root conf]# ls
configuration.xsl logback.xml zoo.cfg zoo_sample.cfg
- 编辑
zoo.cfg
# 修改数据目录
dataDir=/opt/apache-zookeeper-3.8.0-bin/data
dataLogDir=/opt/apache-zookeeper-3.8.0-bin/log
# 添加集群ip信息
server.1=172.16.24.174:2888:3888
server.2=172.16.24.175:2888:3888
server.3=172.16.24.176:2888:3888
- 创建目录
[root conf]# mkdir /opt/apache-zookeeper-3.8.0-bin/data
[root conf]# mkdir /opt/apache-zookeeper-3.8.0-bin/log
- Zookeeper目录同步到需要安装Zookeeper的机器上
- 在
dataDir
目录下创建myid
文件
文件内容为zoo.cfg
中配置对应ip
的 数据
如:172.16.24.174 服务器myid
内容为1
touch /opt/apache-zookeeper-3.8.0-bin/data/myid
- 配置环境变量
export ZOOKEEPER_INSTALL=/opt/apache-zookeeper-3.8.0-bin
export PATH=$PATH:$ZOOKEEPER_INSTALL/bin
export ZOOKEEPER_INSTALL=/opt/apache-zookeeper-3.8.0-bin
export PATH=$PATH:$ZOOKEEPER_INSTALL/bin
- 启动服务
zkServer.sh start