大数据集群一些启动脚本-shell---会更新
Posted 一加六
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了大数据集群一些启动脚本-shell---会更新相关的知识,希望对你有一定的参考价值。
批量启动zookeeper
#!/bin/bash
# hostserver array
iparray=(ha001 ha002 ha003)
#zookeeper install path
#path="/export/servers/zookeeper-3.6.2/bin"
# get parameters start | status | stop
case $@ in
start)
#---------start-zookeeper-----------
for ip in $iparray[*]
do
#echo "ssh to $ip"
ssh $ip "source /etc/profile;zkServer.sh start"
sleep 2s
done
exit
;;
stop)
#---------stop-zookeeper------------
for ip in $iparray[*]
do
#echo "ssh to $ip"
ssh $ip "source /etc/profile;zkServer.sh stop"
sleep 2s
done
exit
;;
status)
#---------status-zookeeper------------
for ip in $iparray[*]
do
#echo "ssh to $ip"
ssh $ip "source /etc/profile;zkServer.sh status"
sleep 2s
done
exit
;;
*)
echo "nothing to do!"
esac
jps查看所有节点服务启动情况
#/bin/bash
# hostserver array
iparray=(ha001 ha002 ha003)
#zookeeper install path
#path="/export/servers/zookeeper-3.6.2/bin"
for ip in $iparray[*]
do
echo "-------------$ip-jps-------------"
ssh $ip "source /etc/profile;jps"
sleep 2s
done
exit
防火墙端口管理
#/bin/bash
#hostserver array
iparray=(ha001 ha002 ha003)
case $1 in
#---------------------- add port-------------------------
add)
#convenient iparray
for ip in $iparray[*]
do
echo "###############open ports on $ip###############"
for port in $*
do
if [ "$port" = "add" ]
then
continue
else
echo "########opening $port########"
ssh $ip "firewall-cmd --add-port=$port/tcp --permanent"
sleep 2s
ssh $ip "firewall-cmd --reload"
fi
done
ssh $ip "firewall-cmd --zone=public --list-port"
done
exit
;;
#---------------------- list port-------------------------
list)
#convenient iparray
for ip in $iparray[*]
do
echo "###############list ports on $ip###############"
ssh $ip "firewall-cmd --zone=public --list-port"
done
exit
;;
#---------------------- state of firewalld------------------
state)
#convenient iparray
for ip in $iparray[*]
do
echo "###############firewalld state on $ip###############"
ssh $ip "firewall-cmd --state"
done
exit
;;
#---------------------- start firewalld--------------------
start)
#convenient iparray
for ip in $iparray[*]
do
echo "###############start firewalld on $ip###############"
ssh $ip "systemctl start firewalld"
done
exit
;;
#---------------------- stop firewalld---------------------
stop)
#convenient iparray
for ip in $iparray[*]
do
echo "###############stop firewalld on $ip###############"
ssh $ip "systemctl stop firewalld"
done
exit
;;
#---------------------- remove ports----------------------
remove)
#convenient iparray
for ip in $iparray[*]
do
port=$2
echo "###############remove $port on $ip###############"
ssh $ip "firewall-cmd --zone=public --remove-port=$port/tcp --permanent"
ssh $ip "firewall-cmd --reload"
done
exit
;;
*)
echo "###############parameter error###############"
esac
以上是关于大数据集群一些启动脚本-shell---会更新的主要内容,如果未能解决你的问题,请参考以下文章
2021年大数据Kafka:❤️Kafka的集群搭建以及shell启动命令脚本编写❤️