Skip to content

Instantly share code, notes, and snippets.

@itadventurer
Last active March 31, 2022 07:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itadventurer/381597803f62d7c46e0165d035f78664 to your computer and use it in GitHub Desktop.
Save itadventurer/381597803f62d7c46e0165d035f78664 to your computer and use it in GitHub Desktop.
Starting and Stopping single-node Kafka
#!/bin/bash
set -e
KAFKA_PATH=~/kafka
echo "Starting Zookeeper…"
${KAFKA_PATH}/bin/zookeeper-server-start.sh -daemon ${KAFKA_PATH}/config/zookeeper.properties
${KAFKA_PATH}/bin/kafka-server-start.sh -daemon ${KAFKA_PATH}/config/server.properties
echo "Zookeeper started. Waiting 5s to finish booting"
sleep 5
echo -n "Testing Connection…"
${KAFKA_PATH}/bin/zookeeper-shell.sh localhost:2181 ls / > /dev/null
echo -e "\tOK"
echo "Kafka started. Waiting 15s to finish booting"
sleep 15
echo -n "Testing Connection…"
kafka-broker-api-versions.sh --bootstrap-server localhost:9092 > /dev/null
echo -e "\tOK"
echo "Happy Streaming!"
#!/bin/bash
KAFKA_PATH=~/kafka
${KAFKA_PATH}/bin/kafka-server-stop.sh
${KAFKA_PATH}/bin/zookeeper-server-stop.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment