How to run following command to test kafka server is installed properly or not?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Apache Kafka is a distributed event streaming platform used by thousands of companies for high-performance data pipelines, streaming analytics, data integration, and mission-critical applications. Testing whether your Kafka server is installed correctly is essential to ensure that it behaves as expected, serving your streaming and message brokering needs efficiently.
Checking Kafka Installation
After installing Kafka, the most straightforward test to verify if it is running correctly is by using Kafka's own command-line tools to create a topic, produce some messages, and consume them.
Prerequisites
Before executing any command, ensure:
- Apache Kafka and ZooKeeper are installed on your server.
- Both Kafka and ZooKeeper services are running.
You can start Kafka and ZooKeeper using the following commands (assuming you are in the Kafka installation directory):
Part 1: Create a Kafka Topic
Creating a topic is the first step to check if Kafka can store and manage data.
Command:
Details:
--create: Command to create a topic.--topic testTopic: Specifies the name of the topic astestTopic.--bootstrap-server localhost:9092: Points to your Kafka server running onlocalhostwith port9092.--replication-factor 1: Each message in the topic will be replicated to only one node.--partitions 1: Topic will have only one partition.
Output:
Part 2: Produce Messages to the Topic
Produce some messages to see if they can be sent to the topic without any issues.
Command:
Details:
- You can type messages into the console after running the command and each new line you enter will be sent as a new message.
Example:
Type CTRL+C to exit the producer prompt.
Part 3: Consume Messages from the Topic
Finally, read the messages back to ensure that they were stored correctly in the Kafka topic.
Command:
Details:
--from-beginning: This tells Kafka to fetch messages from the beginning of the log.
Output:
Summary Table
| Command | Description | Usage |
kafka-topics.sh --create | Create a new Kafka topic. | Initialize data pipelines or testing setups. |
kafka-console-producer.sh | Send messages to a Kafka topic. | Test message production and topic behavior. |
kafka-console-consumer.sh | Consume messages from a Kafka topic. | Verify message storage and consumption. |
Additional Considerations
Logging & Monitoring
Once confirmed that Kafka is working as expected, setting up proper monitoring and logging can aid in production diagnostics and performance tuning. Tools like Prometheus, Grafana, or Kafka’s own JMX metrics can be helpful.
Security Aspects
In a production environment, securing Kafka using SSL/TLS, SASL, or Kerberos can protect sensitive data and guard against unauthorized access.
Conclusion
Validating that your Kafka installation works involves checking that all components function as expected—from creating topics to producing and consuming messages. This ensures data integrity and availability in your real-world applications. By following the above steps, one can systematically verify the success of a Kafka installation and move forward with configuring Kafka for their specific use cases.
Related reading
- How to run Kafka Connect connectors automatically (e.g. in production)?
- How to run Kafka with SASL_SSL
- how to run task at scheduled time with RabbitMQ
- How to save latest offset that Spark consumed to ZK or Kafka and can read back after restart
- How to run Gradle test when all tests are UP-TO-DATE?
- How to run JUnit test cases from the command line
- How to run Nginx within a Docker container without halting?
- How to see log files in MySQL?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.