Last active
May 24, 2024 17:04
-
-
Save piatra/0d6f7ad1435fa7aa790a to your computer and use it in GitHub Desktop.
start zookeeper and kafka in the background and create a topic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$#" -ne 1 ]; then | |
echo "Please supply topic name" | |
exit 1 | |
fi | |
nohup bin/zookeeper-server-start.sh -daemon config/zookeeper.properties > /dev/null 2>&1 & | |
sleep 2 | |
nohup bin/kafka-server-start.sh -daemon config/server.properties > /dev/null 2>&1 & | |
sleep 2 | |
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic $1 | |
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic parsed |
Whether I used & or -daemon, the service will be stop in some random time.why?
Hi, while I tried your script I got the following error:
WARN Session 0x0 for server null, unexpected error, closing socket connection and attempting to reconnect (org.apache.zookeeper.ClientCnxn)
java.net.ConnectException: Connection refused
any help on this, please?
Use "-daemon" instead
#!/bin/bash
$KAFKA_HOME/bin/zookeeper-server-start.sh -daemon config/zookeeper.properties
$KAFKA_HOME/bin/kafka-server-start.sh -daemon config/server.properties
Thanks, updated.
@khanhafizurrahman32 I know this is over two years later, but for anyone else with the issue...firewall could be blocking it
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
!/bin/bash
$KAFKA_HOME/bin/zookeeper-server-start.sh -daemon config/zookeeper.properties
$KAFKA_HOME/bin/kafka-server-start.sh -daemon config/server.properties
:-)