1.3 Quick Start中 Step 3: Create a topic官网剖析(博主推荐)
生活随笔
收集整理的這篇文章主要介紹了
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 testAlternatively, 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官网剖析(博主推荐)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Windows基本路由配置(cmd/ro
- 下一篇: 【BIEE】BIEE报表根据维度表展示事