kafka 命令
Last updated on November 20, 2024 am
🧙 Questions
☄️ Ideas
版本查看
kafka-topics.sh --version
查看kafka端口号
ps -ef | grep kafka/config/server.properties
sudo netstat -nlpt | grep 7745
查看zookeeper端口号
ps -ef | grep org.apache.zookeeper.server.quorum.QuorumPeerMain
sudo netstat -nlpt | grep 4683
topic命令
查询topic列表
kafka-topics.sh --list --zookeeper isxcode:2181
创建topic
kafka-topics.sh --create --zookeeper isxcode:2181 --topic ispong-topic --replication-factor 1 --partitions 1
查询topic信息
kafka-topics.sh --describe --zookeeper isxcode:2181 --topic ispong-topic
删除topic
kafka-topics.sh --delete --zookeeper isxcode:2181 --topic ispong-topic
如果无法删除,则需要在zk中强行删除
# zookeeper-shell.sh isxcode:2181
ls /brokers/topics
deleteall /brokers/topics/ispong_kafka
生产者命令
kafka-console-producer.sh --topic ispong-topic --broker-list isxcode:9092
消费者命令
kafka-console-consumer.sh --bootstrap-server 192.168.115.104:30120 --topic ispong-topic --from-beginning --property print.key=true
group.id查看
cat /opt/kafka/config/consumer.properties | grep group.id=
参数说明
- zookeeper默认端口号:
2181
- kafka默认端口号:
9092
- earliest: 从最早的offset开始消费
- latest: 从最后的offset开始消费
--zookeeper
: ${zkHost}:${zkPort}/${zkPath},可以配置zk的具体路径,路径需要提前创建- 使用kafka-topic或者kafka-topics.sh
- group.id默认: test-consumer-group
🔗 Links
kafka 命令
https://ispong.isxcode.com/hadoop/kafka/kafka 命令/