$ cd /usr/local/
$ tar -zxvf zookeeper-3.4.5.tar.gz
$ mv zookeeper-3.4.5 zk
$ cd
$ vi .bashrc
export ZOOKEEPER_HOME=/usr/local/zk export PATH=$PATH:$ZOOKEEPER_HOME/bin
$ source .bashrc
$ cd /usr/local/zk/conf/
$ mv zoo_sample.cfg zoo.cfg
$ vi zoo.cfg
# 修改 dataDir=/usr/local/zk/data/ # 新增 server.0=spark1:2888:3888 server.1=spark2:2888:3888 server.2=spark3:2888:3888
$ cd /usr/local/zk/
$ mkdir data
$ cd data/
$ vi myid
0
$ cd /usr/local/
$ scp -r zk [email protected]:/usr/local/
$ scp -r zk [email protected]:/usr/local/
$ scp ~/.bashrc [email protected]:~/
$ scp ~/.bashrc [email protected]:~/
# 分别在spark2和spark3上执行 source ~/.bashrc
# 分别修改spark2和spark3的 vi /usr/local/zk/data/myid 为1和2
# 启动zk集群
三台机器分别执行$ zkServer.sh start
三台机器分别执行(检查启动情况)$ zkServer.sh status
# 进入zookeeper命令行
$ zkCli.sh
> quit