1. 程式人生 > >kafka_2.11-1.1.1 遠端一鍵啟停

kafka_2.11-1.1.1 遠端一鍵啟停

 kafka_2.11-1.1.1 這個版本自帶的stop指令碼有問題,需要重新再broker上寫一個stop.sh

#!/bin/sh
	pid=`jps | grep Kafka | awk '{print $1}'`
	echo $HOSTNAME $pid
	kill -9 $pid

統一啟停:

#!/bin/bash

command=$1
config=/home/hadoop/kafka_2.11-1.1.1/config/server.properties

startcmdpath=/home/hadoop/kafka_2.11-1.1.1/bin/kafka-server-start.sh
stopcmdpath=/home/hadoop/kafka_2.11-1.1.1/bin/kafka-server-stop.sh


if [ $command = 'start' ]
then
	$startcmdpath -daemon $config
	ssh hdslave2 "$startcmdpath -daemon $config"
	ssh hdslave3 "$startcmdpath -daemon $config"
elif [ $command = 'stop' ]
then
	pid=`jps | grep Kafka | awk '{print $1}'`
	echo hdmaster $pid
	kill -9 $pid
	ssh hdslave2 $stopcmdpath
	ssh hdslave3 $stopcmdpath
fi