0


docker-compose安装部署kafka

文章目录


前言

记录一下使用docker-compose部署kafka平台的过程
参考:https://blog.csdn.net/QQ83512272/article/details/126368978


一、环境信息

  • 操作系统版本:CentOS Linux release 7.9.2009 (Core)
  • docker服务版本:Docker version 20.10.21
  • docker-compose版本:docker-compose version 1.26.2
  • 服务镜像版本:bitnami/zookeeper:3.6、bitnami/kafka:3.0、hlebalbau/kafka-manager
  • IP信息:172.16.150.23
  • 路径准备:/data/kafka/
  • 端口准备:zookeeper:2181、kafka1:9092、kafka2:9093、kafka3:9094、kafka_manager:9009

二、准备部署

1.准备路径

mkdir-p /data/kafka

2.安装docker-compse,下载镜像

链接: docker-compose安装

docker pull bitnami/zookeeper:3.6
docker pull bitnami/kafka:3.0
docker pull hlebalbau/kafka-manager

3.生成yml文件

按照自己环境信息,修改配置文件的IP信息

  • KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://192.168.150.23:9092
  • KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://192.168.150.23:9093
  • KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://192.168.150.23:9094
cat<<EOF>  /data/kafka/kafka.yml 
version: "3"
 
services:
  zookeeper:
    image: 'bitnami/zookeeper:3.6'
    container_name: zookeeper
    ports:
      - '2181:2181'
    environment:
      # 匿名登录--必须开启
      - ALLOW_ANONYMOUS_LOGIN=yes
    #volumes:
      #- ./zookeeper:/bitnami/zookeeper
    # restart: always
 
  kafka1:
    image: 'bitnami/kafka:3.0'
    container_name: kafka1
    ports:
      - '9092:9092'
    environment:
      - KAFKA_BROKER_ID=1
      - KAFKA_CFG_LISTENERS=PLAINTEXT://:9092
      - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://192.168.150.23:9092
      - KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
      - ALLOW_PLAINTEXT_LISTENER=yes
    # restart: always
    depends_on:
      - zookeeper
 
  kafka2:
    image: 'bitnami/kafka:3.0'
    container_name: kafka2
    ports:
      - '9093:9093'
    environment:
      - KAFKA_BROKER_ID=2
      - KAFKA_CFG_LISTENERS=PLAINTEXT://:9093
      - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://192.168.150.23:9093
      - KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
      - ALLOW_PLAINTEXT_LISTENER=yes
    # restart: always
    depends_on:
      - zookeeper
 
  kafka3:
    image: 'bitnami/kafka:3.0'
    container_name: kafka3
    ports:
      - '9094:9094'
    environment:
      - KAFKA_BROKER_ID=3
      - KAFKA_CFG_LISTENERS=PLAINTEXT://:9094
      - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://192.168.150.23:9094
      - KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
      - ALLOW_PLAINTEXT_LISTENER=yes
    # restart: always
    depends_on:
      - zookeeper
 
  # Web 管理界面 另外也可以用exporter+prometheus+grafana的方式来监控 https://github.com/danielqsj/kafka_exporter
  kafka_manager:
    image: 'hlebalbau/kafka-manager:latest'
    container_name: kafka-manager
    ports:
      - "9009:9000"
    environment:
      ZK_HOSTS: "zookeeper:2181"
    # restart: always
    depends_on:
      - zookeeper
      - kafka1
      - kafka2
      - kafka3
EOF

2.执行部署

代码如下(示例):

cd /data/kafka/
docker-compose-f kafka.yml up -d

三、登陆页面

使用ip+port登陆,我的是下面的地址

http://192.168.150.23:9009/

在这里插入图片描述


本文转载自: https://blog.csdn.net/baidu_35848778/article/details/128340002
版权归原作者 大新新大浩浩 所有, 如有侵权,请联系我们删除。

“docker-compose安装部署kafka”的评论:

还没有评论