JS 与 trick 代码的运用及解析全攻略
651
2022-09-30
kafka启动停止脚本
#!/bin/bashENV_FILE=~/.bash_profile# 判断是否有bash_profile文件if [ ! -f "${ENV_FILE}" ]; then source ${ENV_FILE}fi##java envexport JAVA_HOME=/usr/local/jdkexport CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CLASSPATHexport PATH=$PATH:$JAVA_HOME/binkafka_home_log=/data/SW/kafka/logskafka_home=/usr/local/sw/cluster/kafkastartApp="$kafka_home/bin/kafka-server-start.sh -daemon $kafka_home/config/server.properties"# 停止Kafka服务function stop(){ echo "stopping kafka" SIGNAL=${SIGNAL:-TERM} PIDS=$(ps ax | grep java | grep -i Kafka | grep -v grep | awk '{print }') if [ -z "$PIDS" ]; then echo "No kafka server to stop" exit 1 else kill -s $SIGNAL $PIDS cleanlog fi echo "stoped success"}# 启动Kafka服务function start(){ echo "starting kafka" # $startApp COMMAND=$(ps ax | grep java | grep -i Kafka | grep -v grep | awk '{print }') for((i=1;i<=5;i++)); do if [[ $COMMAND -le 0 ]]; then $startApp echo "start $i sleep 10s else echo "process alived" break fi done echo "started sucess"} # 重启kafka服务function restart(){ echo "restarting kafka" echo "kafka process is $(ps ax | grep java | grep -i Kafka | grep -v grep | awk '{print }')" stop sleep 10s start echo "kafka process is $(ps ax | grep java | grep -i Kafka | grep -v grep | awk '{print }')" echo "restarted success"}function cleanlog(){ echo "删除kafka的临时目录$kafka_home_log" # 删除kafka的临时目录 rm $kafka_home_log/* -rf echo "done 删除kafka的临时目录"}case "" in start) start ;; stop) stop ;; restart) restart ;; * )echo "no command";;esacexit 0
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~