不多说,直接上干货!

  一切来源于官网

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: --replication-factor  --partitions  --topic t-behavior

bin/kafka-topics.sh --create --zookeeper hadoop1: --replication-factor  --partitions  --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: --topic t-behavior --describe
打印如下:
Topic:t-behavior PartitionCount: ReplicationFactor: Configs:
Topic: t-behavior Partition: Leader: Replicas: ,, Isr: ,,
Topic: t-behavior Partition: Leader: Replicas: ,, Isr: ,,
Topic: t-behavior Partition: Leader: Replicas: ,, Isr: ,,
Topic: t-behavior Partition: Leader: Replicas: ,, Isr: ,,
Topic: t-behavior Partition: Leader: Replicas: ,, Isr: ,,
Topic: t-behavior Partition: Leader: Replicas: ,, Isr: ,,
Topic: t-behavior Partition: Leader: Replicas: ,, Isr: ,,
Topic: t-behavior Partition: Leader: Replicas: ,, Isr: ,,
Topic: t-behavior Partition: Leader: Replicas: ,, Isr: ,,
Topic: t-behavior Partition: Leader: Replicas: ,, Isr: ,,
说明;
ReplicationFactor 表示复制因子,即每个分区有几份数据
Leader 分区的主在那个broker上
Replicas 表示分区数据分布在哪些broker上
Isr 表示可立即作为分区的主的broker,即标识3分数据已经保持一致了。

      over

1.3 Quick Start中 Step 3: Create a topic官网剖析(博主推荐)的更多相关文章

  1. 1.3 Quick Start中 Step 4: Send some messages官网剖析(博主推荐)

    不多说,直接上干货! 一切来源于官网 http://kafka.apache.org/documentation/ Step 4: Send some messages Step : 发送消息 Kaf ...

  2. 1.3 Quick Start中 Step 2: Start the server官网剖析(博主推荐)

    不多说,直接上干货! 一切来源于官网 http://kafka.apache.org/documentation/ Step 2: Start the server Step : 启动服务 Kafka ...

  3. 1.3 Quick Start中 Step 5: Start a consumer官网剖析(博主推荐)

    不多说,直接上干货! 一切来源于官网 http://kafka.apache.org/documentation/ Step 5: Start a consumer Step : 消费消息 Kafka ...

  4. 1.3 Quick Start中 Step 1: Download the code官网剖析(博主推荐)

    不多说,直接上干货! 一切来源于官网 http://kafka.apache.org/documentation/ 不要局限于,这个版本,我只是以最新的版本,来做个引子,让大家对官网的各个kafka版 ...

  5. 1.1 Introduction中 Kafka as a Storage System官网剖析(博主推荐)

    不多说,直接上干货! 一切来源于官网 http://kafka.apache.org/documentation/ Kafka as a Storage System kafka作为一个存储系统 An ...

  6. 1.1 Introduction中 Kafka as a Messaging System官网剖析(博主推荐)

    不多说,直接上干货! 一切来源于官网 http://kafka.apache.org/documentation/ Kafka as a Messaging System kafka作为一个消息系统 ...

  7. 1.3 Quick Start中 Step 8: Use Kafka Streams to process data官网剖析(博主推荐)

    不多说,直接上干货! 一切来源于官网 http://kafka.apache.org/documentation/ Step 8: Use Kafka Streams to process data ...

  8. 1.3 Quick Start中 Step 7: Use Kafka Connect to import/export data官网剖析(博主推荐)

    不多说,直接上干货! 一切来源于官网 http://kafka.apache.org/documentation/ Step 7: Use Kafka Connect to import/export ...

  9. 1.3 Quick Start中 Step 6: Setting up a multi-broker cluster官网剖析(博主推荐)

    不多说,直接上干货! 一切来源于官网 http://kafka.apache.org/documentation/ Step 6: Setting up a multi-broker cluster ...

随机推荐

  1. 在启动php时,无法启动此程序,由于计算机中丢失MSVCR110.dll的解决方法

    在启动php时,运行RunHiddenconsole.exe php-cgi.exe -b 127.0.0.1:9000 -c时,出现错误:无法启动此程序,由于计算机中丢失MSVCR110.dll 方 ...

  2. HDU 4349 Xiao Ming's Hope 组合数学

    题意:给你n,问在C(n,1),C(n,2)...C(n,n)中有多少个奇数. 比赛的时候打表看出规律,这里给一个数学上的说明. Lucas定理:A,B非负整数,p是质数,A,B化为p进制分别为a[n ...

  3. 通过视频展示如何通过Samba配置PDC

    通过视频展示如何通过Samba配置PDC(Linux企业应用案例精解补充视频内容) 本文通过视频,真实地再现了在Linux平台下如何通过配置smb.conf文件而实现Samba Server模拟win ...

  4. css3 列表图片hover左右滚动效果

  5. main函数argc,argv操作

    使用main(int argc, char *argv[])==main(int argc, char **argv)的基本操作是linux编程的最基本的一步,在windows下也是exe脱离IDE运 ...

  6. 在Ubuntu14.04中配置mysql远程连接教程

    上一篇文章,小编带大家学会了在Ubuntu14.04中安装MySQL,没有来得及上课的小伙伴们可以戳这篇文章:如何在Ubuntu14.04中安装mysql,今天给大家分享一下,如何简单的配置MySQL ...

  7. 2017-2018年红头发新版Cisco认证网络工程师(CCNA-R&S)全新讲解分享

    网名"红头发",多年授课经验,业内资深思科认证讲师,其所写的CISCO认证原创技术文章风靡各大网站与培训机构.精通CISCO各类路由交换产品,熟悉JUNIPER M/T系列路由产品 ...

  8. 紫书 习题 10-17 UVa 11105 (筛法)

    类似于素数筛的思想去做,不然暴力会超时而且还要判重 #include<cstdio> #include<cstring> #include<vector> #def ...

  9. SFML学习纪要

    工作需要,近段粗浅看了一下SFML,记录一下! 一.浅见概述 SFML,simple and Fast mulitmedia Library官方网站:http://www.sfml-dev.org/i ...

  10. 记VS2008初始化Microsoft Visual Sourcesafe源码管理提供程序时失败

    之前vs2008开发一直都好好,不知道为什么如今的vs2008打开和关闭都老是弹出这这个初始化Microsoft Visual Sourcesafe源码管理提供程序时失败的错误 解决方法非常easy: ...