Premise: Prepare three virtual machines
to start the cluster and modify the configuration (all three servers must be executed)
1. Download the Zookeeper installation package
Zookeeper download address:
https://zookeeper.apache.org/releases.html
https://archive.apache.org/dist/zookeeper
2. Upload the Zookeeper installation package
Upload the downloaded zookeeper installation package to the /root/export/software/ directory of the Linux system
3. Unzip the Zookeeper installation package
First, enter the installation directory, command
cd /root/export/software/
Secondly, unzip the installation package zookeeper-3.4.10.tar.gz to the /root/export/servers/ directory, command
tar -zxvf zookeeper-3.4.10.tar.gz -C /root/export/servers/
4. Modify the zookeeper configuration file
cd /export/servers/zookeeper/conf
cp zoo_sample.cfg zoo.cfg
vi zoo.cfg
#修改数据存放地址
dataDir=/root/export/data/zookeeper/zkdata
#添加节点配置
server.1 =hadoop01:2888:3888
server.2 =hadoop02:2888:3888
server.3 =hadoop03:2888:3888
5. Set the server number
mkdir -p /root/export/data/zookeeper/zkdata
cd /root/export/data/zookeeper/zkdata
echo 1 > myid
#第二台服务器 echo 2 > myid
#第三台服务器 echo 3 > myid
6. Set environment variables
vim /etc/profile
export ZK_HOME=/root/export/servers/zookeeper-3.4.10
export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$ZK_HOME/bin
source /etc/profile
7. Server startup/shutdown/view status
#启动命令
zkServer.sh start
#查看角色
zkServer.sh status
#关闭命令
zkServer.sh stop