大数据集群一些启动脚本-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
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一加六

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值