3
0

More than 1 year has passed since last update.

Apache Kafka(MSK)の設定を変更する簡単な方法

Last updated at Posted at 2021-12-23

目的

MSKを使うとkafkaサーバを立ち上げるところまでは簡単なのですが、
具体的な設定変更の手順が不明瞭だったためまとめです。

Dockerコンテナの起動

設定変更用のクライアントを利用するために、サーバ用のコンテナが必要になります。
redisと同様ですが分かりにくさがあります。

docker run -it --rm bitnami/kafka bash

以下、コンテナ内の操作です。

設定ファイルの作成

--command-config のフォーマットが設定ファイル名のため作成します。
接続にSSLを利用する際の設定例です。

echo 'security.protocol=SSL' > /tmp/kfk

利用例

公式ドキュメント 通りにコマンドを流す準備ができました。
よく使うコマンドの利用例です。

ヘルプの表示

kafka-topics.sh \
  --command-config /tmp/kfk \
  --bootstrap-server \
    b-1.xxxxxxxxxx.kafka.ap-northeast-1.amazonaws.com:9094, \
    b-2.xxxxxxxxxx.kafka.ap-northeast-1.amazonaws.com:9094, \
    b-3.xxxxxxxxxx.kafka.ap-northeast-1.amazonaws.com:9094 \
  --help

トピック情報の表示

kafka-topics.sh \
  --command-config /tmp/kfk \
  --bootstrap-server \
    b-1.xxxxxxxxxx.kafka.ap-northeast-1.amazonaws.com:9094, \
    b-2.xxxxxxxxxx.kafka.ap-northeast-1.amazonaws.com:9094, \
    b-3.xxxxxxxxxx.kafka.ap-northeast-1.amazonaws.com:9094 \
  --topic [トピック名] --describe

パーテーション数の変更

kafka-topics.sh \
  --command-config /tmp/kfk \
  --bootstrap-server \
    b-1.xxxxxxxxxx.kafka.ap-northeast-1.amazonaws.com:9094, \
    b-2.xxxxxxxxxx.kafka.ap-northeast-1.amazonaws.com:9094, \
    b-3.xxxxxxxxxx.kafka.ap-northeast-1.amazonaws.com:9094 \
  --topic [トピック名] --alter --partitions 50

採用PR

弊社で一緒に働く仲間を募集しています。
全てのオタクを幸せにしたい方、是非ご覧ください!

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0