当前位置:   article > 正文

docker-compose安装部署kafka_docker-compose安装kafka

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
  • 1

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

链接: docker-compose安装

docker pull bitnami/zookeeper:3.6
docker pull bitnami/kafka:3.0
docker pull hlebalbau/kafka-manager
  • 1
  • 2
  • 3

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
  • 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
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76

2.执行部署

代码如下(示例):

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

三、登陆页面

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

http://192.168.150.23:9009/

在这里插入图片描述

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

闽ICP备14008679号