linux 常用脚本

linux 常用脚本自定义环境变量/etc/profile.d/my_env.sh#JAVA_HOMEexportJAVA_HOME=/opt/module/jdk1.8.0_171exportJRE_HOME=$JAVA_HOME/jreexportClASSPATH=.:$JAVA_HOME:$JRE_HOME/lib:$CLASSPATHexportPATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin#KAFKA_HOMEexportPATH=$PATH:/op

大家好,欢迎来到IT知识分享网。linux

自定义环境变量

/etc/profile.d/my_env.sh

# JAVA_HOME
export JAVA_HOME=/opt/module/jdk1.8.0_171
export JRE_HOME=$JAVA_HOME/jre
export ClASSPATH=.:$JAVA_HOME:$JRE_HOME/lib:$CLASSPATH
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin 

# KAFKA_HOME
export PATH=$PATH:/opt/module/kafka/bin

#ZOOKEEPER_HOME
export PATH=$PATH:/opt/module/zookeeper/bin

一、文件分发脚本

/usr/local/bin/xsync

#!/bin/bash
pdir=$(cd -P $(dirname $1); pwd)
for i in 22 23;
do
    scp -r $1 root@192.168.1.$i:$pdir/;
done

示例:

xsync Copt/software/jdk-8u171-linux-x64.tar.gz

二、远程执行命令脚本

/usr/local/bin/xcall

#!/bin/bash

for i in kafka-21 kafka-22 kafka-23
do
    echo "------------- $i \"$1\" ------------------"
    ssh $i "$1"
done

示例:

xcall "jps -l"

三、zookeeper启停脚本

/usr/local/bin/zk

#!/bin/bash
case $1 in
"start") { 
   
    for i in kafka-21 kafka-22 kafka-23
    do
        echo "---------------------- start $i ------------"
        ssh $i "/opt/module/zookeeper/bin/zkServer.sh start /opt/module/zookeeper/conf/zoo.cfg"
    done
};;
"stop") { 
   
    for i in kafka-21 kafka-22 kafka-23
    do
        echo "------------------ stop $i -----------------"
        ssh $i "/opt/module/zookeeper/bin/zkServer.sh stop"
    done
};;
"status") { 
   
    for i in kafka-21 kafka-22 kafka-23
    do
        echo "----------------- status $i ------------------"
        ssh $i "/opt/module/zookeeper/bin/zkServer.sh status"
    done
};;
esac

四、kafka启停脚本

/usr/local/bin/kf

#!/bin/bash
case $1 in
"start") { 
   
    for i in kafka-21 kafka-22 kafka-23
    do
        echo "---------------------- start $i ------------"
        ssh $i "/opt/module/kafka/bin/kafka-server-start.sh -daemon /opt/module/kafka/config/server.properties"
    done
};;
"stop") { 
   
    for i in kafka-21 kafka-22 kafka-23
    do
        echo "------------------ stop $i -----------------"
        ssh $i "/opt/module/kafka/bin/kafka-server-stop.sh"
    done
};;
esac

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/21461.html

(0)
上一篇 2024-01-19 14:15
下一篇 2024-01-19 20:33

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注微信