环境安装docker安装yum updateyum 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.mdkafka: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/kafkadepends_on:- zookeeper# Web 管理界面 另外也可以用exporter+prometheus+grafana的方式来监控 https://github.com/danielqsj/kafka_exporterkafka_manager:image: 'hlebalbau/kafka-manager:latest'ports:- "9000:9000"environment:ZK_HOSTS: "zookeeper:2181"APPLICATION_SECRET: letmeindepends_on:- zookeeper- kafka
集群版version: '3.8'services:zookeeper:image: 'bitnami/zookeeper:latest'ports:- '2181:2181'environment:# 匿名登录--必须开启- ALLOW_ANONYMOUS_LOGIN=yes#volumes:#- ./zookeeper:/bitnami/zookeeperkafka1:image: wurstmeister/kafkarestart: alwayscontainer_name: kafka1ports:- "9092:9092"- "9977:9977"environment:KAFKA_BROKER_ID: 1KAFKA_ADVERTISED_HOST_NAME: kafka1KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://127.0.0.1:9092KAFKA_ADVERTISED_PORT: 9092KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181JMX_HOSTNAME : 127.0.0.1JMX_PORT: 9977KAFKA_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:- zookeeperkafka2:image: wurstmeister/kafkarestart: alwayscontainer_name: kafka2ports:- "9093:9093"- "9988:9988"environment:KAFKA_BROKER_ID: 2KAFKA_ADVERTISED_HOST_NAME: kafka2KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9093KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://127.0.0.1:9093KAFKA_ADVERTISED_PORT: 9093KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181JMX_HOSTNAME : 127.0.0.1JMX_PORT: 9988KAFKA_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:- zookeeperkafka3:image: wurstmeister/kafkarestart: alwayscontainer_name: kafka3ports:- "9094:9094"- "9999:9999"environment:KAFKA_BROKER_ID: 3KAFKA_ADVERTISED_HOST_NAME: kafka3KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9094KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://127.0.0.1:9094KAFKA_ADVERTISED_PORT: 9094KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181JMX_HOSTNAME : 127.0.0.1JMX_PORT: 9999KAFKA_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管理工具:
【Docker搭建kafka及监控】https://github.com/didi/KnowStreaming/blob/master/docs/install_guide/单机部署手册.md
初始账户 和 密码 admin
具体访问代码demo:https://github.com/HappyTeemo7569/kafka_demo
有问题欢迎留言哦
推荐阅读
- Docker容器获取宿主机信息
- 我的 Kafka 旅程 - Consumer
- 制作一个网站的费用是多少 搭建网站的收费明细
- 如何创建一个网址 搭建网站的基本流程
- 河南网站建设多少钱 搭建网站的费用标准
- 网页制作教程步骤 超详细的网站搭建技巧
- 个人网站设计制作步骤有哪些 搭建网站的详细教程
- 怎么制作一个网页页面 搭建网站的基本流程
- 创建企业网站需要做什么 教你搭建网站的详细步骤
- 网页制作流程具体步骤是什么 搭建网站的详细教程