sh 卡夫卡

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 卡夫卡相关的知识,希望对你有一定的参考价值。

# 创建一个topic
kafka-topics.sh --zookeeper localhost:2181 --create --topic <name of your topic> --partitions <number-of-partitions> --replication-factor <number-of-replication>
Describe a topic.

# 描述一个topic
kafka-topics.sh --zookeeper localhost:2181 --describe --topic <name of your topic>
List all the topics.

# 列出所有的话题
kafka-topics.sh --zookeeper localhost:2181 --list
Produce messages:

# 产生信息
kafka-console-producer.sh --broker-list localhost:9092 --topic <name of your topic>
Consume messages from a topic.

# 消费来自某个topic的消息
kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic <name of your topic> --from-beginning
Or
# or
kafka-simple-consumer-shell.sh --broker-list <hostname:port, ..., hostname:port> --topic <name of your topic>

# 删除topic
kafka-topics.sh --zookeeper localhost:2181 --delete --topic <name of your topic>
# 创建一个名为 test-topic 的新topic,其中包含1个分区和1个复制因子
kafka-topics.sh --zookeeper localhost:2181 --create --topic test-topic --partitions 1 --replication-factor 1

# 创建一个Kafka producer,他会把信息发送到你刚刚创建的topic
kafka-console-producer.sh --broker-list localhost:9092 --topic test-topic

# 在另一个控制台中,创建一个 Kafka consumer,该consumer将监听发送到topic的消息
kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test-topic --from-beginning

# 在 producer 控制台中,输入 i love Cloud Computing 并点击 return。 您可以多次将此消息发送到 Kafka 群集。 如果你的 Kafka 集群工作正常,你会在你的终端中看到我喜欢云计算的消息
Kafka API

以上是关于sh 卡夫卡的主要内容,如果未能解决你的问题,请参考以下文章

sh 卡夫卡命令

sh 卡夫卡经纪人测试失败

sh 在乒乓球卡夫卡消息上眨眼

卡夫卡消费者不返回任何事件

卡夫卡消费者名单

Siddhi中卡夫卡源初始化的问题