zookeeper集群安装-3.x

作者时间
刘权2017-08-28

基础环境准备:

编号说明
1卸载openJDK,安装SunJDK,并配置环境变量
2关闭防火墙
3准备zookeeper安装包(http://mirrors.hust.edu.cn/apache/zookeeper/)
  1. 上传压缩包
  2. 解压:tar -zxvf zookeeper-3.4.5.tar.gz
  3. 配置ZOOKEEPER_HOME
export ZOOKEEPER_HOME=/home/hadoop/zookeeper-3.4.5
export PATH=$PATH:$ZOOKEEPER_HOME/bin
  1. 重新加载配置:source /etc/profile
  2. 注意:3台zookeeper都需要修改
  3. 修改zookeeper配置文件
cd zookeeper-3.4.5/conf
cp zoo_sample.cfg zoo.cfg
vi zoo.cfg
添加一下内容:
dataDir=/home/hadoop/zookeeper-3.4.5/data
dataLogDir=/home/hadoop/zookeeper-3.4.5/log
server.1=slave1:2888:3888
server.2=slave2:2888:3888
server.3=slave3:2888:3888
  1. 创建目录:
mkdir -m 755 /home/hadoop/zookeeper-3.4.5/data
mkdir -m 755 /home/hadoop/zookeeper-3.4.5/log
  1. 写入myid :echo "1" > /home/hadoop/zookeeper-3.4.5/data/myid
  2. 将zookeeper发送到集群其他机器:
scp -r /home/hadoop/zookeeper-3.4.5 hadoop@slave2:/home/hadoop/
scp -r /home/hadoop/zookeeper-3.4.5 hadoop@slave3:/home/hadoop/
  1. 修改其他机器的配置文件
到slave2上:修改myid为:2 (echo "2" > /home/hadoop/zookeeper-3.4.5/data/myid)
到slave3上:修改myid为:3 (echo "3" > /home/hadoop/zookeeper-3.4.5/data/myid)
  1. 启动(每台机器):zkServer.sh start
  2. 查看集群状态
1、jps(查看进程)
2、zkServer.sh status(查看集群状态,主从信息)
    原文作者:雨中星辰0
    原文地址: https://www.jianshu.com/p/18a90a38aaae
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞