日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

1.3 Quick Start中 Step 3: Create a topic官网剖析(博主推荐)

發布時間:2025/5/22 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 1.3 Quick Start中 Step 3: Create a topic官网剖析(博主推荐) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

  一切來源于官網

http://kafka.apache.org/documentation/

?

?

?

?

Step 3: Create a topic

Step 3: 創建一個主題(topic)

?

  Let's create a topic named "test" with a single partition and only one replica:

創建一個名為“test”的Topic,只有一個分區和一個備份:
> bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

  We can now see that topic if we run the list topic command:

創建好之后,可以通過運行以下命令,查看已創建的topic信息: > bin/kafka-topics.sh --list --zookeeper localhost:2181 test

  Alternatively, instead of manually creating topics you can also configure your brokers to auto-create topics when a non-existent topic is published to.

或者,除了手工創建topic外,你也可以配置你的broker,當發布一個不存在的topic時自動創建topic。

?

?

?

  

?

  其實,這個很簡單,比如--create就是創建,--list是查看。當然,不能局限于官網,大家要靈活多變,官網只是個參考和引子。

--topic test 名字為test的topic --partitions 1 分區數為1
--replication-factor 1 復制因子是1(即每個分區在集群中有1份數據)
--zookeeper localhost:2181  這個不多說,太簡單

?

?  比如,我們一般寫

bin/kafka-topics.sh --create --zookeeper master:2181 --replication-factor 3 --partitions 10 --topic t-behavior

bin/kafka-topics.sh --create --zookeeper hadoop1:2181 --replication-factor 3 --partitions 10 --topic t-behavior 說明:--replication-factor 3   指定了復制因子3,即每個分區在集群中有3份數據--partitions 10      指定topic的分區數10 --topic t-behavior       指定創建名為t-behavior的topic

?

?

?

?同時,查看topic詳情

bin/kafka-topics.sh --zookeeper txy001:2181 --topic t-behavior --describe
打印如下: Topic:t-behavior PartitionCount:10 ReplicationFactor:3 Configs:Topic: t-behavior Partition: 0 Leader: 1 Replicas: 1,2,0 Isr: 0,1,2Topic: t-behavior Partition: 1 Leader: 2 Replicas: 2,0,1 Isr: 0,1,2Topic: t-behavior Partition: 2 Leader: 0 Replicas: 0,1,2 Isr: 0,1,2Topic: t-behavior Partition: 3 Leader: 1 Replicas: 1,0,2 Isr: 0,1,2Topic: t-behavior Partition: 4 Leader: 2 Replicas: 2,1,0 Isr: 0,1,2Topic: t-behavior Partition: 5 Leader: 0 Replicas: 0,2,1 Isr: 0,1,2Topic: t-behavior Partition: 6 Leader: 1 Replicas: 1,2,0 Isr: 0,1,2Topic: t-behavior Partition: 7 Leader: 2 Replicas: 2,0,1 Isr: 0,1,2Topic: t-behavior Partition: 8 Leader: 0 Replicas: 0,1,2 Isr: 0,1,2Topic: t-behavior Partition: 9 Leader: 1 Replicas: 1,0,2 Isr: 0,1,2 說明; ReplicationFactor 表示復制因子,即每個分區有幾份數據 Leader 分區的主在那個broker上 Replicas 表示分區數據分布在哪些broker上 Isr 表示可立即作為分區的主的broker,即標識3分數據已經保持一致了。

?

?


本文轉自大數據躺過的坑博客園博客,原文鏈接:http://www.cnblogs.com/zlslch/p/6766890.html,如需轉載請自行聯系原作者

總結

以上是生活随笔為你收集整理的1.3 Quick Start中 Step 3: Create a topic官网剖析(博主推荐)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。