集群运维脚本

集群运维的几个脚本:

1 xcall.sh

#! /bin/bash

for i in nfcls8 nfcls7 nfcls6 nfcls5 nfcls4 nfcls3 nfcls2
        do
            echo --------- $i ----------
                    ssh $i "source /etc/profile;$*"
        done

2 xsync.sh

#!/bin/bash
#1 获取输入参数个数,如果没有参数,直接退出
pcount=$#
if((pcount==0)); then
echo no args;
exit;
fi

#2 获取文件名称
p1=$1
fname=`basename $p1`
echo fname=$fname

#3 获取上级目录到绝对路径
pdir=`cd -P $(dirname $p1); pwd`
echo pdir=$pdir

#4 获取当前用户名称
user=`whoami`

#5 循环
for host in nfcls7 nfcls6 nfcls5 nfcls4 nfcls3 nfcls2
#for host in nfcls7 nfcls6 nfcls3 nfcls2
        do
            echo ------------------- $host --------------
            source /etc/profile;  rsync -rvl $pdir/$fname $user@$host:$pdir
        done

3 presto-all.sh

#! /bin/bash

case $1 in
"start"){
            for i in nfcls3 nfcls4 nfcls7 nfcls8
            do
            echo "========== $i =========="
            ssh $i 'source /etc/profile&&/work/module/presto/presto-server/bin/launcher start --server-log-file=/logs/server.log'
            echo $?
            done
};;

"stop"){
            for i in nfcls3 nfcls4 nfcls7 nfcls8
            do
            echo "========== $i =========="
            ssh $i 'source /etc/profile&&/work/module/presto/presto-server/bin/launcher stop --server-log-file=/logs/server.log'
            echo $?
            done
};;
esac

4 presto.sh

/work/module/presto/presto-cli --server nfcls8:8082 --catalog hive  --schema nfyy_cdm_20210909_1_union_std

presto监控页面:

        nfcls8:8082

5 kafka-all.sh

#! /bin/bash

case $1 in
"start"){
            #for i in `cat /work/hadoop-2.7.7/etc/hadoop/slaves`
            for i in nfcls2 nfcls3 nfcls4 nfcls5 nfcls6 nfcls7 nfcls8
            do
            echo "========== $i =========="
            ssh $i 'source /etc/profile&&/work/module/kafka/bin/kafka-server-start.sh -daemon /work/module/kafka/config/server.properties'
            echo $?
            done
};;

"stop"){
            for i in nfcls2 nfcls3 nfcls4 nfcls5 nfcls6 nfcls7 nfcls8
	    do
            echo "========== $i =========="
            ssh $i 'source /etc/profile&&/work/module/kafka/bin/kafka-server-stop.sh stop'
            echo $?
            done
};;
esac

6 /etc/profile.d/my_env.sh

        配置环境变量

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值