当前位置: 首页> 汽车> 时评 > kafka操作

kafka操作

时间:2025/7/10 12:24:29来源:https://blog.csdn.net/q2570558854/article/details/141535642 浏览次数: 0次

kafka 操作

基本操作

# 列出所有的主题 --bootstrap-server 是必选参数
./kafka-topics.sh --list --bootstrap-server localhost:9092# 创建主题
./kafka-topics.sh --create --topic hello --bootstrap-server localhost:9092# 删除主题
./kafka-topics.sh --delete --topic hello --bootstrap-server localhost:9092# 显示主题详细信息
./kafka-topics.sh --describe --topic hello --bootstrap-server localhost:9092# 修改主题信息
./kafka-topics.sh --alter --topic hello --partitions 5 --bootstrap-server localhost:9092

写入操作

# 写入操作
./kafka-console-producer.sh --topic hello --bootstrap-server localhost:9092# 每一次换行是一个事件 Event
# 使用Ctrl+C退出,停止发送事件Event到主题 Topic

读取操作

# 读取操作
./kafka-console-consumer.sh --topic hello --from-beginning --bootstrap-server localhost:9092# 使用Ctrl+C停止消费者客户端

事件Events是持久存储在Kafka中的,所以它们可以被任意多次读取

关键字:kafka操作

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: