ZooKeeper 群起失败
- 故障描述:
使用群起脚本启动后,通过jps查看无启动。
zk.sh
#! /bin/bash
case $1 in
"start"){
for i in hadoop01 hadoop02 hadoop03
do
ssh $i "/opt/module/zookeeper-3.4.14/bin/zkServer.sh start"
done
};;
"stop"){
for i in hadoop01 hadoop02 hadoop03
do
ssh $i "/opt/module/zookeeper-3.4.14/bin/zkServer.sh stop"
done
};;
"status"){
for i in hadoop01 hadoop02 hadoop03
do
ssh $i "/opt/module/zookeeper-3.4.14/bin/zkServer.sh status"
done
};;
esac
- Zookeeper集群启动脚本
zk.sh start
- Zookeeper集群停止脚本
zk.sh stop
- Zookeeper集群状态脚本
zk.sh status
解决方案
- 修改/etc/profile文件:用来设置系统环境参数,比如$PATH. 这里面的环境变量是
对系统内所有用户生效
。使用bash命令,需要source /etc/profile一下
。
示例:
ssh $i "source /etc/profile &&
/opt/module/zookeeper-3.4.14/bin/zkServer.sh start"`
- 修改~/.bashrc文件:
针对某一个特定的用户
,环境变量的设置只对该用户自己有效。使用bash命令,只要以该用户身份运行命令行就会读取该文件。
把/etc/profile里面的环境变量追加到~/.bashrc目录
在所有ZK节点上执行
后即可使用脚本
cat /etc/profile >> ~/.bashrc