一切来源于官网

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官网剖析(博主推荐)相关推荐

  1. 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 ...

  2. 1.1 Introduction中 Consumers官网剖析(博主推荐)

    不多说,直接上干货! 一切来源于官网 http://kafka.apache.org/documentation/ Consumers 消费者(Consumers) Consumers label t ...

  3. PPQ.executor中的内容(来自PPQ官网)

    PPQ Graph Executor(PPQ执行引擎) 为了量化并优化神经网络模型,PPQ实现了基于Pytorch的执行引擎,该执行引擎能够执行Onnx与Caffe的模型文件,目前支持90余种常见On ...

  4. 虚幻4脱坑指南——官网C++编程教程中第一人称设计游戏教程的若干问题及解决方法

    一.前言 我使用的虚幻4引擎版本为4.25.3,碰到的问题是针对官网C++编程教程中第一人称设计游戏教程出现的情况. 二.问题与实现 2.1.缺少引用的编译错误 如图1所示的步骤2.7中,将官网的代码 ...

  5. 闪店空间官网-创意优质快闪店,店中店专家

    闪店空间官网-创意优质快闪店,店中店专家 闪店空间官网-创意优质快闪店,店中店专家 远程.work-为远程工作者寻找远程工作 posted on 2016-07-22 14:21  lexus 阅读( ...

  6. Oracle中,使 CREATE TABLE AS SELECT 支持ORDER BY

    Oracle中,使 CREATE TABLE AS SELECT 支持ORDER BY 文章发表:kehui  发表日期:2002-01-21  阅读次数:1103  大家都知道,"CREA ...

  7. mysql中新建数据库create table的COLLATE是什么?

    在mysql中执行show create table <tablename>指令,可以看到一张表的建表语句,example如下: CREATE TABLE `table1` (`id` b ...

  8. opencv的Mat中step的解释

    网络上对Mat的详解,绝大多数是翻译官方的manual,而官方的manual却恰好对部分(官方认为)我们平时很少使用的内容没有详细的解释,或者对一些实现没有解释细节,因此我们就很难在刚入门时迅速地对某 ...

  9. matlab step函数的用法,Matlab 中step conv 函数使用

    Matlab 中step 函数使用 s+ 4 对于一个闭环系统 传递函数是   G(s) = ------------------  : s^2 + 2s + 8 现在要求其时域响应: 代码: num ...

最新文章

  1. linux7系统怎么启动ftp,教你如何在CentOS7系统中配置ftp服务
  2. spacy库的安装与使用_为 SpaCy 提供的中文数据模型
  3. 《鸿蒙理论知识02》HarmonyOS开发平台和工具
  4. 《『若水新闻』客户端开发教程》——01.课程介绍
  5. rabbitmq 安装 linux
  6. javascript闭包_JavaScript闭包基本指南
  7. c++ string截取字符串_String类的常见用法
  8. 【Spring第三篇】什么是Bean?
  9. jrtplib 编译安装配置
  10. 微信小程序底部导航栏tabBar及不显示问题解决记录
  11. implement在JAVA中_java中的implement
  12. 树莓派系列二:openCV之头像添加国旗
  13. 后门攻击阅读笔记,Input-aware dynamic backdoor attack
  14. 为什么电脑运行越来越慢?解决方法又是什么呢?
  15. 涂鸦Zigbee SDK开发系列教程——2.环境搭建
  16. 集合有哪些 java_java集合有哪些
  17. MySQL自定义函数和存储过程
  18. 小米10S MIUI13.0.3线刷12.5.14
  19. MySQL学习笔记——基础语句
  20. stackoverflow无法注册解决方案

热门文章

  1. 嵌入式系统中系统时间显示
  2. main 函数内的变量是全局变量,还是局部变量?
  3. 【星云测试】开发者测试-采用精准测试工具对Spring Boot应用进行测试
  4. PHP:第一章——PHP中的关键字
  5. [LeetCode] Binary Tree Postorder Traversal 二叉树的后序遍历
  6. java Date工具类
  7. Linux /etc/inittab 文件的解读
  8. 袁崇焕·任志强·张纪中
  9. mac redis 链接_在Ubunt/Mac系统安装Redis以及设置Redis密码并且允许远程连接 - Laravel学习网...
  10. js jquery关闭当前窗口