版本号确认:
- 进入kafka安装目录libs下,ll|grep kafka可以看出jar附带的版本号
- bin/kafka-topics.sh --version
官方文档:
https://kafka.apache.org/documentation/#gettingStarted
- 增 bin/kafka-topics.sh --create --replication-factor 2 --partitions 1 --topic tommy --zookeeper host1,host2:2181
- 删(标记) bin/kafka-topics.sh --zookeeper host1,host2:2181 --topic tommy --delete
- 改 bin/kafka-topics.sh --zookeeper host1,host2:2181 -alter --partitions 2 --topic tommy
- 查 bin/kafka-topics.sh --bootstrap-server host1,host2:9092 --list
- 生产 bin/kafka-console-producer.sh --bootstrap-server host1,host2:9092 --topic tommy
- 消费 bin/kafka-console-consumer.sh --bootstrap-server host1,host2:9092 --topic tommy --from-beginning
- 【To check overrides set on the topic you can do】
kafka-configs --zookeeper host:2181 --entity-type topics --entity-name mytopic --describe
- 【修改topic某个配置】
kafka-configs --zookeeper host:2181 --entity-type topics --entity-name mytopic --alter --add-config retention.ms=259200000
注:delete.topic.enable=false,执行delete语句时并没有被删除,只是被标记为删除
另外,到kafka的broker节点上执行kafka-dump-log --files l o g . d i r s / log.dirs/ log.dirs/topic/xxx.log即可查看消息是否被压缩