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 ...
随机推荐
- NOIP模拟赛-奶牛晒衣服(dry)
一.奶牛晒衣服(dry) [问题描述] 在熊大妈英明的带领下,时针和它的同伴生下了许多牛宝宝.熊大妈决定给每个宝宝都穿上可爱的婴儿装.于是,为牛宝宝洗晒衣服就成了很不爽的事情. 圣人王担负起了这个重任 ...
- Scrum4.0+5.0 数独游戏
1.题目: 1.准备看板. 形式参考图4. 2.任务认领,并把认领人标注在看板上的任务标签上. 先由个人主动领任务,PM根据具体情况进行任务的平衡. 然后每个人都着手实现自己的任务. 3.为了团队合作 ...
- 阅读《构建之法》P384~391
通过阅读<构建之法>P384~391以及参考阅读杜老师给出的链接,得出一个重要的结论:软件工程师的职业道德至关重要. 软件工程的动态性和需求的前后关系,要求一个规范能对出现的新情形有较强的 ...
- 三分 --- ZOJ 3203 Light Bulb
Light Bulb Problem's Link: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3203 Mean: ...
- EasyUI文档学习心得
概述 jQuery EasyUI 是一组基于jQuery 的UI 插件集合,它可以让开发者在几乎完全不需要CSS以及复杂的JS代码情况下完成美观且功能强大的Web界面. 本文主要说明一些如何利用Eas ...
- Python基础:模块
一.概述 二.导入语句 1.基本语法 2.推荐风格 三.模块 1.模块名 2.模块属性 3.可导出的公有属性 4.直接执行 四.包 1.包名 2.包属性 3.可导出的公有属性 4.其他 五.导入原理 ...
- [水]用vb写了个PCB
这学期我们学操作系统,所以得写个PCB. 于是我借鉴了一下windows的PCB,写了这个 Imports System.Runtime.InteropServices ''' <summary ...
- 看了一本Unity3D的教程
国内写的<Unity 3D游戏开发>. 实例挺多,对于有基础的人来说,上手会挺快的: 但进阶的东西没有涉及,可能与书的定位有关吧
- python pip 升级每个包
pip本身不自带升级所有包的功能, 但可以通过下面的脚本实现. import pip from subprocess import call for dist in pip.get_installed ...
- [Android] 环境配置之基础开发环境(SDK/Android Studio)(转)
[Android] 环境配置之基础开发环境(SDK/Android Studio) 博客: blog.csdn.net/qiujuer 网站: www.qiujuer.net 开源库: Geniu ...