第16章 Cruise Control を使用したトピックレプリケーション係数の変更
Cruise Control REST API の /topic_configuration エンドポイントにリクエストを送信して、レプリケーション係数を含むトピック設定を変更します。
前提条件
-
Red Hat Enterprise Linux に
kafkaユーザーとしてログインしている。 - Cruise Control を設定 した。
- Cruise Control Metrics Reporter をデプロイ した。
手順
Cruise Control サーバーを起動します。デフォルトでは、サーバーはポート 9092 で起動します。オプションで別のポートを指定します。
cd /opt/cruise-control/ ./kafka-cruise-control-start.sh config/cruisecontrol.properties <port_number>
cd /opt/cruise-control/ ./kafka-cruise-control-start.sh config/cruisecontrol.properties <port_number>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Cruise Control が実行していることを確認するには、Cruise Control サーバーの
/stateエンドポイントに GET リクエストを送信します。curl -X GET 'http://<cc_host>:<cc_port>/kafkacruisecontrol/state'
curl -X GET 'http://<cc_host>:<cc_port>/kafkacruisecontrol/state'Copy to Clipboard Copied! Toggle word wrap Toggle overflow --describeオプションを指定してbin/kafka-topics.shコマンドを実行し、ターゲットトピックの現在のレプリケーション係数を確認します。/opt/kafka/bin/kafka-topics.sh \ --bootstrap-server localhost:9092 \ --topic <topic_name> \ --describe
/opt/kafka/bin/kafka-topics.sh \ --bootstrap-server localhost:9092 \ --topic <topic_name> \ --describeCopy to Clipboard Copied! Toggle word wrap Toggle overflow トピックのレプリケーション係数を更新します。
curl -X POST 'http://<cc_host>:<cc_port>/kafkacruisecontrol/topic_configuration?topic=<topic_name>&replication_factor=<new_replication_factor>&dryrun=false'
curl -X POST 'http://<cc_host>:<cc_port>/kafkacruisecontrol/topic_configuration?topic=<topic_name>&replication_factor=<new_replication_factor>&dryrun=false'Copy to Clipboard Copied! Toggle word wrap Toggle overflow たとえば、
curl -X POST 'localhost:9090/kafkacruisecontrol/topic_configuration?topic=topic1&replication_factor=3&dryrun=false'とします。-
前述の手順と同様に、
--describeオプションを指定してbin/kafka-topics.shコマンドを実行し、トピックへの変更の結果を確認します。