zookeeper集群搭建
注:zookeeper集群节点数必须为奇数,满足leader选举算法(当选leader的节点所需支持节点数过半的原则),且>=3
1、下载zookeeper安装包
curl -O https://archive.apache.org/dist/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz
2、远程传输到hadoop2、hadoop3节点上
scp -r zookeeper-3.4.10.tar.gz root@hadoop2:`pwd`
scp -r zookeeper-3.4.10.tar.gz root@hadoop3:`pwd`
3、解压安装包
tar -zxvf zookeeper-3.4.10.tar.gz
4、拷贝"xxx安装目录/zookeeper-3.4.10/conf"目录下的zoo_sample.cfg文件,重命名为zoo.cfg,并进行编辑,添加如下设置
cp zoo_sample.cfg zoo.cfg
vim zoo.cfg
dataDir=/data/zookeeper
server.1=hadoop1:2888:3888
server.2=hadoop2:2888:3888
server.3=hadoop3:2888:3888
5、在配置的文件目录/data/zookeeper目录下,新建myid文件并编辑(用于标识在zookeeper集群的编号)
6、启动/停止zookeeper
cd /usr/local/softwareinstall/zookeeper-3.4.10
bin/zkServer.sh start //启动zookeeper
bin/zkServer.sh stop //停止zookeeper
bin/zkServer.sh status //查看zookeeper状态
7、开机自启动设置
参考zookeeper && kafka开机自启动设置博文