Mac下kafka的安装与配置
1. 安装
liuxianqiang-mac:~ liuxianqiang$ brew install kafka
==> Downloading https://homebrew.bintray.com/bottles/zookeeper-3.6.2.mojave.bottle.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/799dcedfc580923f05b1634fead93e5b4d570bf499f4c52e732cb123d3d9a928?response-content-dispositi
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/kafka-2.6.0.mojave.bottle.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/027a1d06325c8b98cca97cc2922fdbf7d980fb52917d1791861032cd501e5428?response-content-dispositi
######################################################################## 100.0%
==> Installing dependencies for kafka: zookeeper
==> Installing kafka dependency: zookeeper
==> Pouring zookeeper-3.6.2.mojave.bottle.tar.gz
==> Caveats
To have launchd start zookeeper now and restart at login:
brew services start zookeeper
Or, if you don't want/need a background service you can just run:
zkServer start
==> Summary
🍺 /usr/local/Cellar/zookeeper/3.6.2: 1,025 files, 37.0MB
==> Installing kafka
==> Pouring kafka-2.6.0.mojave.bottle.tar.gz
==> Caveats
To have launchd start kafka now and restart at login:
brew services start kafka
Or, if you don't want/need a background service you can just run:
zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties & kafka-server-start /usr/local/etc/kafka/server.properties
==> Summary
🍺 /usr/local/Cellar/kafka/2.6.0: 186 files, 62.4MB
zookeeper:
安装目录: /usr/local/Cellar/zookeeper/
自动启停: brew services start/stop zookeeper
手动启停: zkServer start/stop
手动启停(kafka内置):
zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties
zookeeper-server-stop
kafka:
安装目录: /usr/local/Cellar/kafka/
自动启停: brew services start/stop kafka
手动启停:
kafka-server-start /usr/local/etc/kafka/server.properties
kafka-server-stop
注意:
kafka依赖的zookeeper, 可以选择使用kafka内置的zookeeper.
在mac下, 建议使用brew services, 自动启停的方式, 简单干脆.
2. 验证
# 查看Topic
kafka-topics --list --zookeeper localhost:2181
# 创建Topic
kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic DEMO
# 发送消息 (一发一接, 需开两窗口)
kafka-console-producer --broker-list localhost:9092 --topic DEMO
# 接收消息 (一发一接, 需开两窗口)
kafka-console-consumer --bootstrap-server localhost:9092 --topic DEMO --from-beginning
# 如上命令, --help 查看帮助
3. 监控工具
暂无官方的监控页面
三方的有, kafka manager(yahoo), kafka center(国产) 等等.