Apache Kafka - Quick Start on Windows
在这篇文章中,我将要介绍如何搭建和使用Apache Kafka在windows环境。在开始之前,简要介绍一下Kafka,然后再进行实践。
Apache Kafka
Kafka是分布式的发布-订阅消息的解决方案。相比于传统的消息系统,Kafka快速,可扩展,耐用。想象一下传统的发布-订阅消息系统,producers产生/写消息到topic中,另一边,consumers从topic中消费/读消息。Kafka的topic可以在多个服务器之间分区(partition)和复制(replicate)。
可以得到更多细节信息从Kafka官网。

我参考了这篇博客(http://blog.cloudera.com/blog/2014/09/apache-kafka-for-beginners/)。它简单并很好的解释了Kafka是什么。这两张图片也取自同一篇博客。
"Messages are simply byte arrays and the developers can use them to store any object in any format – with String, JSON, and Avro the most common. It is possible to attach a key to each message, in which case the producer guarantees that all messages with the same key will arrive to the same partition. When consuming from a topic, it is possible to configure a consumer group with multiple consumers. Each consumer in a consumer group will read messages from a unique subset of partitions in each topic they subscribe to, so each message is delivered to one consumer in the group, and all messages with the same key arrive at the same consumer."
“信息只不过是简单的字节数组,开发人员可以用它们来存储任何对象用任何格式--String,JSON,Avro是最常用的。可以给每个消息附上一个键,这样producer可以保证拥有相同键的消息到达相同的分区。当从一个topic消费信息时,可以配置一个消费组拥有多个消费者。在消费组里的每个消费者从订阅的topic的partition中读取唯一的一段消息,所以每个消息交付给组里的一个consumer,而且拥有相同键的所有消息到达同一个consumer。”
"What makes Kafka unique is that Kafka treats each topic partition as a log (an ordered set of messages). Each message in a partition is assigned a unique offset. Kafka does not attempt to track which messages were read by each consumer and only retain unread messages; rather, Kafka retains all messages for a set amount of time, and consumers are responsible to track their location in each log. Consequently, Kafka can support a large number of consumers and retain large amounts of data with very little overhead."
“使Kafka独特的是Kafka把每个topic分区当做一条日志来处理(一组有序的消息)。在一个分区当中的每一条消息被分配一个唯一的偏移量。Kafka并不试图追踪哪些消息被consumer读取,而是保留未被读取的消息;而且,Kafka保留了所有消息的时间设定量,consumer负责追踪在每一个log中他们的位置。因此,Kafka可以支持众多的消费者,保留大量的数据,只用了非常小的开销。”
现在你要问了,“怎么在Windows上设置Kafka环境?”。不必着急,我通过简单的几步来引导你。

log.dirs=<kafka_dir>\kafka-logs
dataDir=<kafka_dir>\zookeeper-data
<kafka_dir>\bin\windows\zookeeper-server-start.bat ..\..\config\zookeeper.properties
<kafka_dir>\bin\windows\kafka-server-start.bat ..\..\config\server.properties
<kafka_dir>\bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic mytopic
Created topic "mytopic".
<kafka_dir>\bin\windows\kafka-console-producer.bat --broker-list localhost:9092 --topic mytopic
<kafka_dir>\bin\windows\kafka-console-consumer.bat --zookeeper localhost:2181 --topic mytopic
Apache Kafka - Quick Start on Windows的更多相关文章
- Windows OS上安装运行Apache Kafka教程
Windows OS上安装运行Apache Kafka教程 下面是分步指南,教你如何在Windows OS上安装运行Apache Zookeeper和Apache Kafka. 简介 本文讲述了如何在 ...
- Spring for Apache Kafka
官方文档详见:http://docs.spring.io/spring-kafka/docs/1.0.2.RELEASE/reference/htmlsingle/ Authors Gary Russ ...
- Error when sending message to topic test with key: null, value: 2 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback)
windows下使用kafka遇到这个问题: Error when sending message to topic test with key: null, value: 2 bytes with ...
- Apache Kafka简介与安装(二)
Kafka在Windows环境上安装与运行 简介 Apache kafka 是一个分布式的基于push-subscribe的消息系统,它具备快速.可扩展.可持久化的特点.它现在是Apache旗下的一个 ...
- An Overview of End-to-End Exactly-Once Processing in Apache Flink (with Apache Kafka, too!)
01 Mar 2018 Piotr Nowojski (@PiotrNowojski) & Mike Winters (@wints) This post is an adaptation o ...
- Configuring Apache Kafka for Performance and Resource Management
Apache Kafka is optimized for small messages. According to benchmarks, the best performance occurs w ...
- Benchmarking Apache Kafka: 2 Million Writes Per Second (On Three Cheap Machines)
I wrote a blog post about how LinkedIn uses Apache Kafka as a central publish-subscribe log for inte ...
- How-to: Do Real-Time Log Analytics with Apache Kafka, Cloudera Search, and Hue
Cloudera recently announced formal support for Apache Kafka. This simple use case illustrates how to ...
- 《Apache kafka实战》读书笔记-kafka集群监控工具
<Apache kafka实战>读书笔记-kafka集群监控工具 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 如官网所述,Kafka使用基于yammer metric ...
随机推荐
- Eclipse启动报错:A java runtime Environment(JRE) or java Development……的解决办法
第一种: 解决方法: 系统变量里设置下面: 变量名:JAVA_HOME 变量值:D:\Java\jdk1.8.0_31 变量名:CLASSPATH 变量值:.;%JAVA_HOME%\lib; 变量名 ...
- Swift使用FMDB操作SQLite
SQLite大家都懂的.本地数据库,在移动设备上使用广泛.IOS平台上自然也少不了它.最近自己折腾一个小App的时候需要使用sqlite本地数据库,上Github搜了下IOS下对SQLite的三方封装 ...
- AC自动机 - 多模式串的匹配 --- HDU 3695 Computer Virus on Planet Pandora
Problem's Link Mean: 有n个模式串和一篇文章,统计有多少模式串在文章中出现(正反统计两次). analyse: 好久没写AC自动机了,回顾一下AC自动机的知识. 本题在构造文章的时 ...
- background的属性和背景图片定位的实例
本文内容: 1.背景图片定位示例 2.background常用的属性值 3.background-repeat新增的round.space属性 4.background-size的属性值(着重介绍co ...
- R语言-简单线性回归图-方法
目标:利用R语言统计描绘50组实验对比结果 第一步:导入.csv文件 X <- read.table("D:abc11.csv",header = TRUE, sep = & ...
- java之StringBuilder类详解
StringBuilder 非线程安全的可变字符序列 .该类被设计用作StringBuffer的一个简易替换,用在字符串缓冲区被单个线程使用的时候(这种情况很普遍).如果可能,建议优先采用该类,因为在 ...
- Oracle不足与MySQL优势
Oracle库主要不足:1.单点故障:2.付费License;3.不支持水平扩展. MySQL及水平拆库的优势:1.单点故障影响率1/N:2.免费:3.可低成本水平扩展,近乎无限的水平扩展能力.
- [翻译]:SQL死锁-锁的类型
很久没有写博客了,这里面的原因有很多.最近的一个项目由于客户明确提出要做下性能压力测试,使用的工具就是VS自带的压力测试工具.以前其它项目做压力测试后反馈的其中一个重要问题就是数据库的死锁.没想到我们 ...
- javascript --- 设计模式之单体模式(一)
单体是一个用来划分命名空间并将一些相关的属性与方法组织在一起的对象,如果她可以被实例化的话,那她只能被实例化一次(她只能嫁一次,不能二婚). 单体模式是javascript里面最基本但也是最有用的模式 ...
- SharePoint 2013 创建搜索中心及搜索设置
本文没有太多深奥的东西,只是简单的搜索配置,如果你已经掌握请略过本文. 好了,进入内容简介,众所周知,搜索是SharePoint一大特性,下面,我们简单介绍下搜索中心的创建. 1.创建Search子网 ...