首页 > 其他分享 >Docker搭建kafka及监控

Docker搭建kafka及监控

时间:2022-09-29 09:45:28浏览次数:84  
标签:management zookeeper KAFKA Dcom Docker kafka docker 搭建

环境安装

docker安装

yum update
yum install docker

# 启动
systemctl start docker
# 加入开机启动
systemctl enable docker

# 检查是否启动
docker version

# 测试一下
docker run hello-world

docker-compose安装

# 第一步 下载二进制文件到/usr/local/bin/位置
curl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

# 下载慢就用这个
curl -L https://get.daocloud.io/docker/compose/releases/download/v2.11.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose


# 第二步 赋予可执行权限
chmod +x /usr/local/bin/docker-compose

# 查看版本号
docker-compose version

kafka安装

单机版

version: "3"
services:
  zookeeper:
    image: 'bitnami/zookeeper:latest'
    ports:
      - '2181:2181'
    environment:
      # 匿名登录--必须开启
      - ALLOW_ANONYMOUS_LOGIN=yes
    #volumes:
      #- ./zookeeper:/bitnami/zookeeper
  # 该镜像具体配置参考 https://github.com/bitnami/bitnami-docker-kafka/blob/master/README.md
  kafka:
    image: 'bitnami/kafka:2.8.0'
    ports:
      - '9092:9092'
      - '9999:9999'
    environment:
      - KAFKA_BROKER_ID=1
      - KAFKA_CFG_LISTENERS=PLAINTEXT://:9092
      # 客户端访问地址,更换成自己的主机IP (如果要外网访问就是服务器IP)
      - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://127.0.0.1:9092
      - 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
      # 开启JMX监控
      - JMX_PORT=9999
    #volumes:
      #- ./kafka:/bitnami/kafka
    depends_on:
      - zookeeper
  # Web 管理界面 (用KnowStreaming可以不用下面的)
  kafka_manager:
    image: 'hlebalbau/kafka-manager:latest'
    ports:
      - "9000:9000"
    environment:
      ZK_HOSTS: "zookeeper:2181"
      APPLICATION_SECRET: letmein
    depends_on:
      - zookeeper
      - kafka

集群版

version: '3.8'
services:
  zookeeper:
    image: 'bitnami/zookeeper:latest'
    ports:
      - '2181:2181'
    environment:
      # 匿名登录--必须开启
      - ALLOW_ANONYMOUS_LOGIN=yes
    #volumes:
      #- ./zookeeper:/bitnami/zookeeper
  kafka1:
    image: wurstmeister/kafka
    restart: always
    container_name: kafka1
    ports:
      - "9092:9092"
      - "9977:9977"
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_ADVERTISED_HOST_NAME: kafka1
      KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://127.0.0.1:9092
      KAFKA_ADVERTISED_PORT: 9092
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      JMX_HOSTNAME : 127.0.0.1
      JMX_PORT: 9977
      KAFKA_JMX_OPTS: "-Djava.rmi.server.hostname=127.0.0.1 -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.authenticate=false  -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.rmi.port=9977"
    depends_on:
      - zookeeper

  kafka2:
    image: wurstmeister/kafka
    restart: always
    container_name: kafka2
    ports:
      - "9093:9093"
      - "9988:9988"
    environment:
      KAFKA_BROKER_ID: 2
      KAFKA_ADVERTISED_HOST_NAME: kafka2
      KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9093
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://127.0.0.1:9093
      KAFKA_ADVERTISED_PORT: 9093
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      JMX_HOSTNAME : 127.0.0.1
      JMX_PORT: 9988
      KAFKA_JMX_OPTS: "-Djava.rmi.server.hostname=127.0.0.1 -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.authenticate=false  -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.rmi.port=9988"
    depends_on:
      - zookeeper

  kafka3:
    image: wurstmeister/kafka
    restart: always
    container_name: kafka3
    ports:
      - "9094:9094"
      - "9999:9999"
    environment:
      KAFKA_BROKER_ID: 3
      KAFKA_ADVERTISED_HOST_NAME: kafka3
      KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9094
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://127.0.0.1:9094
      KAFKA_ADVERTISED_PORT: 9094
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      JMX_HOSTNAME : 127.0.0.1
      JMX_PORT: 9999
      KAFKA_JMX_OPTS: "-Djava.rmi.server.hostname=127.0.0.1 -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.authenticate=false  -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.rmi.port=9999"
    depends_on:
      - zookeeper

管理工具 KnowStreaming

管理工具:

https://github.com/didi/KnowStreaming/blob/master/docs/install_guide/单机部署手册.md

初始账户 和 密码 admin

具体访问代码demo:

https://github.com/HappyTeemo7569/kafka_demo

有问题欢迎留言哦

标签:management,zookeeper,KAFKA,Dcom,Docker,kafka,docker,搭建
From: https://www.cnblogs.com/HappyTeemo/p/16740331.html

相关文章

  • Kafka常用命令
    启动Kafka后台常驻方式,带上参数 -daemon,如:/usr/local/kafka/bin/kafka-server-start.sh-daemon/usr/local/kafka/config/server.properties指定JMXport端口启......
  • mysql主从搭建
    mysql主从搭建环境:ubuntu20.04.1,mysql:8.0.22。主:192.168.87.3备:192.168.87.6安装数据库sudoapt-getinstallmysql-serversudoapt-getinstallmysql-clientsud......
  • 【题解】P3225 [HNOI2012]矿场搭建(割点,dfs)
    【题解】P3225[HNOI2012]矿场搭建割点好题!(因为刚开始没想清楚卡了好久/kk)题目链接P3225[HNOI2012]矿场搭建题意概述给定一张\(n\)条边的无向图,现在要求在其中一......
  • Dockerfile centos7_tomcat7.0.64_jdk7u80
    FROMcentos:7MAINTAINERjiangzhehaoWORKDIR/tmpRUNyum-yinstallnet-toolsADDjdk-7u80-linux-x64.tar.gz/usr/local/RUNrm-f/usr/local/jdk-7u80-linux-x64.tar.......
  • 把beef-xss搭建在公网上
    我是la......
  • docker搭建mysql
    下载mysql镜像[root@localhost~]#dockerpullmysql:5.5.59 创建mysql容器[root@localhost~]#dockerrun-itd--namemysql-p3309:3306--restart=always-eMYSQL_......
  • docker 简介和使用总结:image,container,dockfile,nginx,redis,compose
    硬件发展速度:asp.net+sql+redis+nginx:资源利用率太低,多软件工具不能隔离,相互影响,不能快速部署 0.docker简介和使用总结:image,container,dockfile,nginx,redis,compose......
  • 【C语言】Visual Studio 2022开发环境搭建
    1.下载VisualStudio2022VisualStudio的官方网站:​​https://visualstudio.microsoft.com/​​点击下载VisualStudio社区版Community2.安装VisualStudio2022双击Visual......
  • docker 搭建 Telegram Messenger MTP
    dockerhub官方镜像地址如下:​​https://hub.docker.com/r/telegrammessenger/proxy​​ 拉取镜像sudodockerpulltelegrammessenger/proxy 创建容器sudodockerrun-d......
  • Dockerfile centos7_php5.6.36
    Dockerfile:FROMcentos:7MAINTAINERwww.ctnrs.comRUNyuminstallepel-release-y&&\yuminstall-ygccgcc-c++makegd-devellibxml2-devel\libcurl-deve......