1.3 Quick Start中 Step 3: Create a topic官网剖析(博主推荐)
生活随笔
收集整理的這篇文章主要介紹了
1.3 Quick Start中 Step 3: Create a topic官网剖析(博主推荐)
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
一切來源于官網(wǎng)
http://kafka.apache.org/documentation/?
?
?
?
Step 3: Create a topic
Step 3: 創(chuàng)建一個主題(topic)?
Let's create a topic named "test" with a single partition and only one replica:
創(chuàng)建一個名為“test”的Topic,只有一個分區(qū)和一個備份:> 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:
創(chuàng)建好之后,可以通過運行以下命令,查看已創(chuàng)建的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.
或者,除了手工創(chuàng)建topic外,你也可以配置你的broker,當發(fā)布一個不存在的topic時自動創(chuàng)建topic。?
?
?
?
其實,這個很簡單,比如--create就是創(chuàng)建,--list是查看。當然,不能局限于官網(wǎng),大家要靈活多變,官網(wǎng)只是個參考和引子。
--topic test 名字為test的topic --partitions 1 分區(qū)數(shù)為1--replication-factor 1 復制因子是1(即每個分區(qū)在集群中有1份數(shù)據(jù))
--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,即每個分區(qū)在集群中有3份數(shù)據(jù)--partitions 10 指定topic的分區(qū)數(shù)10 --topic t-behavior 指定創(chuàng)建名為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 表示復制因子,即每個分區(qū)有幾份數(shù)據(jù) Leader 分區(qū)的主在那個broker上 Replicas 表示分區(qū)數(shù)據(jù)分布在哪些broker上 Isr 表示可立即作為分區(qū)的主的broker,即標識3分數(shù)據(jù)已經(jīng)保持一致了。
?
?
本文轉自大數(shù)據(jù)躺過的坑博客園博客,原文鏈接:http://www.cnblogs.com/zlslch/p/6766890.html,如需轉載請自行聯(lián)系原作者
總結
以上是生活随笔為你收集整理的1.3 Quick Start中 Step 3: Create a topic官网剖析(博主推荐)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Windows基本路由配置(cmd/ro
- 下一篇: 【BIEE】BIEE报表根据维度表展示事