How to Use Kafka Manager: Setup and Basic Operations
To use
Kafka Manager, first install and start the Kafka Manager service, then add your Kafka cluster by providing its Zookeeper connection string. You can then monitor topics, brokers, and perform operations like topic creation and partition reassignment through its web interface.Syntax
Kafka Manager is a web-based tool that connects to your Kafka cluster via Zookeeper. The main steps are:
- Start Kafka Manager service.
- Add a Kafka cluster by specifying a name and Zookeeper hosts.
- Use the web UI to manage and monitor the cluster.
The key configuration is the zkhosts string, which tells Kafka Manager where to find your Kafka cluster metadata.
bash
bin/kafka-manager -Dconfig.file=conf/application.conf -Dhttp.port=9000 # In the config file, add your cluster: kafka-manager.zkhosts="localhost:2181" kafka-manager.clusters=[{"name":"MyCluster","zkHosts":"localhost:2181"}]
Example
This example shows how to start Kafka Manager, add a Kafka cluster, and view topics.
bash
# Start Kafka Manager on port 9000 bin/kafka-manager -Dhttp.port=9000 # Access the web UI at http://localhost:9000 # In the UI, add a cluster with: # Name: MyCluster # Zookeeper Hosts: localhost:2181 # After adding, click on the cluster to see topics, brokers, and partitions.
Output
INFO Kafka Manager started on http://localhost:9000
INFO Cluster 'MyCluster' added successfully
INFO Topics loaded: topic1, topic2, topic3
Common Pitfalls
- Incorrect Zookeeper address: Using the wrong Zookeeper host or port will prevent Kafka Manager from connecting.
- Firewall issues: Ensure ports 9000 (Kafka Manager) and 2181 (Zookeeper) are open.
- Version mismatch: Kafka Manager may not support very new Kafka versions; check compatibility.
- Not running Kafka Manager as a service: Running it in the background or as a service avoids accidental shutdowns.
bash
## Wrong Zookeeper address example (will fail): # kafka-manager.zkhosts="wronghost:2181" ## Correct Zookeeper address example: # kafka-manager.zkhosts="localhost:2181"
Quick Reference
| Action | Description | Example |
|---|---|---|
| Start Kafka Manager | Launch the Kafka Manager service | bin/kafka-manager -Dhttp.port=9000 |
| Add Cluster | Add Kafka cluster via Zookeeper hosts | Name: MyCluster, ZK Hosts: localhost:2181 |
| View Topics | See all topics and partitions | Click cluster > Topics tab |
| Create Topic | Create new topic with partitions and replication | Use UI 'Create Topic' button |
| Reassign Partitions | Move partitions between brokers | Use UI 'Partition Reassignment' feature |
Key Takeaways
Start Kafka Manager and connect it to your Kafka cluster via Zookeeper hosts.
Use the web UI to monitor brokers, topics, and partitions easily.
Ensure correct Zookeeper connection string to avoid connection errors.
Check Kafka Manager compatibility with your Kafka version before use.
Run Kafka Manager as a background service for continuous monitoring.