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

Validate Kafka

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

[Note]Note
  • 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/kafka-topics.sh --zookeeper localhost:2181 --create --topic test --replication-factor 1 --partitions 1

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

    Created topic "test"

    [Note]Note

    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/kafka-console-producer.sh --broker-list localhost:9092 --topic test

    You should see your test message, for example:

    This is a message.

    [Note]Note

    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/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning