zoukankan      html  css  js  c++  java
  • kafka 集群启动脚本 xkafka

    1: 在 /usr/local/bin 目录下touch xkafka.sh

    2 : chmod 777 xkafka.sh

    3 :编辑文件

    #!/bin/bash
    
    #判断用户是否传参
    if [ $# -ne 1 ];then
        echo "无效参数,用法为: $0  {start|stop}"
        exit
    fi
    
    #获取用户输入的命令
    cmd=$1
    
    for (( i=101 ; i<=103 ; i++ )) ;do
        tput setaf 2
        echo ========== hadoop${i}  $cmd ================
        tput setaf 9
        case $cmd in
            start)
                ssh  hadoop${i} "source /etc/profile ; nohup /opt/module/kafka/bin/kafka-server-start.sh  /opt/module/kafka/config/server.properties >> /opt/module/kafka/console-logs/kafka-`date +%F`.log &" 
                #ssh  hadoop${i}  "source /etc/profile ; /opt/module/kafka/bin/kafka-server-start.sh -daemon /opt/module/kafka/bin/config/server.properties"
                echo  hadoop${i}  "服务已启动"
                ;;
            stop) 
                ssh hadoop${i}  "source /etc/profile ; /opt/module/kafka/bin/kafka-server-stop.sh" 
                echo hadoop${i}  "服务已停止"
                ;;
                *) 
                echo "无效参数,用法为: $0  {start|stop}"
                exit 
                ;;
         esac
    done

     注意点:

    1:/opt/module/kafka/console-logs  需要在kafka 目录下创建console-logs
    2:用notepad++编辑时候。注意notepad++右下角编码格式为Unix(LF)
     
  • 相关阅读:
    sql STUFF用法
    关于原型链
    原生js事件绑定
    http常见7种请求
    关于linux的一些常用的指令
    flex布局详解
    html5 新增元素以及css3新特性
    css浮动以及清除
    css 浮动
    计算机网络
  • 原文地址:https://www.cnblogs.com/kpwong/p/13768886.html
Copyright © 2011-2022 走看看