Validate Kafka
Use the following procedure to verify Kafka installation and configuration:
Note | |
---|---|
Verify that ZooKeeper is running before starting Kafka and validating the installation. |
Start the Kafka Service:
su kafka
"/usr/hdp/current/kafka-broker/bin/kafka start"
Run the following command to start the Kafka cluster:
<KAFKA_INSTALL_DIR>/bin/kafka start config/server.properties
Run the following command to create a test Kafka topic:
<KAFKA_INSTALL_DIR>/bin/kafka-topics.sh --zookeeper localhost:2181 --create --topic --replication-factor 1 --partitions 1 --topic test
The value of --replication-factor must match the number of Kafka servers in the cluster. You should see the following output if Kafka is installed correctly:
Created topic "test".
Run the following command to send a test message:
<KAFKA_INSTALL_DIR>/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
You should see your test message, for example:
This is a message.
Note To return to the command prompt after sending the test message, type Ctrl + C.
Run the following command to receive the test message:
<KAFKA_INSTALL_DIR>/bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning
You should see your test message:
This is a message.