kafka-basic-commands
kafka basic commands
有各种cheatsheet参考文档:
https://www.tutorialspoint.com/apache_kafka/apache_kafka_basic_operations.htm
https://betterprogramming.pub/kafka-cli-commands-1a135a4ae1bd
kafka topic 开荒操作
/opt/bitami/kafka
- 查看所有topic
bin/kafka-topics.sh --list --bootstrap-server localhost:9092
创建topic
bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --replication-factor 1 --partitions 1 --topic test
Created topic test.
- 再次查看topic列表
```bash
bin/kafka-topics.sh --list --bootstrap-server localhost:9092
test
``
- 查看某个topic详情
```bash
./kafka-topics.sh --bootstrap-server localhost:9092 --describe --topic test
Topic: test TopicId: f7JXP67-T4aXlVX-kOJgAg PartitionCount: 1 ReplicationFactor: 1 Configs: segment.bytes=1073741824
Topic: test Partition: 0 Leader: 1 Replicas: 1 Isr: 1
kafka 生产消费
生产端可以输入任意字符串, 消费端会立马打印出来
生产端:
bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic test
消费端
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 -topic test
