1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- #!/bin/sh
- set -ex
- TOXIPROXY_VERSION=2.1.4
- mkdir -p ${KAFKA_INSTALL_ROOT}
- if [ ! -f ${KAFKA_INSTALL_ROOT}/kafka-${KAFKA_VERSION}.tgz ]; then
- wget --quiet https://archive.apache.org/dist/kafka/${KAFKA_VERSION}/kafka_${KAFKA_SCALA_VERSION}-${KAFKA_VERSION}.tgz -O ${KAFKA_INSTALL_ROOT}/kafka-${KAFKA_VERSION}.tgz
- fi
- if [ ! -f ${KAFKA_INSTALL_ROOT}/toxiproxy-${TOXIPROXY_VERSION} ]; then
- wget --quiet https://github.com/Shopify/toxiproxy/releases/download/v${TOXIPROXY_VERSION}/toxiproxy-server-linux-amd64 -O ${KAFKA_INSTALL_ROOT}/toxiproxy-${TOXIPROXY_VERSION}
- chmod +x ${KAFKA_INSTALL_ROOT}/toxiproxy-${TOXIPROXY_VERSION}
- fi
- rm -f ${KAFKA_INSTALL_ROOT}/toxiproxy
- ln -s ${KAFKA_INSTALL_ROOT}/toxiproxy-${TOXIPROXY_VERSION} ${KAFKA_INSTALL_ROOT}/toxiproxy
- for i in 1 2 3 4 5; do
- ZK_PORT=$((i + 2180))
- ZK_PORT_REAL=$((i + 21800))
- KAFKA_PORT=$((i + 9090))
- KAFKA_PORT_REAL=$((i + 29090))
-
- mkdir -p ${KAFKA_INSTALL_ROOT}/kafka-${KAFKA_PORT}
- tar xzf ${KAFKA_INSTALL_ROOT}/kafka-${KAFKA_VERSION}.tgz -C ${KAFKA_INSTALL_ROOT}/kafka-${KAFKA_PORT} --strip-components 1
-
- mkdir -p "${KAFKA_INSTALL_ROOT}/kafka-${KAFKA_PORT}/data"
-
- printf "\n\n" >> "${KAFKA_INSTALL_ROOT}/kafka-${KAFKA_PORT}/config/server.properties"
- cat << EOF >> "${KAFKA_INSTALL_ROOT}/kafka-${KAFKA_PORT}/config/server.properties"
- broker.id=${KAFKA_PORT}
- broker.rack=${i}
- listeners=PLAINTEXT://:${KAFKA_PORT_REAL}
- advertised.listeners=PLAINTEXT://${KAFKA_HOSTNAME}:${KAFKA_PORT}
- zookeeper.connect=127.0.0.1:${ZK_PORT}
- log.dirs="${KAFKA_INSTALL_ROOT}/kafka-${KAFKA_PORT}/data"
- default.replication.factor=2
- log.retention.bytes=268435456
- log.segment.bytes=268435456
- delete.topic.enable=true
- auto.create.topics.enable=false
- zookeeper.session.timeout.ms=3000
- zookeeper.connection.timeout.ms=3000
- reserved.broker.max.id=10000
- replica.selector.class=org.apache.kafka.common.replica.RackAwareReplicaSelector
- EOF
-
- cp ${REPOSITORY_ROOT}/vagrant/zookeeper.properties ${KAFKA_INSTALL_ROOT}/kafka-${KAFKA_PORT}/config/
- sed -i s/KAFKAID/${KAFKA_PORT}/g ${KAFKA_INSTALL_ROOT}/kafka-${KAFKA_PORT}/config/zookeeper.properties
- sed -i s/ZK_PORT/${ZK_PORT_REAL}/g ${KAFKA_INSTALL_ROOT}/kafka-${KAFKA_PORT}/config/zookeeper.properties
- ZK_DATADIR="${KAFKA_INSTALL_ROOT}/zookeeper-${ZK_PORT}"
- mkdir -p ${ZK_DATADIR}
- sed -i s
- echo $i > ${KAFKA_INSTALL_ROOT}/zookeeper-${ZK_PORT}/myid
- done
|