不多说,直接上干货!

  一切来源于官网

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. java钩子函数

    也不知道我理解的对不对,欢迎大家讨论! 自己写了个钩子函数,我理解的钩子函数: public interface Transactioner { String wedontknow() ; } pub ...

  2. 鸟哥的Linux私房菜-----15、例行性命令at与crontab

  3. 对照 Android 的 Intent 与 iOS StoryBoard 的 Segue - Intent 假设也能添加个prepareForSegue回调就好了

    对照 Android 的 Intent 与 iOS StoryBoard 的 Segue - Intent 假设也能添加个prepareForSegue回调就好了 太阳火神的漂亮人生 (http:// ...

  4. POJ 3450--Corporate Identity【KMP && 枚举】

    Corporate Identity Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 5696   Accepted: 207 ...

  5. 安装SQL2008后需要打开的端口为 1433,4630

  6. javaScript 对象学习笔记

    javaScript 对象学习笔记 关于对象,这对我们软件工程到学生来说是不陌生的. 因为这个内容是在过年学到,事儿多,断断续续,总感觉有一丝不顺畅,但总结还是要写一下的 JavaScript 对象 ...

  7. LRJ入门经典-0907万圣节的小L306

    原题 LRJ入门经典-0907万圣节的小L306 难度级别:B: 运行时间限制:1000ms: 运行空间限制:256000KB: 代码长度限制:2000000B 试题描述 今天是万圣节,小L同学开始了 ...

  8. Windows学习总结(6)——MindManager新手入门教程

    MindManager新手入门教程 MindManager是一款创造.管理和交流思想的思维导图软件,其直观清晰的可视化界面和强大的功能可以快速捕捉.组织和共享思维.想法.资源和项目进程等等.MindM ...

  9. ubuntu下vim中内容拷贝到浏览器

    在vim中编辑好了代码想要复制出来到浏览器或者其它地方.用yy复制后去别的地方粘帖发现根本不是当初复制的内容,非常头疼-- 这是由于vim中有它自己的一套剪贴板系统(clipboard).这套系统和u ...

  10. Linux下MySQL导入导出数据库

    linux下 一.导出数据库用mysqldump命令(注意mysql的安装路径,即此命令的路径):1.导出数据和表结构:mysqldump -u用户名 -p密码 数据库名 > 数据库名.sql# ...