启动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