how to change Kafka broker list ip
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 popular distributed streaming platform that utilizes a cluster of brokers to manage its robust, high-throughput message service. Changing the IP list of Kafka brokers is a process that can be required during scaling, maintenance, or migration of your Kafka setup. Here’s how to successfully modify the IP addresses of brokers in your Kafka broker list.
Understanding Kafka Configuration
Before diving into how to change the broker IP addresses in Kafka, it’s important to understand where and how Kafka brokers are configured:
- server.properties: Each broker in a Kafka cluster has its own
server.propertiesfile. This file contains many broker-specific configurations includinglisteners, which dictate how the brokers receive requests from producers and consumers. - Zookeeper: Kafka uses Zookeeper for maintaining and managing the cluster state and configurations. Changes in the brokers must also be reflected here for consistency across the cluster.
Step-by-Step Approach to Change Broker IPs
1. Pre-Change Preparations
- Backup Configuration: Always backup your existing configurations.
- Check Interdependencies: Ensure that no services are tightly coupled with the current IP configurations.
2. Update Broker Configurations
- Navigate to each Kafka broker’s
server.propertiesfile. - Locate the
listenersproperty. This will generally be in the formatlisteners=PLAINTEXT://your.old.ip.address:port. - Modify the IP address in the
listenersline to the new IP address.
Example:
3. Update Zookeeper Data
- Log into Zookeeper CLI: Connect to your Zookeeper instance.
- Identify Broker Information: Search for the path where Kafka stores its broker information, often found under
/brokers/ids. - Update Each Broker Node: For each broker, update the IP address information.
Example of Zookeeper command:
4. Restart Kafka Brokers
- Restart each Kafka broker one at a time to ensure minimal downtime. This will enable the revised configurations to take effect.
5. Verify Changes
- Use Kafka command-line tools like
kafka-brokers.shto verify that all brokers are registered with the new IPs. - Check the logs of each broker to ensure they have reconnected successfully with the cluster.
Table: Key Points in Changing Kafka Broker IP Addresses
| Step | Action | Detail/Command |
| 1. | Backup Configurations | cp server.properties server.properties.bak |
| 2. | Modify Listeners Property | $: old_ip -> new_ip in server.properties |
| 3. | Update Zookeeper Data | set /brokers/ids/1 {...new.ip.address...} |
| 4. | Restart Brokers | kafka-server-stop.sh; kafka-server-start.sh |
| 5. | Verify Changes | kafka-brokers.sh; check logs |
Additional Considerations
- Rolling Upgrades: Implement changes using a rolling upgrade strategy to avert any downtime.
- Testing: Test the entire configuration in a staging environment before applying to production.
- Monitoring and Alerts: Monitor your Kafka system through any available monitoring solutions and enable alerts to swiftly respond to any anomalies during or after the transition.
Conclusion
Changing broker IPs in a Kafka cluster, while sensitive, can be effectively handled by carefully updating server.properties and corresponding Zookeeper data, followed by systematic restarts and verification. Keeping a close eye on the transition process and monitoring cluster behavior afterward are equally necessary to ensure that Kafka continues to operate smoothly post-configuration change.
Related reading
- How to change RabbitMQ Heartbeat without restart
- How to change the name of the topic generated by Kafka Connect Source Connector
- How to check consumer offsets when the offset store is Kafka?
- How to check if a topic was consumed by a consumer in Kafka
- How to change swagger-ui.html default path
- How to check errors from asynchronous Web Services calls
- How to change the CHARACTER SET and COLLATION throughout a database?
- How to change the threshold on decision tree classifier model?

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.