一、首先进入:/usr/local/bin 文件夹下,编写start-cluster.sh脚本
vim start-cluster.sh (需要root权限) 下面的各个节点的信息根据自身情况进行修改
#!/bin/bash user=`whoami` echo "=============== 开始启动所有节点服务 ===============" for((host=102; host<=104; host++)); do echo "--------------- hadoop$host Zookeeper...... ----------------" ssh [email protected]$host ‘/opt/module/zookeeper-3.4.10/bin/zkServer.sh start‘ done echo "================ 正在启动HDFS ===============" ssh [email protected] ‘/opt/module/hadoop-2.7.2/sbin/start-dfs.sh‘ echo "================ 正在启动YARN ===============" ssh [email protected] ‘/opt/module/hadoop-2.7.2/sbin/start-yarn.sh‘ echo "================ hadoop102正在启动JobHistoryServer ===============" ssh [email protected] ‘/opt/module/hadoop-2.7.2/sbin/mr-jobhistory-daemon.sh start historyserver‘
保存,退出。修改执行权限 chmod 777 start-cluster.sh (或者u+x)运行:
二、编写stop-cluster.sh
#!/bin/bash user=`whoami` echo "================ 开始停止所有节点服务 ===============" echo "================ hadoop102正在停止JobHistoryServer ===============" ssh [email protected] ‘/opt/module/hadoop-2.7.2/sbin/mr-jobhistory-daemon.sh stop historyserver‘ echo "================ 正在停止YARN ===============" ssh [email protected] ‘/opt/module/hadoop-2.7.2/sbin/stop-yarn.sh‘ echo "================ 正在停止HDFS ===============" ssh [email protected] ‘/opt/module/hadoop-2.7.2/sbin/stop-dfs.sh‘ echo "=============== 正在停止Zookeeper...... ===============" for((host=102; host<=104; host++)); do echo "--------------- hadoop$host Zookeeper...... ----------------" ssh [email protected]$host ‘/opt/module/zookeeper-3.4.10/bin/zkServer.sh stop‘ done
修改执行权限:chmod 777 stop-cluster.sh
三、编写show-jps.sh
#!/bin/bash for((host=102; host<=104; host++)); do echo "================ hadoop$host JPS =====================" ssh hadoop$host "jps" done
修改权限,运行
注意:如果仅仅是编辑以上的脚本的话启动时是看不到其它主机的信息的,因为他们找不到Java里的jps路径,因此我们必须要去创建软连接:
sudo ln -s /opt/module/jdk1.8.0_144/bin/jps /usr/local/bin/jps
显示为
再在每个节点的这个位置手动设置软链接!不设置软连接便会出现如下情况!
设置好每个节点的软链接
注:编写的脚本群起zookeeper服务,显示started但是jps不显示相应QuorumPeerMain进程解决方案:
在/opt/module/zookeeper-3.4.10/bin目录下的zkEnv.sh文件
在开头加上你的JAVA_HOME路径如下:
再分发到各个节点:xsync zkEnv.sh
一切就大功告成!如有哪儿不懂可以加我的群哦!875910806
原文地址:https://www.cnblogs.com/Mark-blog/p/11760415.html
时间: 2024-10-15 16:36:20