1)在/home/hadoop/bin 目录下创建脚本 km.sh
[hadoop@el-01 shell]$ vim km.sh
在脚本中填写如下内容
#! /bin/bash case $1 in "start"){ echo " -------- 启动 KafkaManager -------" cd /bd/kafka-manager/ #export ZK_HOSTS="elk-01:2181,elk-02:2181,elk-03:2181" nohup /bd/kafka-manager/bin/kafka-manager - Dhttp.port=7456 >/bd/kafka-manager/bin/start.log 2>&1 & };; "stop"){ echo " -------- 停止 KafkaManager -------" ps -ef | grep ProdServerStart | grep -v grep |awk '{print $2}' | xargs kill };; * ) echo "usage:./km.sh start|stop" ;; esac