1 minute read

Here’s a procedure to download and install Apache Kafka binaries on bare metal, and then verify that they’re working with a simple message produce and consume using Kafka scripts. This procedure should work on RHEL, macOS, and Windows.

  1. Download Kafka binaries

    Go to the Apache Kafka website. Download the latest Kafka binaries (not the source code) by clicking on the link under “Binary downloads”. Extract the downloaded archive to a directory of your choice.

  2. Set up environment variables.

    In a command prompt or terminal, navigate to the directory where you extracted the Kafka binaries.

    Set the KAFKA_HOME environment variable to this directory. For example, on Windows: set KAFKA_HOME=C:\path\to\kafka\directory.

    Add the bin directory within KAFKA_HOME to your system’s PATH environment variable. For example, on Windows: set PATH=%PATH%;%KAFKA_HOME%\bin.

  3. Start Kafka.

    Open a new command prompt or terminal window and navigate to the directory where you extracted the Kafka binaries.

    Start the ZooKeeper service: bin\zookeeper-server-start.sh config\zookeeper.properties (on Windows, use bin\windows\zookeeper-server-start.bat instead).

    In a separate command prompt or terminal window, start the Kafka broker: bin\kafka-server-start.sh config\server.properties (on Windows, use bin\windows\kafka-server-start.bat instead)

  4. Create a topic.

    Open a new command prompt or terminal window and navigate to the directory where you extracted the Kafka binaries.

    Create a new topic named “test” with a single partition and a replication factor of 1: bin\kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test

  5. Produce a message.

    Open a new command prompt or terminal window and navigate to the directory where you extracted the Kafka binaries.

    Send a message to the “test” topic: bin\kafka-console-producer.sh --bootstrap-server localhost:9092 --topic test.

    Type a message and press Enter to send it.

  6. Consume a message.

    Open a new command prompt or terminal window and navigate to the directory where you extracted the Kafka binaries.

    Start a consumer that reads messages from the beginning of the “test” topic: bin\kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning.

    You should see the message you produced in step 5 appear in the consumer window.

That’s it! If you followed these steps, you should have a working installation of Apache Kafka that can produce and consume messages.