赞
踩
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路径即可:
- [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
问题解决完毕!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。