当前位置:   article > 正文

docker-compose部署 kafka 3.7 集群(3台服务器)并启用账号密码认证_docker compose三节点raft kafka

docker compose三节点raft kafka

1. 规划

服务IP
kafka-0110.10.xxx.199
kafka-0210.10.xxx.198
kafka-0310.10.xxx.197
kafkamp10.10.xxx.199

2. 服务部署

2.1 kafka-01

  • 登录10.10.xxx.199,创建目录 kafka-01,进入该目录
  • 目录下创建docker-compose.yml 文件
version: "3"
services:
   kafka:
     image: 'bitnami/kafka:3.7.0'
     user: root
     ports:
       - '9092:9092'
       - '9093:9093'
     environment:
       - TZ=Asia/Shanghai
       - KAFKA_CFG_PROCESS_ROLES=broker,controller
       - BITNAMI_DEBUG=true 
       - ALLOW_PLAINTEXT_LISTENER=no
       - KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER
       - KAFKA_CFG_NUM_PARTITIONS=1
       - KAFKA_CFG_LISTENERS=INTERNAL://:9094,CLIENT://:9095,CONTROLLER://0.0.0.0:9093,EXTERNAL://0.0.0.0:9092
       - KAFKA_CFG_ADVERTISED_LISTENERS=INTERNAL://10.10.181.199:9094,CLIENT://:9095,EXTERNAL://10.10.181.199:9092
       - KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=INTERNAL:SASL_PLAINTEXT,CLIENT:SASL_PLAINTEXT,CONTROLLER:PLAINTEXT,EXTERNAL:SASL_PLAINTEXT   
       - KAFKA_CFG_INTER_BROKER_LISTENER_NAME=INTERNAL
       - KAFKA_CFG_SASL_MECHANISM_INTER_BROKER_PROTOCOL=PLAIN
       - KAFKA_CFG_SASL_ENABLED_MECHANISMS=PLAIN
       - KAFKA_CLIENT_USERS=liubei
       - KAFKA_CLIENT_PASSWORDS=liubei@161
       - KAFKA_INTER_BROKER_USER=liuwei
       - KAFKA_INTER_BROKER_PASSWORD=liubei@161
       - KAFKA_CFG_NODE_ID=1
       - KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=1@10.10.181.199:9093,2@10.10.181.198:9093,3@10.10.181.197:9093
       - KAFKA_KRAFT_CLUSTER_ID=xishu
       - KAFKA_OPTS=-Djava.security.auth.login.config=/bitnami/kafka/data/kafka_server_jaas.conf
     volumes:
       - ./data:/bitnami/kafka/data:rw
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

2.2 kafka-02

  • 登录10.10.xxx.198,创建目录 kafka-02,进入该目录
  • 目录下创建docker-compose.yml 文件
version: "3"
services:
   kafka:
     image: bitnami/kafka:3.7.0'
     user: root
     ports:
       - '9092:9092'
       - '9093:9093'
     environment:
       - TZ=Asia/Shanghai
       - KAFKA_CFG_PROCESS_ROLES=broker,controller
       - BITNAMI_DEBUG=true 
       - ALLOW_PLAINTEXT_LISTENER=no
       - KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER
       - KAFKA_CFG_NUM_PARTITIONS=1
       - KAFKA_CFG_LISTENERS=INTERNAL://:9094,CLIENT://:9095,CONTROLLER://0.0.0.0:9093,EXTERNAL://0.0.0.0:9092
       - KAFKA_CFG_ADVERTISED_LISTENERS=INTERNAL://10.10.181.198:9094,CLIENT://:9095,EXTERNAL://10.10.181.198:9092
       - KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=INTERNAL:SASL_PLAINTEXT,CLIENT:SASL_PLAINTEXT,CONTROLLER:PLAINTEXT,EXTERNAL:SASL_PLAINTEXT   
       - KAFKA_CFG_INTER_BROKER_LISTENER_NAME=INTERNAL
       - KAFKA_CFG_SASL_MECHANISM_INTER_BROKER_PROTOCOL=PLAIN
       - KAFKA_CFG_SASL_ENABLED_MECHANISMS=PLAIN
       - KAFKA_CLIENT_USERS=liubei
       - KAFKA_CLIENT_PASSWORDS=liubei@161
       - KAFKA_INTER_BROKER_USER=liuwei
       - KAFKA_INTER_BROKER_PASSWORD=liubei@161
       - KAFKA_CFG_NODE_ID=2
       - KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=1@10.10.181.199:9093,2@10.10.181.198:9093,3@10.10.181.197:9093
       - KAFKA_KRAFT_CLUSTER_ID=xishu
       - KAFKA_OPTS=-Djava.security.auth.login.config=/bitnami/kafka/data/kafka_server_jaas.conf
     volumes:
       - ./data:/bitnami/kafka/data:rw
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

2.3 kafka-03

  • 登录10.10.xxx.197,创建目录 kafka-03,进入该目录
  • 目录下创建docker-compose.yml 文件
version: "3"
services:
   kafka:
     image: bitnami/kafka:3.7.0'
     user: root
     ports:
       - '9092:9092'
       - '9093:9093'
     environment:
       - TZ=Asia/Shanghai
       - KAFKA_CFG_PROCESS_ROLES=broker,controller
       - BITNAMI_DEBUG=true 
       - ALLOW_PLAINTEXT_LISTENER=no
       - KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER
       - KAFKA_CFG_NUM_PARTITIONS=1
       - KAFKA_CFG_LISTENERS=INTERNAL://:9094,CLIENT://:9095,CONTROLLER://0.0.0.0:9093,EXTERNAL://0.0.0.0:9092
       - KAFKA_CFG_ADVERTISED_LISTENERS=INTERNAL://10.10.181.197:9094,CLIENT://:9095,EXTERNAL://10.10.181.197:9092
       - KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=INTERNAL:SASL_PLAINTEXT,CLIENT:SASL_PLAINTEXT,CONTROLLER:PLAINTEXT,EXTERNAL:SASL_PLAINTEXT   
       - KAFKA_CFG_INTER_BROKER_LISTENER_NAME=INTERNAL
       - KAFKA_CFG_SASL_MECHANISM_INTER_BROKER_PROTOCOL=PLAIN
       - KAFKA_CFG_SASL_ENABLED_MECHANISMS=PLAIN
       - KAFKA_CLIENT_USERS=liubei
       - KAFKA_CLIENT_PASSWORDS=liubei@161
       - KAFKA_INTER_BROKER_USER=liuwei
       - KAFKA_INTER_BROKER_PASSWORD=liubei@161
       - KAFKA_CFG_NODE_ID=2
       - KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=1@10.10.181.199:9093,2@10.10.181.198:9093,3@10.10.181.197:9093
       - KAFKA_KRAFT_CLUSTER_ID=xishu
       - KAFKA_OPTS=-Djava.security.auth.login.config=/bitnami/kafka/data/kafka_server_jaas.conf
     volumes:
       - ./data:/bitnami/kafka/data:rw
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

2.4 启动服务

  • 每台服务器上执行
docker-compose up -d
  • 1

3. 测试

3.1 kafkamap搭建(测试工具)

  • 登录10.10.xxx.199,创建kafkamap目录,进入该目录
  • 创建docker-compose.yml文件如下
version: "3"
services:
   kafka_map:
     image: dushixiang/kafka-map:latest
     environment:
       - DEFAULT_USERNAME=liubei
       - DEFAULT_PASSWORD=liubei@161
     ports:
       - '8080:8080'

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

3.2 测试

  • 连接集群
    在这里插入图片描述
  • 连接成功
    在这里插入图片描述
  • 进入topic
    在这里插入图片描述
  • 创建topic
    在这里插入图片描述

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小舞很执着/article/detail/823180
推荐阅读
相关标签
  

闽ICP备14008679号