Zookeeper集群脚本启动问题

问题:

运行:./start.sh看见启动成功了,有输出。但是输入jps查看的时候,会发现没有QuorumPeerMain 进程。说明没有启动成功
分析原因

首先知道交互式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.8等环境的配
置,所以脚本执行/opt/module/zookeeper-3.4.10/bin/zkServer.sh start 启动zookeeper失败了

解决方法

把profile的配置信息echo到.bashrc中  cat  /etc/profile  >> ~/.bashrc
在/zookeeper/bin/zkEnv.sh的中开始位置添加export JAVA_HOME=/opt/module/jdk1.8.0_191

Zookeeper集群脚本启动问题_第1张图片

 附带脚本

#!/bin/bash
echo "================     正在启动Zookeeper               ==========="
for i in hadoop108 hadoop109 hadoop110 hadoop111
do       
        echo ------------$i-----------
        ssh $i 'source /etc/profile ;cd /opt/module/zookeeper-3.4.10/bin/ ; ./zkServer.sh start'       
done

--------------------------------------------------------------------------------------

#!/bin/bash
echo "================     正在关闭Zookeeper               ==========="
for i in hadoop108 hadoop109 hadoop110 hadoop111
do
    echo ---------$i-----------
     ssh $i 'source /etc/profile ;cd /opt/module/zookeeper-3.4.10/bin/ ; ./zkServer.sh stop'
done


--------------------------------------------------------------------------------------

#!/bin/bash
echo "================     开始启动所有节点服务            ==========="
echo "================     正在启动Zookeeper               ==========="
for i in hadoop108 hadoop109 hadoop110 hadoop111
do
     ssh $i 'source /etc/profile ;cd /opt/module/zookeeper-3.4.10/bin/ ; ./zkServer.sh start'
    echo $i 执行完
done
echo "================     正在启动HDFS                    ==========="
ssh hadoop108 '/opt/module/hadoop-2.7.2/sbin/start-dfs.sh'
echo "================     正在启动YARN                    ==========="
ssh hadoop109 '/opt/module/hadoop-2.7.2/sbin/start-yarn.sh'
echo "================     正在开启JobHistoryServer        ==========="
ssh hadoop108 '/opt/module/hadoop-2.7.2/sbin/mr-jobhistory-daemon.sh start historyserver'

------------------------------------------------------------------------------------------------------------------------

#!/bin/bash
echo "================     开始关闭所有节点服务            ==========="
echo "================     正在关闭Zookeeper               ==========="
for i in hadoop108 hadoop109 hadoop110 hadoop111
do
     ssh $i 'source /etc/profile ;cd /opt/module/zookeeper-3.4.10/bin/ ; ./zkServer.sh stop'
    echo $i执行完
done

echo "================     正在关闭HDFS                    ==========="
ssh hadoop108 '/opt/module/hadoop-2.7.2/sbin/stop-dfs.sh'
echo "================     正在关闭YARN                    ==========="
ssh hadoop109 '/opt/module/hadoop-2.7.2/sbin/stop-yarn.sh'
echo "================     正在关闭JobHistoryServer        ==========="
ssh hadoop108 '/opt/module/hadoop-2.7.2/sbin/mr-jobhistory-daemon.sh stop historyserver'

 

 

-------------------------------------------------------------------------------------------------------------------

 

 

 

 

 

 

你可能感兴趣的:(Zookeeper集群脚本启动问题)