一、安装kafka
brew install kafka
lishuo@李硕的MacBook Pro:~ [130] $ brew install kafka ✘ Running `brew update --preinstall`... ==> Auto-updated Homebrew! Updated 1 tap (shivammathur/php). ==> Updated Formulae Updated 9 formulae. ==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/openjdk-17.0.2.arm64_ ######################################################################## 100.0% ==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/zookeeper-3.7.0_1.arm ######################################################################## 100.0% ==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/kafka-3.1.0.arm64_mon ######################################################################## 100.0% ==> Installing dependencies for kafka: openjdk and zookeeper ==> Installing kafka dependency: openjdk ==> Pouring openjdk-17.0.2.arm64_monterey.bottle.tar.gz 🍺 /opt/homebrew/Cellar/openjdk/17.0.2: 640 files, 306.4MB ==> Installing kafka dependency: zookeeper ==> Pouring zookeeper-3.7.0_1.arm64_monterey.bottle.tar.gz 🍺 /opt/homebrew/Cellar/zookeeper/3.7.0_1: 1,084 files, 42.4MB ==> Installing kafka ==> Pouring kafka-3.1.0.arm64_monterey.bottle.tar.gz ==> Caveats To restart kafka after an upgrade: brew services restart kafka Or, if you don't want/need a background service you can just run: /opt/homebrew/opt/kafka/bin/kafka-server-start /opt/homebrew/etc/kafka/server.properties ==> Summary 🍺 /opt/homebrew/Cellar/kafka/3.1.0: 198 files, 84.2MB ==> Running `brew cleanup kafka`... Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`). ==> Caveats ==> kafka To restart kafka after an upgrade: brew services restart kafka Or, if you don't want/need a background service you can just run: /opt/homebrew/opt/kafka/bin/kafka-server-start /opt/homebrew/etc/kafka/server.properties 复制代码
二、启动kafka服务
brew services start kafka
我们需要先后启动zookeeper和kafka服务。
它们都需要进入 /opt/homebrew/Cellar/kafka/3.1.0
目录,然后再启动相应的命令。
cd /opt/homebrew/Cellar/kafka/3.1.0 复制代码
启动zookeeper服务,运行命令:
zookeeper-server-start /opt/homebrew/etc/kafka/zookeeper.properties 复制代码
启动kafka服务,运行命令:
kafka-server-start /opt/homebrew/etc/kafka/server.properties