LoginSignup
14
10

More than 5 years have passed since last update.

Kafkaのtopic操作コマンド

Last updated at Posted at 2017-12-05

Kafkaのtopic操作コマンド

とにかく良く忘れるのでまとめる

前提条件

Kafkaバージョン: 0.11
Zookeeperの稼働場所:localhost:2181

コマンド実行場所はKafkaの展開ディレクトリとします

コマンド郡

topic作成

コマンド
./bin/kafka-topics.sh --zookeeper localhost:2181 --create --replication-factor 1 --partitions 1 --topic sample1
結果
Created topic "sample1".

replication-factor : ざっくり言うとメッセージの複製数
paprtitions : topic内のパーティション数

パラメータについてはKafkaの構成やtopicについてのドキュメントを一読しておくのが望ましいでしょう

tpic一覧表示

コマンド
./bin/kafka-topics.sh --zookeeper localhost:2181 --list
結果
sample1

topic詳細確認

コマンド
./bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic sample1
結果
Topic:sample1   PartitionCount:1    ReplicationFactor:1 Configs:
    Topic: sample1  Partition: 0    Leader: 1   Replicas: 1 Isr: 1

topic修正

コマンド
./bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic sample1 --config max.message.bytes=128000
結果
WARNING: Altering topic configuration from this script has been deprecated and may be removed in future releases.
         Going forward, please use kafka-configs.sh for this functionality
Updated config for topic "sample1".

WARNING出るけど実行出来てるみたい。configについては様々なパラメータがあるのでドキュメントを一読のこと..

topic削除

コマンド
./bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic sample1
結果
Note: This will have no impact if delete.topic.enable is not set to true.

Kafkaの起動時のパラメータで(デフォルトではconfig/server.properties) delete.topic.enable=true を指定していないと削除出来ない

14
10
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
14
10