zoukankan      html  css  js  c++  java
  • flume 启动,停止,重启脚本

    #!/bin/bash
    #echo "begin start flume..."
    #flume的安装根目录(根据自己情况,修改为自己的安装目录)
    path=/sysware/apache-flume-1.8.0-bin 
    echo "flume home is :$path" 
    #flume的进程名称,固定值(不用修改)
    JAR="flume"
    #flume的配置文件名称(根据自己的情况,修改为自己的flume配置文件名称)
    Flumeconf="flume-conf.conf"
    #定义的soure名称
    agentname="agent1"
    function start(){
    echo "begin start flume process ...." 
    #查找flume运行的进程数
    num=`ps -ef|grep java|grep $JAR|wc -l`  
    #判断是否有flume进程运行,如果有则运行执行nohup命令
    if [ "$num" = "0" ] ;then 
    nohup $path/bin/flume-ng agent --conf conf -f $path/conf/$Flumeconf --name $agentname -Dflume.root.logger=INFO,console & 
    echo "start success...." 
    echo "日志路径: $path/logs/flume.log" 
    else 
    echo "进程已经存在,启动失败,请检查....." 
    exit 0 
    fi 
    }
    function stop(){
    echo "begin stop flume process.."
    num=`ps -ef|grep java|grep $JAR|wc -l`
    #echo "$num...."
    if [ "$num" != "0" ];then
    #正常停止flume
    ps -ef|grep java|grep $JAR|awk '{print $2;}'|xargs kill 
    echo "进程已经关闭..."
    else
    echo "服务未启动,无须停止..."
    fi
    }
    function restart(){
    #echo "begin stop flume process .."
    #执行stop函数
    stop
    #判断程序是否彻底停止
    num='ps -ef|grep java|grep $JAR|wc -l'
    #stop完成之后,查找flume的进程数,判断进程数是否为0,如果不为0,则休眠5秒,再次查看,直到进程数为0
    while [ $num -gt 0 ];do
    sleep 5
    num='ps -ef|grep java|grep $JAR|wc -l'
    done
    echo "flume process stoped,and starting..."
    #执行start
    start
    echo "started...."
    }
    #case 命令获取输入的参数,如果参数为start,执行start函数,如果参数为stop执行stop函数,如果参数为restart,执行restart函数
    case "$1" in
    "start")
    start
    ;;
    "stop")
    stop
    ;;
    "restart")
    restart
    ;;
    *)
    ;;
    esac  
    

      

    以上脚本命名成.sh文件,例如我命名为 flume.sh  ,存放路径为 /sysware

    调用start 函数:

     sh /sysware/flume.sh start

    调用 stop命令

    sh /sysware/flume.sh stop

    调用重启命名

    sh /sysware/flume.sh restart

    以上脚本即可完成flume的start,stop,restart,并且在后台运行的需求。

    此博客中涉及到一些flume,shell命令知识点

    shell :函数、if 、while ,case、wc,管道符| 、sleep 等,可参考linux分类进行学习 

    flume:flume启动命令 ,可参考大数据分类进行学习

  • 相关阅读:
    poj 3335 Rotating Scoreboard
    卷积神经网络Convolutional Neural Networks
    深度卷积神经网络用于图像缩放Image Scaling using Deep Convolutional Neural Networks
    用matlab训练数字分类的深度神经网络Training a Deep Neural Network for Digit Classification
    深度神经网络入门教程Deep Neural Networks: A Getting Started Tutorial
    深度神经网络如何看待你,论自拍What a Deep Neural Network thinks about your #selfie
    视觉中的深度学习方法CVPR 2012 Tutorial Deep Learning Methods for Vision
    MFC编程入门
    什么是I帧,P帧,B帧
    视频编码部分定义
  • 原文地址:https://www.cnblogs.com/wenq001/p/10196201.html
Copyright © 2011-2022 走看看