博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
kafka+zookeeper环境配置(Mac 或者 linux环境)
阅读量:6881 次
发布时间:2019-06-27

本文共 3519 字,大约阅读时间需要 11 分钟。

一.zookeeper下载与安装

1)下载

adeMacBook-Pro:zookeeper_soft apple$ wget http://

2)解压

tar zxvf zookeeper-3.4.6.tar.gz

3)配置

cd zookeeper-3.4.6 cp -rf conf/zoo_sample.cfg conf/zoo.cfg
vim zoo.cfg

zoo.cfg:

# The number of milliseconds of each ticktickTime=2000# The number of ticks that the initial # synchronization phase can takeinitLimit=10# The number of ticks that can pass between # sending a request and getting an acknowledgementsyncLimit=5# the directory where the snapshot is stored.# do not use /tmp for storage, /tmp here is just # example sakes.dataDir=/Users/apple/Documents/soft/zookeeper_soft/zkdata #这个目录是预先创建的# the port at which the clients will connectclientPort=2181# the maximum number of client connections.# increase this if you need to handle more clients#maxClientCnxns=60## Be sure to read the maintenance section of the # administrator guide before turning on autopurge.## http://## The number of snapshots to retain in dataDir#autopurge.snapRetainCount=3# Purge task interval in hours# Set to "0" to disable auto purge feature#autopurge.purgeInterval=1

4)启动zookeeper

adeMacBook-Pro:bin apple$ sh  startJMX enabled by defaultUsing config: /Users/apple/Documents/soft/zookeeper_soft/zookeeper-3.4.6/bin/../conf/zoo.cfg-n Starting zookeeper ... STARTEDadeMacBook-Pro:bin apple$ ps ax| grep zookeeper.out 10311 s003  S+     0:00.01 grep zookeeper.outadeMacBook-Pro:bin apple$ ps ax| grep zookeeper10307 s003  S      0:00.63 /usr/bin/java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /Users/apple/Documents/soft/zookeeper_soft/zookeeper-3.4.6/bin/../build/classes:/Users/apple/Documents/soft/zookeeper_soft/zookeeper-3.4.6/bin/../build/lib/*.jar:/Users/apple/Documents/soft/zookeeper_soft/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/Users/apple/Documents/soft/zookeeper_soft/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/Users/apple/Documents/soft/zookeeper_soft/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/Users/apple/Documents/soft/zookeeper_soft/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/Users/apple/Documents/soft/zookeeper_soft/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/Users/apple/Documents/soft/zookeeper_soft/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/Users/apple/Documents/soft/zookeeper_soft/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/Users/apple/Documents/soft/zookeeper_soft/zookeeper-3.4.6/bin/../conf: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /Users/apple/Documents/soft/zookeeper_soft/zookeeper-3.4.6/bin/../conf/zoo.cfg

二 下载并且安装kafka(预先得安装配置好scala的环境,Mac环境参照:http://www.

1).下载kafka:

wget http://

2) 解压:

tar -zxf kafka_2.10-0.8.2.1.tgz

3)启动kafka

  adeMacBook-Pro:kafka_2.10-0.8.2.1 apple$ sh bin/kafka-server-start.sh config/server.properties

备注:要挂到后台使用:

sh bin/kafka-server-start.sh config/server.properties &

4)新建一个TOPIC

adeMacBook-Pro:bin apple$ sh  --create --topic kafkatopic --replication-factor 1 --partitions 1 --zookeeper localhost:2181

备注:要挂到后台使用:

sh  --create --topic kafkatopic --replication-factor 1 --partitions 1 --zookeeper localhost:2181 &

5) 把KAFKA的生产者启动起来:

adeMacBook-Pro:bin apple$ sh  --broker-list localhost:9092 --sync --topic kafkatopic

备注:要挂到后台使用:

sh  --broker-list localhost:9092 --sync --topic kafkatopic &

6)另开一个终端,把消费者启动起来:

adeMacBook-Pro:bin apple$ sh  --zookeeper localhost:2181 --topic kafkatopic --from-beginning

备注:要挂到后台使用:

sh  --zookeeper localhost:2181 --topic kafkatopic --from-beginning &

7)使用

  1. 在发送消息的终端输入aaa,则可以在消费消息的终端显示,如下图所示:

转载地址:http://dubbl.baihongyu.com/

你可能感兴趣的文章
MultiDex工作原理分析和优化方案
查看>>
解密新一代Java JIT编译器Graal
查看>>
IBM在云计算中推动了Swift并使用了Swift的运行环境、包目录和其更多属性
查看>>
MongoDB 是如何鼓励和激励开发者社区的
查看>>
Apple开源新的压缩算法LZFSE
查看>>
.NET Core运行时和基础类库性能提升
查看>>
当编程语言掌握在企业手中,是生机还是危机?
查看>>
HTML5 Canvas玩转酷炫大波浪进度图
查看>>
RethinkDB已经将其数据库移植到Windows
查看>>
可观测性对测试的影响:QCon伦敦大会上对Amy Phillips的访谈
查看>>
Sharding-Sphere成长记——写在分布式数据库代理端里程碑版本3.0.0发布之际
查看>>
JS阻止事件冒泡以及浏览器默认行为
查看>>
使用自选择创建团队
查看>>
Bazel发布Beta版本,增加对Groovy、Rust和Scala语言的支持
查看>>
DevOps实战:Graphite监控上手指南
查看>>
日均千亿级别的数据请求量背后的秘密
查看>>
SICP Python 描述 2.2 数据抽象
查看>>
Mac 链接不上AppStore的解决方法
查看>>
Android 在 Multidex 下使用 Instant Run
查看>>
理解Cocoapods
查看>>