如下给出使用docker快速搭建一个kafka集群的方法,使用 docker compose up docker-compose.yml即可启动启动一个kafka集群。
注意将192.168.50.112换成你自己docker宿主机的ip。
docker-compose.yml如下:
version: '3' services: zookeeper: image: 'bitnami/zookeeper:3.7' ports: - '2190:2181' environment: - ZOO_ENABLE_AUTH=yes - ZOO_SERVER_USERS=zoo - ZOO_SERVER_PASSWORDS=zoo - ZOO_CLIENT_USER=zoo - ZOO_CLIENT_PASSWORD=zoo kafka1: depends_on: - zookeeper image: 'bitnami/kafka:2.6.0' ports: - '19092:9093' environment: - KAFKA_BROKER_ID=1 - KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=INTERNAL:PLAINTEXT,CLIENT:PLAINTEXT - KAFKA_CFG_LISTENERS=INTERNAL://kafka1:9092,CLIENT://kafka1:9093 - KAFKA_CFG_ADVERTISED_LISTENERS=INTERNAL://kafka1:9092,CLIENT://192.168.50.112:19092 - KAFKA_CFG_INTER_BROKER_LISTENER_NAME=INTERNAL - KAFKA_CLIENT_USER=kafka - KAFKA_CLIENT_PASSWORD=kafka - ALLOW_PLAINTEXT_LISTENER=yes # - KAFKA_INTER_BROKER_USER=kafka # - KAFKA_INTER_BROKER_PASSWORD=kafka - KAFKA_CFG_ZOOKEEPER_ConNECT=zookeeper:2181 - KAFKA_ZOOKEEPER_PROTOCOL=SASL - KAFKA_ZOOKEEPER_USER=zoo - KAFKA_ZOOKEEPER_PASSWORD=zoo kafka2: depends_on: - zookeeper image: 'bitnami/kafka:2.6.0' ports: - '19093:9093' environment: - KAFKA_BROKER_ID=2 - KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=INTERNAL:PLAINTEXT,CLIENT:PLAINTEXT - KAFKA_CFG_LISTENERS=INTERNAL://kafka2:9092,CLIENT://kafka2:9093 - KAFKA_CFG_ADVERTISED_LISTENERS=INTERNAL://kafka2:9092,CLIENT://192.168.50.112:19093 - KAFKA_CFG_INTER_BROKER_LISTENER_NAME=INTERNAL - KAFKA_CLIENT_USER=kafka - KAFKA_CLIENT_PASSWORD=kafka - ALLOW_PLAINTEXT_LISTENER=yes # - KAFKA_INTER_BROKER_USER=kafka # - KAFKA_INTER_BROKER_PASSWORD=kafka - KAFKA_CFG_ZOOKEEPER_ConNECT=zookeeper:2181 - KAFKA_ZOOKEEPER_PROTOCOL=SASL - KAFKA_ZOOKEEPER_USER=zoo - KAFKA_ZOOKEEPER_PASSWORD=zoo kafka3: depends_on: - zookeeper image: 'bitnami/kafka:2.6.0' ports: - '19094:9093' environment: - KAFKA_BROKER_ID=3 - KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=INTERNAL:PLAINTEXT,CLIENT:PLAINTEXT - KAFKA_CFG_LISTENERS=INTERNAL://kafka3:9092,CLIENT://kafka3:9093 - KAFKA_CFG_ADVERTISED_LISTENERS=INTERNAL://kafka3:9092,CLIENT://192.168.50.112:19094 - KAFKA_CFG_INTER_BROKER_LISTENER_NAME=INTERNAL - KAFKA_CLIENT_USER=kafka - KAFKA_CLIENT_PASSWORD=kafka - ALLOW_PLAINTEXT_LISTENER=yes # - KAFKA_INTER_BROKER_USER=kafka # - KAFKA_INTER_BROKER_PASSWORD=kafka - KAFKA_CFG_ZOOKEEPER_ConNECT=zookeeper:2181 - KAFKA_ZOOKEEPER_PROTOCOL=SASL - KAFKA_ZOOKEEPER_USER=zoo - KAFKA_ZOOKEEPER_PASSWORD=zoo
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)