1、安装Kafka
brew install kafka
- 安装完之后,会在/usr/local/Cellar目录下生成kafka和zookeeper两个文件夹
- kafka安装目录与配置文件路径如下所示,Kafka的默认端口号是9092
- Kafka的集群管理依赖于ZooKeeper,ZooKeeper的默认端口号是2182
# kafka安装目录
/usr/local/Cellar/kafka/2.8.0
?
# kafka配置文件目录
/usr/local/etc/kafka/
2、启动与关闭
2.1 启动zookeeper
- kafka是基于zookeeper的,启动kafka之前,需要先启动zookeeper
/usr/local/Cellar/kafka/2.8.0/bin/zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties &
# 先比较low地查找吧,后续补充上zookeeper的命令使用
ps aux | grep zookeeper
2.2 启动kafka
- 现在,可以尝试启动kafka了
- 前台启动kafka,末尾不加 &
- 后台启动,末尾加 &
/usr/local/Cellar/kafka/2.8.0/bin/kafka-server-start /usr/local/etc/kafka/server.properties &
# 先比较low地查找吧,后续补充上kafka的命令使用
ps aux | grep kafka
2.3 服务的关闭
- 服务关闭的顺序是先kafka,然后zookeeper
# 关闭kafka
/usr/local/Cellar/kafka/2.8.0/bin/kafka-server-stop
#关闭zookeeper
/usr/local/Cellar/kafka/2.8.0/bin/zookeeper-server-stop
|