1.上传安装包,并解压
tar -zvxf zookeeper-3.4.6.tar.gz
2.修改配置文件
cp zoo_sample.cfg zoo.cfg
修改conf/zoo.cfg
#修改路径 dataDir=/root/zkdata #追加 server.1=hdp-01:2888:3888 server.2=hdp-02:2888:3888 server.3=hdp-03:2888:388
3.配置文件修改完,将安装包发送到hdp-02和hdp-03
scp -r zookeeper-3.4.6/ hdp-03:$PWD
scp -r zookeeper-3.4.6/ hdp-02:$PWD
4.创建/root/zkdata目录,目录下添加myid文件
hdp-01内容为1 echo 1 > /root/zkdata/myid
hdp-02内容为2 echo 2> /root/zkdata/myid
hdp-03内容为3 echo 3 > /root/zkdata/myid
5.启动集群
批量启动脚本
#!/bin/bash for host in hdp-01 hdp-02 hdp-03 do echo "${host} ${1}ing...." ssh $host "source /etc/profile;/root/apps/zookeeper-3.4.6/bin/zkServer.sh $1" done sleep 2 for host in hdp-01 hdp-02 hdp-03 do ssh $host "source /etc/profile;/root/apps/zookeeper-3.4.6/bin/zkServer.sh status" done
启动zookeeper命令行客户端
zkCli.sh -server hdp-01:2181