Setting up, Installing and Starting the Kafka server on MacOS
Apache Kafka is a popular distributed streaming platform that you can install and run on your MacBook. Below are the detailed steps to set up, install, and start Kafka on your MacBook:
Step 1 —
Download Apache Kafka
- Open your web browser and go to the Apache Kafka download page: https://kafka.apache.org/downloads
- Download the latest version of Kafka (e.g., kafka_2.13–3.5.0.tgz) for Scala 2.13.
Step 2 -
Extract Kafka
- Open Terminal.
- Navigate to the directory where you downloaded Kafka
- Extract and Unzip the downloaded kafka using below command —
tar -xzf kafka_2.13–3.5.0.tgzStep 3 —
Start Zookeeper
- Zookeeper is mandatory in the kafka cluster and broker(server) will not be started if zookeeper is unavailable.
- Open the terminal and Navigate to the Kafka directory:
cd kafka_2.13–3.5.0Command to start the zookeeper ->
bin/zookeeper-server-start.sh config/zookeeper.propertiesStep 4 —
Start Kafka server
Get bectorhimanshu’s stories in your inbox
Join Medium for free to get updates from this writer.
a. Open new Terminal and navigate to the kafka directory.
b. Run the following command to start Kafka server:
bin/kafka-server-start.sh config/server.propertiesThis will start the Kafka broker, and it will be ready to receive and process messages.
Bonus! Various handy kafka related commands.
a. Command to know kafka version — →
bin/kafka-broker-api-versions.sh --versionb. Create Topic ->
bin/kafka-topics.sh --create --topic cities --bootstrap-server localhost:9092c. To List all the Topics ->
bin/kafka-topics.sh --list --bootstrap-server localhost:9092d. To Describe a Topic ->
bin/kafka-topics.sh --describe --topic cities --bootstrap-server localhost:9092e. Producing messages to the topic ->
bin/kafka-console-producer.sh --topic cities --bootstrap-server localhost:9092f. Consuming messages using Kafka console Consumer — — >
bin/kafka-console-consumer.sh --topic cities --bootstrap-server localhost:9092g. To consume all the messages from the beginning ->
bin/kafka-console-consumer.sh --topic cities --from-beginning --bootstrap-server localhost:9092h. Run the following command to create a Kafka topic named “test-topic” with 1 partition and a replication factor of 1:
kafka-topics --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test-topici. To stop the Kafka server, you can use the kafka-server-stop command in a new Terminal window.







