Error: JAVA_HOME is not set and java could not be found in PATH.

导读:本篇文章讲解 Error: JAVA_HOME is not set and java could not be found in PATH.,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com

CSDN话题挑战赛第2期
参赛话题:学习笔记

目录

前言

问题

解决办法:

测试:

启动成功:

查看状态

关闭服务:


前言

因为zookeeper服务器多,每一次启动、关闭和查看状态都很麻烦,所以通过shell脚本启动zookeeper集群,写完的脚本如下:

#!/bin/bash


case $1 in
"start") {
        for i in hadoop100 hadoop101 hadoop102
        do
                echo ----------------zookeeper $i 启动---------------------
                ssh $i "/opt/module/zookeeper-3.5.7/bin/zkServer.sh start"
        done
}
;;
"stop") {
        for i in hadoop100 hadoop101 hadoop102
        do
                echo ----------------zookeeper$i 关闭---------------------

                ssh $i "/opt/module/zookeeper-3.5.7/bin/zkServer.sh stop"
        done
}
;;
"status") {
        for i in hadoop100 hadoop101 hadoop102
        do
                echo ----------------zookeeper $i 状态---------------------
                ssh $i "/opt/module/zookeeper-3.5.7/bin/zkServer.sh status"
        done
}
;;
esac

问题

通过脚本开启三台服务器却报了以下错误:

[root@hadoop100 bin]# zk.sh start
----------------zookeeper hadoop100 启动---------------------
root@hadoop100's password: 
Error: JAVA_HOME is not set and java could not be found in PATH.
----------------zookeeper hadoop101 启动---------------------
root@hadoop101's password: 
Error: JAVA_HOME is not set and java could not be found in PATH.
----------------zookeeper hadoop102 启动---------------------
root@hadoop102's password: 
Error: JAVA_HOME is not set and java could not be found in PATH.

解决办法:

在zookeeper安装包下的bin目录中添加上JAVA_HOME,配置上自己对应的jdk路径即可:

Error: JAVA_HOME is not set and java could not be found in PATH.

测试:

 启动成功:

[root@hadoop100 bin]# zk.sh start
----------------zookeeper hadoop100 启动---------------------
root@hadoop100's password: 
ZooKeeper JMX enabled by default
Using config: /opt/module/zookeeper-3.5.7/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
----------------zookeeper hadoop101 启动---------------------
root@hadoop101's password: 
ZooKeeper JMX enabled by default
Using config: /opt/module/zookeeper-3.5.7/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
----------------zookeeper hadoop102 启动---------------------
root@hadoop102's password: 
ZooKeeper JMX enabled by default
Using config: /opt/module/zookeeper-3.5.7/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

查看状态

[root@hadoop100 bin]# zk.sh status
----------------zookeeper hadoop100 状态---------------------
root@hadoop100's password: 
ZooKeeper JMX enabled by default
Using config: /opt/module/zookeeper-3.5.7/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Mode: follower
----------------zookeeper hadoop101 状态---------------------
root@hadoop101's password: 
ZooKeeper JMX enabled by default
Using config: /opt/module/zookeeper-3.5.7/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Mode: leader
----------------zookeeper hadoop102 状态---------------------
root@hadoop102's password: 
ZooKeeper JMX enabled by default
Using config: /opt/module/zookeeper-3.5.7/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Mode: follower

关闭服务:

[root@hadoop100 bin]# zk.sh stop
----------------zookeeperhadoop100 关闭---------------------
root@hadoop100's password: 
ZooKeeper JMX enabled by default
Using config: /opt/module/zookeeper-3.5.7/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
----------------zookeeperhadoop101 关闭---------------------
root@hadoop101's password: 
ZooKeeper JMX enabled by default
Using config: /opt/module/zookeeper-3.5.7/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
----------------zookeeperhadoop102 关闭---------------------
root@hadoop102's password: 
ZooKeeper JMX enabled by default
Using config: /opt/module/zookeeper-3.5.7/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED

问题解决完毕!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/118496.html

(0)
seven_的头像seven_bm

相关推荐

发表回复

登录后才能评论
极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!