yahoo/kafka-manager 容器化实践

7 篇文章 0 订阅
1 篇文章 0 订阅

启动kafka集群

version: '2'

services:
  zookeeper:
    image: wurstmeister/zookeeper
    container_name: common-zookeeper
    restart: always
    volumes:
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
      - ./data/zookeeper/data:/opt/zookeeper-3.4.9/data
    ports:
      - "2181:2181"
    networks:
      default:
        aliases:
          - zookeeper.host
  kafka:
    image: wurstmeister/kafka
    container_name: common-kafka
    restart: always
    environment:
      KAFKA_ADVERTISED_HOST_NAME: 192.168.1.130
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_LOG_DIRS: "/kafka/kafka-logs"
      // 启动JMX监控
      KAFKA_JMX_OPTS: "-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=common-kafka -Dcom.sun.management.jmxremote.rmi.port=1099"
      JMX_PORT: 10000
    volumes:
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock
      - ./data/kafka/data:/kafka/kafka-logs
    ports:
      - "9092:9092"
      - "10000:1099"
    networks:
      default:
        aliases:
          - kafka.host
  kafka2:
    image: wurstmeister/kafka
    container_name: common-kafka2
    restart: always
    environment:
      KAFKA_ADVERTISED_HOST_NAME: 192.168.1.130
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_LOG_DIRS: "/kafka/kafka-logs"
      KAFKA_JMX_OPTS: "-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=common-kafka -Dcom.sun.management.jmxremote.rmi.port=1099"
      JMX_PORT: 10001
    volumes:
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock
      - ./data/kafka/data2:/kafka/kafka-logs
    ports:
      - "9093:9092"
      - "10001:1099"
    networks:
      default:
        aliases:
          - kafka.host2
  kafka3:
    image: wurstmeister/kafka
    container_name: common-kafka3
    restart: always
    environment:
      KAFKA_ADVERTISED_HOST_NAME: 192.168.1.130
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_LOG_DIRS: "/kafka/kafka-logs"
      KAFKA_JMX_OPTS: "-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=common-kafka -Dcom.sun.management.jmxremote.rmi.port=1099"
      JMX_PORT: 10002
    volumes:
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock
      - ./data/kafka/data3:/kafka/kafka-logs
    ports:
      - "9094:9092"
      - "10002:1099"
    networks:
      default:
        aliases:
          - kafka.host3
networks:
  default:
   external:
     name: default_network

打包最新kafka-manager容器

FROM centos:7

MAINTAINER Clement Laforet <sheepkiller@cultdeadsheep.org>

RUN yum update -y && \
    yum install -y java-1.8.0-openjdk-headless && \
    yum clean all

ENV JAVA_HOME=/usr/java/default/ \
    ZK_HOSTS=localhost:2181 \
    KM_VERSION=1.3.3.22 \
    KM_REVISION=04b585eddd81768b03b6989efcfb5032307a1888\
    KM_CONFIGFILE="conf/application.conf"

ADD start-kafka-manager.sh /kafka-manager-${KM_VERSION}/start-kafka-manager.sh

RUN yum install -y java-1.8.0-openjdk-devel git wget unzip which && \
    mkdir -p /tmp 

COPY ./kafka-manager-${KM_VERSION}.zip /tmp/kafka-manager-${KM_VERSION}.zip

RUN unzip  -d / /tmp/kafka-manager-${KM_VERSION}.zip && \
    rm -fr /tmp/* /root/.sbt /root/.ivy2 && \
    chmod +x /kafka-manager-${KM_VERSION}/start-kafka-manager.sh && \
    yum autoremove -y java-1.8.0-openjdk-devel git wget unzip which && \
    yum clean all

WORKDIR /kafka-manager-${KM_VERSION}

EXPOSE 9000
ENTRYPOINT ["./start-kafka-manager.sh"]

启动kafka-manager容器

version: '2'
services:
  kafka-manager:
    image: kafka-manager:latest
    container_name: km
    ports:
      - "9000:9000"
    environment:
      ZK_HOSTS: zookeeper.host:2181
      APPLICATION_SECRET: letmein
      KM_ARGS: -Djava.net.preferIPv4Stack=true
networks:
  default:
   external:
     name: default_network
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值