-
Notifications
You must be signed in to change notification settings - Fork 140
/
quickstart.sh
executable file
·57 lines (43 loc) · 1.6 KB
/
quickstart.sh
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
#
# This script deploys Mesos Kafka on a minimesos cluster and adds a single broker
#
command -v minimesos >/dev/null 2>&1 || { echo "minimesos is not found. You can install it by running 'curl -sSL https://minimesos.org/install | sh'. For more info see https://www.minimesos.org" >&2; exit 1; }
cp kafka-mesos.sh /tmp
cp kafka-mesos*.jar /tmp
if [ "$1" == "" ]; then
echo "Usage: quickstart.sh <ipaddress>"
exit 1
fi;
IP=$1
echo "Launching minimesos cluster..."
minimesos up
echo "Exporting minimesos environment variables..."
$(minimesos)
MASTER_HOST_PORT=$(echo $MINIMESOS_MASTER | cut -d/ -f3)
echo "Creating kafka-mesos.properties file in /tmp..."
cat << EOF > /tmp/kafka-mesos.properties
storage=file:kafka-mesos.json
master=$MINIMESOS_ZOOKEEPER/mesos
zk=$MASTER_HOST_PORT
api=http://$IP:7000
EOF
echo "Installing Mesos Kafka..."
ZK_HOST_PORT=$(echo $MINIMESOS_ZOOKEEPER | cut -d/ -f3)
docker run -d -p 7000:7000 `whoami`/kafka-mesos --master=$MINIMESOS_ZOOKEEPER/mesos --api=http://$IP:7000 --zk=$ZK_HOST_PORT 2>&1 > /dev/null
echo "Wait until Mesos Kafka API is available..."
while ! nc -z $IP 7000; do
sleep 0.1 # wait for 1/10 of the second before check again
done
echo "Mesos Kafka API is available..."
echo "Adding broker 0..."
cd /tmp
./kafka-mesos.sh broker add 0
cd - 2>&1 > /dev/null
echo "Starting broker 0..."
cd /tmp
./kafka-mesos.sh broker start 0
cd - 2>&1 > /dev/null
minimesos state > state.json
BROKER_IP=$(cat state.json | jq -r ".frameworks[0].tasks[] | select(.name=\"broker-0\").statuses[0].container_status.network_infos[0].ip_address")
echo "broker-0 IP is $BROKER_IP"