hadoop用脚本启动

xiaoxiao2021-02-28  79

hadoop中需要启动的配置太多了,今天写了个脚本,实现了一键 启动hadoop,脚本写法如下图

这个脚本的前提是,服务器之间配置了ssh无秘钥登录!!!!!

运行脚本时,服务器提示我输入密码,但是我的机器已经配置了无秘钥登录,最后在启

zookeeper时提示启动成功,但是没有进程:如下

原因:

首先需要知道 交互式shell和非交互式shell、登录shell和非登录shell是有区别的 在登录shell里,环境信息需要读取/etc/profile和~ /.bash_profile, ~/.bash_login, and ~/.profile按顺序最先的一个,并执行其中的命令。除非被 --noprofile选项禁止了; 在非登录shell里,环境信息只读取 /etc/bash.bashrc和~/.bashrc 手工执行是属于登陆shell,脚本执行数据非登陆shell,而我的linux环境配置中只对/etc/profile进行了jdk1.7等环境的配置,所以脚本执行/usr/local/zookeeper/bin/zkServer.sh start 启动zookeeper失败了     解决方法(下面3个方法任选1): 1、脚本代码中添加“source /etc/profile;” 改为:ssh crxy$i "source /etc/profile;/usr/local/zookeeper/bin/zkServer.sh start"  2、把profile的配置信息echo到.bashrc中  echo 'source /etc/profile' >> ~/.bashrc 3、在/zookeeper/bin/zkEnv.sh的中开始位置添加 export JAVA_HOME=/usr/local/jdk1.7.0_45(就像hadoop中对hadoop-env.sh的配置一样)  解决了这个问题,就以方便的通过脚本实现hadoop集群的启动与关闭了,避免了繁琐的手工操作^-^

转载请注明原文地址: https://www.6miu.com/read-52002.html

最新回复(0)