-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathstart-kafka.sh
More file actions
31 lines (27 loc) · 1.06 KB
/
start-kafka.sh
File metadata and controls
31 lines (27 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
Z=`ps -ef | grep zookeeper.properties | grep -v grep | awk '{print $2}'`
if [ "$Z" == "" ]; then
echo Starting Zookeeper
/usr/local/kafka/bin/zookeeper-server-start.sh /usr/local/kafka/config/zookeeper.properties &
else
echo Zookeeper already started
fi
sleep 3
K=`ps -ef | grep kafka | grep server.properties | grep -v grep | awk '{print $2}'`
if [ "$K" == "" ]; then
echo Starting Kafka
/usr/local/kafka/bin/kafka-server-start.sh /usr/local/kafka/config/server.properties &
else
echo Kafka already started
fi
sleep 3
T=`/usr/local/kafka/bin/kafka-topics.sh --list --zookeeper localhost:2181 | grep weblogs`
if [ "$T" == "" ]; then
echo Creating weblogs topic
/usr/local/kafka/bin/kafka-topics.sh --create --topic weblogs --replication-factor 1 --partitions 1 --zookeeper 192.168.10.2:2181
fi
T=`/usr/local/kafka/bin/kafka-topics.sh --list --zookeeper localhost:2181 | grep stats`
if [ "$T" == "" ]; then
echo Creating stats topic
/usr/local/kafka/bin/kafka-topics.sh --create --topic stats --replication-factor 1 --partitions 1 --zookeeper 192.168.10.2:2181
fi