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
- 群起脚本需要配置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,赋予脚本执行权限执行测试
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)