关于ZooKeeper群起失败

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

解决方案

  1. 修改/etc/profile文件:用来设置系统环境参数,比如$PATH. 这里面的环境变量是对系统内所有用户生效。使用bash命令,需要source /etc/profile一下

示例:
ssh $i "source /etc/profile && /opt/module/zookeeper-3.4.14/bin/zkServer.sh start"`

  1. 修改~/.bashrc文件:针对某一个特定的用户,环境变量的设置只对该用户自己有效。使用bash命令,只要以该用户身份运行命令行就会读取该文件。

把/etc/profile里面的环境变量追加到~/.bashrc目录
所有ZK节点上执行后即可使用脚本
cat /etc/profile >> ~/.bashrc

  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值