Chapter 14. Using Cruise Control to modify topic replication factor
Make requests to the /topic_configuration
endpoint of the Cruise Control REST API to modify topic configurations, including the replication factor.
Prerequisites
-
You are logged in to Red Hat Enterprise Linux as the
kafka
user. - You have configured Cruise Control.
- You have deployed the Cruise Control Metrics Reporter.
Procedure
Start the Cruise Control server. The server starts on port 9092 by default; optionally, specify a different port.
cd /opt/cruise-control/ ./kafka-cruise-control-start.sh config/cruisecontrol.properties <port_number>
To verify that Cruise Control is running, send a GET request to the
/state
endpoint of the Cruise Control server:curl -X GET 'http://<cc_host>:<cc_port>/kafkacruisecontrol/state'
Run the
bin/kafka-topics.sh
command with the--describe
option and to check the current replication factor of the target topic:/opt/kafka/bin/kafka-topics.sh \ --bootstrap-server localhost:9092 \ --topic <topic_name> \ --describe
Update the replication factor for the topic:
curl -X POST 'http://<cc_host>:<cc_port>/kafkacruisecontrol/topic_configuration?topic=<topic_name>&replication_factor=<new_replication_factor>&dryrun=false'
For example,
curl -X POST 'localhost:9090/kafkacruisecontrol/topic_configuration?topic=topic1&replication_factor=3&dryrun=false'
.-
Run the
bin/kafka-topics.sh
command with the--describe
option, as before, to see the results of the change to the topic.