Zookeeper3.6.3集群搭建教程(附群起脚本)

Zookeeper3.6.3集群搭建教程(附群起脚本),第1张

Zookeeper3.6.3集群搭建教程(附群起脚本)

目录

1. 环境准备2. 部署安装3. 群起脚本

1. 环境准备

官网下载地址:https://www.apache.org/dyn/closer.cgi/zookeeper/三台CentOS7虚拟机自备JDK 2. 部署安装

    上传安装包到虚拟机
    tar -zxvf apache-zookeeper-3.6.3-bin.tar.gz -C /data/解压mv apache-zookeeper-3.6.3-bin zookeeper-3.6.3/修改安装包名称进入安装目录,创建zkdata目录,创建myid
cd /data/zookeeper-3.6.3/
mkdir zkdata
cd zkdata/
echo 1 > myid
    修改配置文件,添加对应配置信息
cd /data/zookeeper-3.6.3/conf/
cp zoo_sample.cfg zoo.cfg
vim zoo.cfg
# 修改以下内容:
dataDir=/data/zookeeper-3.6.3/zkdata
# 添加以下内容:
server.1=192.168.68.121:2888:3888
server.2=192.168.68.122:2888:3888
server.3=192.168.68.123:2888:3888
    分发安装包到另外两台机器
scp -r zookeeper-3.6.3 hadoop@192.168.68.122:/$PWD
scp -r zookeeper-3.6.3 hadoop@192.168.68.123:/$PWD
    修改另外两台机器的myid文件,192.168.68.122修改为2,192.168.68.123修改为3
vim /data/zookeeper-3.6.3/zkdata/myid
    三台依次sudo vim /etc/profile添加环境变量,然后source /etc/profile加载环境变量
#ZOOKEEPER_HOME
export ZOOKEEPER_HOME=/data/zookeeper-3.6.3
export PATH=$PATH:$ZOOKEEPER_HOME/bin
    依次启动三台zookeeper
cd /data/zookeeper-3.6.3/bin/
zkServer.sh start
    查看集群状态zkServer.sh status
3. 群起脚本
    群起脚本需要配置SSH免密登录,我的这篇博客里有免密登录的教程:Hadoop3.x在centos上的完全分布式部署,就不细说了vim start_cluster.sh添加以下内容
#!/bin/bash

if [ $# -lt 1 ]
then
    echo "No Args Input..."
    exit ;
fi

case  in
"start")
        echo " =================== 启动 zookeeper集群 ==================="

        echo " --------------- 启动 hadoop121 ---------------"
        ssh 192.168.68.121 "/data/zookeeper-3.6.3/bin/zkServer.sh start"
        echo " --------------- 启动 hadoop122 ---------------"
        ssh 192.168.68.122 "/data/zookeeper-3.6.3/bin/zkServer.sh start"
        echo " --------------- 启动 hadoop123 ---------------"
        ssh 192.168.68.123 "/data/zookeeper-3.6.3/bin/zkServer.sh start"
;;
"stop")
        echo " =================== 关闭 zookeeper集群 ==================="

        echo " --------------- 关闭 hadoop121 ---------------"
        ssh 192.168.68.121 "/data/zookeeper-3.6.3/bin/zkServer.sh stop"
        echo " --------------- 关闭 hadoop122 ---------------"
        ssh 192.168.68.122 "/data/zookeeper-3.6.3/bin/zkServer.sh stop"
        echo " --------------- 关闭 hadoop123 ---------------"
        ssh 192.168.68.123 "/data/zookeeper-3.6.3/bin/zkServer.sh stop"
;;
"status")
		echo " =================== 查看 zookeeper集群状态 ==================="

		echo " --------------- hadoop121状态 ---------------"
        ssh 192.168.68.121 "/data/zookeeper-3.6.3/bin/zkServer.sh status"
        echo " --------------- hadoop122状态 ---------------"
        ssh 192.168.68.122 "/data/zookeeper-3.6.3/bin/zkServer.sh status"
        echo " --------------- hadoop123状态 ---------------"
        ssh 192.168.68.123 "/data/zookeeper-3.6.3/bin/zkServer.sh status"
;;
*)
    echo "Input Args Error..."
;;
esac
    chmod +x start_cluster.sh,赋予脚本执行权限执行测试


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5703888.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存