当前位置:   article > 正文

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

domain home is not set.

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

目录

前言

问题

解决办法:

测试:

启动成功:

查看状态

关闭服务:


前言

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

  1. #!/bin/bash
  2. case $1 in
  3. "start") {
  4. for i in hadoop100 hadoop101 hadoop102
  5. do
  6. echo ----------------zookeeper $i 启动---------------------
  7. ssh $i "/opt/module/zookeeper-3.5.7/bin/zkServer.sh start"
  8. done
  9. }
  10. ;;
  11. "stop") {
  12. for i in hadoop100 hadoop101 hadoop102
  13. do
  14. echo ----------------zookeeper$i 关闭---------------------
  15. ssh $i "/opt/module/zookeeper-3.5.7/bin/zkServer.sh stop"
  16. done
  17. }
  18. ;;
  19. "status") {
  20. for i in hadoop100 hadoop101 hadoop102
  21. do
  22. echo ----------------zookeeper $i 状态---------------------
  23. ssh $i "/opt/module/zookeeper-3.5.7/bin/zkServer.sh status"
  24. done
  25. }
  26. ;;
  27. esac

问题

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

  1. [root@hadoop100 bin]# zk.sh start
  2. ----------------zookeeper hadoop100 启动---------------------
  3. root@hadoop100's password:
  4. Error: JAVA_HOME is not set and java could not be found in PATH.
  5. ----------------zookeeper hadoop101 启动---------------------
  6. root@hadoop101's password:
  7. Error: JAVA_HOME is not set and java could not be found in PATH.
  8. ----------------zookeeper hadoop102 启动---------------------
  9. root@hadoop102's password:
  10. Error: JAVA_HOME is not set and java could not be found in PATH.

解决办法:

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

测试:

 启动成功:

  1. [root@hadoop100 bin]# zk.sh start
  2. ----------------zookeeper hadoop100 启动---------------------
  3. root@hadoop100's password:
  4. ZooKeeper JMX enabled by default
  5. Using config: /opt/module/zookeeper-3.5.7/bin/../conf/zoo.cfg
  6. Starting zookeeper ... STARTED
  7. ----------------zookeeper hadoop101 启动---------------------
  8. root@hadoop101's password:
  9. ZooKeeper JMX enabled by default
  10. Using config: /opt/module/zookeeper-3.5.7/bin/../conf/zoo.cfg
  11. Starting zookeeper ... STARTED
  12. ----------------zookeeper hadoop102 启动---------------------
  13. root@hadoop102's password:
  14. ZooKeeper JMX enabled by default
  15. Using config: /opt/module/zookeeper-3.5.7/bin/../conf/zoo.cfg
  16. Starting zookeeper ... STARTED

查看状态

  1. [root@hadoop100 bin]# zk.sh status
  2. ----------------zookeeper hadoop100 状态---------------------
  3. root@hadoop100's password:
  4. ZooKeeper JMX enabled by default
  5. Using config: /opt/module/zookeeper-3.5.7/bin/../conf/zoo.cfg
  6. Client port found: 2181. Client address: localhost.
  7. Mode: follower
  8. ----------------zookeeper hadoop101 状态---------------------
  9. root@hadoop101's password:
  10. ZooKeeper JMX enabled by default
  11. Using config: /opt/module/zookeeper-3.5.7/bin/../conf/zoo.cfg
  12. Client port found: 2181. Client address: localhost.
  13. Mode: leader
  14. ----------------zookeeper hadoop102 状态---------------------
  15. root@hadoop102's password:
  16. ZooKeeper JMX enabled by default
  17. Using config: /opt/module/zookeeper-3.5.7/bin/../conf/zoo.cfg
  18. Client port found: 2181. Client address: localhost.
  19. Mode: follower

关闭服务:

  1. [root@hadoop100 bin]# zk.sh stop
  2. ----------------zookeeperhadoop100 关闭---------------------
  3. root@hadoop100's password:
  4. ZooKeeper JMX enabled by default
  5. Using config: /opt/module/zookeeper-3.5.7/bin/../conf/zoo.cfg
  6. Stopping zookeeper ... STOPPED
  7. ----------------zookeeperhadoop101 关闭---------------------
  8. root@hadoop101's password:
  9. ZooKeeper JMX enabled by default
  10. Using config: /opt/module/zookeeper-3.5.7/bin/../conf/zoo.cfg
  11. Stopping zookeeper ... STOPPED
  12. ----------------zookeeperhadoop102 关闭---------------------
  13. root@hadoop102's password:
  14. ZooKeeper JMX enabled by default
  15. Using config: /opt/module/zookeeper-3.5.7/bin/../conf/zoo.cfg
  16. Stopping zookeeper ... STOPPED

问题解决完毕!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/574546
推荐阅读
相关标签
  

闽ICP备14008679号