问题描述
我使用的是 macOS M1 Big Sur 11.2.3,但我的 kafka 无法正常运行,无法创建/列出主题.不知道是不是操作系统的原因,但是kafka的日志是这样的:
I use macOS M1 Big Sur 11.2.3, but my kafka cannot running well and cannot create/list the topics. I don't know its because the OS or not, but the log for kafka is only like this:
这是我的 docker compose:
here's my docker compose:
services:
zookeeper:
image: wurstmeister/zookeeper
container_name: zookeeper
hostname: zookeeper
ports:
- 2181:2181
environment:
ZOO_MY_ID: 1
networks:
- kafka_net
kafka:
image: wurstmeister/kafka
container_name: kafka
ports:
- 9092:9092
expose:
- 29092
depends_on:
- zookeeper
environment:
KAFKA_ADVERTISED_HOST_NAME: localhost
KAFKA_ADVERTISED_PORT: 9092
KAFKA_LISTENERS: INSIDE://0.0.0.0:29092,OUTSIDE://0.0.0.0:9092
KAFKA_ADVERTISED_LISTENERS: INSIDE://kafka:29092,OUTSIDE://localhost:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_BROKER_ID: 1
restart: always
networks:
- kafka_net
networks:
kafka_net:
driver: bridge
我认为 kafka 尚未运行,因此我无法列出/创建主题.大家有这个想法吗?我已经在搜索有关此的可能性,但我仍然没有解决问题.谢谢
I think kafka not yet to running, So i cannot list/create a topics. Do you guys have any idea of this? i already search possibilities about this, but i still don't have the problem solving. Thanks
推荐答案
对于在 mac m1 上的 docker 中启动 kafka,我接下来要做的事情:
For startup kafka in docker on mac m1 i do next things :
- 克隆 kafka 存储库并在我的 macbook pro m1 上构建 (./gradlew clean releaseTarGz)
- 使用下一个结构创建 docker-compose 项目目录
- 根目录
- kafka_m1
- kafka(解压缩的 kafka 发行版)
- Dockerfile
- docker-compose.yml
- 配置server.properties 文件(根目录/kafka_m1/kafka/config/server.properties).主要参数:
- Configure server.properties file (root dir/kafka_m1/kafka/config/server.properties). Main params:
zookeeper.connect=zookeeper:2181 listeners=PLAINTEXT://:9092 advertised.listeners=PLAINTEXT://127.0.0.1:9092 listener.security.protocol.map=PLAINTEXT:PLAINTEXT
- kafka 的 Dockerfile(openjdk:15.0.2-jdk 是为 m1 构建的):
- kafka`s Dockerfile (openjdk:15.0.2-jdk was build for m1):
FROM openjdk:15.0.2-jdk WORKDIR / COPY . / EXPOSE 9092 EXPOSE 8092 EXPOSE 9092 EXPOSE 10092 EXPOSE 11092 EXPOSE 12092 ENTRYPOINT [ "/kafka/bin/kafka-server-start.sh", "/kafka/config/server.properties" ]
- docker-compose.yml(我选择 zookeeper:3.7.0 因为它有 arm 构建):
- docker-compose.yml (i choose zookeeper:3.7.0 because it has arm build):
version: "2" services: zookeeper: image: zookeeper:3.7.0 ports: - "2181:2181" environment: ZOOKEEPER_CLIENT_PORT: 2181 ZOOKEEPER_TICK_TIME: 2000 kafka: build: ./kafka_m1 ports: - "127.0.0.1:9092:9092" volumes: - /var/run/docker.sock:/var/run/docker.sock
- 使用 kafka_m1 镜像构建启动 docker-compose.
在 docker 中运行本地 kafka 的快速接收
It`s fast receipt for run local kafka in docker
这篇关于MacOS M1 上的 Docker kafka 问题停留在配置上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
- kafka_m1