1.安装zk
解压缩
tar -zxvf zookeeper-3.4.8.tar.gz
mv zookeeper-3.4.8 zk
配置环境变量
vi ~/.bashrc
export ZOOKEEPER_HOME=/opt/zk
export PATH=$ZOOKEEPER_HOME/bin
source ~/.bashrc
2.配置zoo.cfg
cd /opt/zk/conf
mv zoo_sample.cfg zoo.cfg
vi zoo.cfg
修改:
dataDir=/opt/zk/data
新增:
server.0=hadoop001:2888:3888
server.1=hadoop002:2888:3888
server.2=hadoop003:2888:3888
3.设置节点标识
cd /opt/zk
mkdir data
cd data
vi myid
0
4.二三节点配置
复制zk目录到二三节点
cd /opt
scp -r zk hadoop002:/opt
scp -r zk hadoop003:/opt
复制环境变量到二三节点
scp ~/.bashrc hadoop002:~
scp ~/.bashrc hadoop003:~
修改二三节点myid
二三节点myid分别改为1、2
5.启动
分别在三台机器上执行:zkServer.sh start
检查ZooKeeper状态:zkServer.sh status
其中一个为leader其他为follower
使用jsp验证
Hadoop001:QuorumPeerMain
Hadoop002:QuorumPeerMain
Hadoop003:QuorumPeerMain
来源:oschina
链接:https://my.oschina.net/u/2812496/blog/717849