Non-Ambari Cluster Installation Guide
Also available as:
loading table of contents...

Validate Kafka

Use the following procedure to verify the Kafka installation and configuration.


Verify that ZooKeeper is running before starting Kafka and validating the installation.

  1. Start the Kafka service using user kafka:

    su kafka -c "KAFKA_HOME/bin/kafka start"

  2. Create a Kafka topic with the name "test" that has a replication factor of 1 and 1 partition.

    bin/ --zookeeper localhost:2181 --create --topic test --replication-factor 1 --partitions 1

    After running this command, you should see the following output:

    Created topic "test"


    The value of --replication-factor must be less then or equal to the number of Kafka brokers in the cluster. Otherwise an error will occur. Usually the replication-factor equals the number of Kafka brokers in the cluster.

  3. Start a command line Kafka console producer that you can use to send messages. You can type your message once the process is started.

    <KAFKA_HOME>/bin/ --broker-list localhost:9092 --topic test

    You should see your test message, for example:

    This is a message.


    To return to the command prompt after sending the test message, type Ctrl + C.

  4. Start a command line kafka consumer that you can use to read the messages sent by the producer.

    <KAFKA_HOME>/bin/ --zookeeper localhost:2181 --topic test --from-beginning