-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
42 lines (34 loc) · 1.22 KB
/
setup.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
#!/bin/bash
#install java
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install -y default-jre
ZKIP=$(hostname --ip-address)
BRKID=0
SVRIP=${ZKIP}
ZKSTART=false
while getopts 'z:i:' opz
do
case $opz in
z) ZKIP=$OPTARG ;;
i) BRKID=$OPTARG ;;
esac
done
#download kafka & zookeeper bundle
KAFKAVER="2.8.1"
SCALAVER="2.12"
WORKDIR="/opt"
echo "getting archive ..."
sudo wget -q -O ${WORKDIR}/kafka.tgz https://archive.apache.org/dist/kafka/${KAFKAVER}/kafka_${SCALAVER}-${KAFKAVER}.tgz
sudo mkdir -p ${WORKDIR}/kafka
echo "expanding..."
sudo tar -C ${WORKDIR}/kafka --strip-components 1 -xzf ${WORKDIR}/kafka.tgz
cd ${WORKDIR}/kafka
if [ "${ZKIP}" = "${SVRIP}" ] ; then
#no zookeeper ip was provided, we start our own locally
#the default config listens on _all_ interfaces
echo "starting Zookeeper..."
sudo bin/zookeeper-server-start.sh config/zookeeper.properties >> /tmp/zookeeper.log 2>&1 &
fi
echo "starting kafka broker with ZK ${ZKIP}, listening on ${SVRIP}..."
sudo bin/kafka-server-start.sh config/server.properties --override advertised.listeners=PLAINTEXT://${SVRIP}:9092 --override broker.id=${BRKID} --override zookeeper.connect=${ZKIP}:2181 >> /tmp/kafka.log 2>&1 &