window下Kafka最佳实践
2016-12-16 10:06
330 查看
Kafka的介绍和入门请看这里kafka入门:简介、使用场景、设计原理、主要配置及集群搭建(转)
当前文章从实践的角度为大家规避window下使用的坑。
1.要求:
java 6+
2.下载kafka【注意,只用下载kafka】
http://mirrors.cnnic.cn/apache/kafka/0.9.0.1/kafka_2.11-0.9.0.1.tgz
3.解压,通过cmd进入kafka_2.11-0.9.0.1\bin\windows目录
4.启动zk
zookeeper-server-start ..\..\config\zookeeper.properties
测试连接一下
zookeeper-shell.bat 0.0.0.0:2181
5.启动Kafka
kafka-server-start.bat ..\..\config\server.properties
6)创建topic
kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 3 --topic mytopic
参数的含义可以自查,当前无视
7)查看topic
kafka-topics.bat --describe --zookeeper localhost:2181 --topic mytopic
8)发布/生产消息窗口
kafka-console-producer.bat --broker-list localhost:9092 --topic mytopic
9)消费消息窗口
kafka-console-consumer.bat --zookeeper localhost:2181 --from-beginning --topic mytopic
10)在生产者producer窗口输入,可以在consumer窗口看到输出
--------------------------------------------------------------------
你真坚决
niaho
heelo
我是中文啊
--------------------------------------------------------------------
你真坚决
niaho
heelo
我是中文啊
--------------------------------------------------------------------
以上内容参考这里:http://kafka.apache.org/documentation.html#quickstart
ok,很完美.
出错问题:Unrecognized VM option UseG1GC 这些优化参数其实都是新版的,所以要么用jdk1.7+,要么去掉。
解决办法:打开conf\kafka-run-class.bat,找到102行,修改如下
使用java调用kafka,参考http://blog.csdn.net/hxpjava1/article/details/19160665。
Kafka与spring集成,参考http://colobu.com/2014/11/19/kafka-spring-integration-in-practice/
当前文章从实践的角度为大家规避window下使用的坑。
1.要求:
java 6+
2.下载kafka【注意,只用下载kafka】
http://mirrors.cnnic.cn/apache/kafka/0.9.0.1/kafka_2.11-0.9.0.1.tgz
3.解压,通过cmd进入kafka_2.11-0.9.0.1\bin\windows目录
4.启动zk
zookeeper-server-start ..\..\config\zookeeper.properties
测试连接一下
zookeeper-shell.bat 0.0.0.0:2181
5.启动Kafka
kafka-server-start.bat ..\..\config\server.properties
6)创建topic
kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 3 --topic mytopic
参数的含义可以自查,当前无视
Created topic "mytopic".
7)查看topic
kafka-topics.bat --describe --zookeeper localhost:2181 --topic mytopic
----------------------------------------------------------
Topic:mytopic PartitionCount:3 ReplicationFactor:1 Configs:
Topic: mytopic Partition: 0 Leader: 0 Replicas: 0 Isr: 0
Topic: mytopic Partition: 1 Leader: 0 Replicas: 0 Isr: 0
Topic: mytopic Partition: 2 Leader: 0 Replicas: 0 Isr: 0
8)发布/生产消息窗口
kafka-console-producer.bat --broker-list localhost:9092 --topic mytopic
9)消费消息窗口
kafka-console-consumer.bat --zookeeper localhost:2181 --from-beginning --topic mytopic
10)在生产者producer窗口输入,可以在consumer窗口看到输出
bin\windows>kafka-console
-producer.bat --broker-list localhost:9092 --topic mytopic
--------------------------------------------------------------------
你真坚决
niaho
heelo
我是中文啊
bin\windows>kafka-console
-consumer.bat --zookeeper localhost:2181 --from-beginning --topic mytopic
--------------------------------------------------------------------
你真坚决
niaho
heelo
我是中文啊
--------------------------------------------------------------------
以上内容参考这里:http://kafka.apache.org/documentation.html#quickstart
ok,很完美.
出错问题:Unrecognized VM option UseG1GC 这些优化参数其实都是新版的,所以要么用jdk1.7+,要么去掉。
解决办法:打开conf\kafka-run-class.bat,找到102行,修改如下
IF ["%KAFKA_JVM_PERFORMANCE_OPTS%"] EQU [""] ( rem set KAFKA_JVM_PERFORMANCE_OPTS=-server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+DisableExplicitGC -Djava.awt.headless=true set KAFKA_JVM_PERFORMANCE_OPTS=-server -XX:+DisableExplicitGC -Djava.awt.headless=true )
使用java调用kafka,参考http://blog.csdn.net/hxpjava1/article/details/19160665。
Kafka与spring集成,参考http://colobu.com/2014/11/19/kafka-spring-integration-in-practice/
相关文章推荐
- window下Kafka最佳实践
- 某互联网大厂kafka最佳实践
- MVVM探索:从ViewModel关闭Window的最佳实践
- Window下使用Xshell连接VirtualBox中CentOS SSH最佳实践
- Window下使用Xshell连接VirtualBox中CentOS SSH最佳实践
- Window下使用Xshell连接VirtualBox中CentOS SSH最佳实践
- 某互联网大厂kafka最佳实践
- MVVM探索:从ViewModel关闭Window的最佳实践
- Kafka最佳实践
- 【译】Kafka最佳实践 / Kafka Best Practices
- 【译】Kafka最佳实践
- J2ME最佳实践概述
- ASP.NET&Spring.NET&NHibernate最佳实践(二)——第1章前言
- Web前端开发最佳实践(8):还没有给CSS样式排序?其实你可以更专业一些
- 学习JavaScript最佳实践方法
- C#编码标准 - 指导和最佳实践 - Juval Lowy
- ASP.NET 缓存:方法和最佳实践
- Maven最佳实践:划分模块
- J2EE架构学习者的6个最佳实践
- 十大PHP最佳安全实践