启动 kafka
启动 kafka 使用 zookeeper
shell
# 启动 zookeeper
./zookeeper-server-start.sh ../config/zookeeper.properties &
# 启动 kafka
./kafka-server-start.sh ../config/server.properties &
# 关闭 kafka
./kafka-server-stop.sh ../config/server.properties
# 关闭 zookeeper
./zookeeper-server-stop.sh ../config/zookeeper.properties
使用独立 zookeeper 启动 kafka
shell
# 启动 zookeeper
./zkServer.sh start
# 启动 kafka
./kafka-server-start.sh ../config/server.properties &
使用 KRaft 启动 kafka
shell
# 生成 cluster UUID 生成的 UUID 为:tlR2hHI6S9eFbAkkkFYveQ
./kafka-storage.sh random-uuid
# 格式化日志目录 -t 参数的值为上面生成的 UUID: tlR2hHI6S9eFbAkkkFYveQ
./kafka-storage.sh format -t tlR2hHI6S9eFbAkkkFYveQ -c ../config/kraft/server.properties
# 启动 kafka
./kafka-server-start.sh ../config/kraft/server.properties &
# 关闭 kafka
./kafka-server-stop.sh ../config/kraft/server.properties
使用 Docker 启动 kafka
shell
# 拉取 kafka 镜像
docker pull apache/kafka:3.7.0
# 启动 kafka
docker -d --name kafka -p 9092:9092 --restart=always apache/kafka:3.7.0