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