Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第三期 作业四:部署 Apache Kafka 多实例集群 #25

Open
mercyblitz opened this issue Aug 11, 2023 · 1 comment
Open

第三期 作业四:部署 Apache Kafka 多实例集群 #25

mercyblitz opened this issue Aug 11, 2023 · 1 comment

Comments

@mercyblitz
Copy link
Owner

要求

  1. 本地部署(物理机和虚拟机均可)
@Kurok1
Copy link
Contributor

Kurok1 commented Aug 18, 2023

本地docker

version: "3"

networks:
  app-kafka:
    driver: host

services:
  zookeeper:
    image: 'bitnami/zookeeper:latest'
    networks:
      -  app-kafka
    ports:
      - '2181:2181'
    environment:
      # 匿名登录--必须开启
      - ALLOW_ANONYMOUS_LOGIN=yes
    volumes:
      - /Volumes/PortableSSD/docker/zookeeper:/bitnami/zookeeper
  kafka1:
    image: 'bitnami/kafka:2.8.0'
    networks:
      - app-kafka
    ports:
      - '9092:9092'
    environment:
      - KAFKA_BROKER_ID=1
      - KAFKA_CFG_LISTENERS=INTERNAL://kafka1:9092
      - KAFKA_CFG_ADVERTISED_LISTENERS=INTERNAL://192.168.1.149:9092
      - KAFKA_CFG_ADVERTISED_HOST_NAME=kafka1
      - KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
      # 允许使用PLAINTEXT协议(镜像中默认为关闭,需要手动开启)
      - ALLOW_PLAINTEXT_LISTENER=yes
      # 关闭自动创建 topic 功能
      - KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE=false
      # 全局消息过期时间 6 小时(测试时可以设置短一点)
      - KAFKA_CFG_LOG_RETENTION_HOURS=6
      - KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT
      - KAFKA_CFG_INTER_BROKER_LISTENER_NAME=INTERNAL
      # 开启JMX监控
    volumes:
      - /Volumes/PortableSSD/docker/kafka1:/bitnami/kafka
    depends_on:
      - zookeeper
  kafka2:
    image: 'bitnami/kafka:2.8.0'
    networks:
      - app-kafka
    ports:
      - '9093:9092'
    environment:
      - KAFKA_BROKER_ID=2
      - KAFKA_CFG_LISTENERS=INTERNAL://kafka2:9093
      # 客户端访问地址,更换成自己的
      - KAFKA_CFG_ADVERTISED_LISTENERS=INTERNAL://192.168.1.149:9093
      - KAFKA_CFG_ADVERTISED_HOST_NAME=kafka2
      - KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
      # 允许使用PLAINTEXT协议(镜像中默认为关闭,需要手动开启)
      - ALLOW_PLAINTEXT_LISTENER=yes
      # 关闭自动创建 topic 功能
      - KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE=false
      # 全局消息过期时间 6 小时(测试时可以设置短一点)
      - KAFKA_CFG_LOG_RETENTION_HOURS=6
      - KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT
      - KAFKA_CFG_INTER_BROKER_LISTENER_NAME=INTERNAL
      # 开启JMX监控
    volumes:
      - /Volumes/PortableSSD/docker/kafka2:/bitnami/kafka
    depends_on:
      - zookeeper
  kafka3:
    image: 'bitnami/kafka:2.8.0'
    networks:
      - app-kafka
    ports:
      - '9094:9092'
    environment:
      - KAFKA_BROKER_ID=3
      - KAFKA_CFG_LISTENERS=INTERNAL://kafka3:9094
      # 客户端访问地址,更换成自己的
      - KAFKA_CFG_ADVERTISED_LISTENERS=INTERNAL://192.168.1.149:9094
      - KAFKA_CFG_ADVERTISED_HOST_NAME=kafka3
      - KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
      # 允许使用PLAINTEXT协议(镜像中默认为关闭,需要手动开启)
      - ALLOW_PLAINTEXT_LISTENER=yes
      # 关闭自动创建 topic 功能
      - KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE=false
      # 全局消息过期时间 6 小时(测试时可以设置短一点)
      - KAFKA_CFG_LOG_RETENTION_HOURS=6
      - KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT
      - KAFKA_CFG_INTER_BROKER_LISTENER_NAME=INTERNAL
      # 开启JMX监控
    volumes:
      - /Volumes/PortableSSD/docker/kafka3:/bitnami/kafka
    depends_on:
      - zookeeper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants