kafka安装运行(docker)
Posted wintersoft
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了kafka安装运行(docker)相关的知识,希望对你有一定的参考价值。
zookeeper参照https://www.cnblogs.com/wintersoft/p/11128484.html
mkdir /opt/kafka -p
vim /opt/kafka/Dockerfile
FROM wurstmeister/kafka:latest EXPOSE 9092
vim /opt/kafka/docker-compose.yml
version: ‘2‘ services: kafka: image: v-kafka container_name: kafka build: context: . dockerfile: Dockerfile restart: always ports: - "9092:9092" environment: KAFKA_ADVERTISED_HOST_NAME: 192.168.0.101 KAFKA_ADVERTISED_PORT: 9092 KAFKA_ZOOKEEPER_CONNECT: "192.168.0.101:2181" volumes: - ./logs:/kafka - ./var/run/docker.sock:/var/run/docker.sock
生成启动
cd /opt/kafka/
docker-compose build
docker-compose up -d --force-recreate
docker-compose down
docker-compose restart
查看日志
docker logs --tail="500" kafka
docker logs -f kafka
进入容器
docker exec -it kafka /bin/bash
伪集群
vim /opt/kafka/docker-compose.yml
version: ‘2‘ services: kafka1: image: wurstmeister/kafka:latest container_name: kafka1 restart: always ports: - 9091:9092 environment: KAFKA_ADVERTISED_HOST_NAME: 192.168.1.101 KAFKA_ADVERTISED_PORT: 9091 KAFKA_ZOOKEEPER_CONNECT: 192.168.0.101:2181,192.168.0.101:2182,192.168.0.101:2183 volumes: - ./kafka1/logs:/kafka - ./kafka1/var/run/docker.sock:/var/run/docker.sock kafka2: image: wurstmeister/kafka:latest container_name: kafka2 restart: always ports: - 9092:9092 environment: KAFKA_ADVERTISED_HOST_NAME: 192.168.1.101 KAFKA_ADVERTISED_PORT: 9092 KAFKA_ZOOKEEPER_CONNECT: 192.168.0.101:2181,192.168.0.101:2182,192.168.0.101:2183 volumes: - ./kafka2/logs:/kafka - ./kafka2/var/run/docker.sock:/var/run/docker.sock kafka3: image: wurstmeister/kafka:latest container_name: kafka3 restart: always ports: - 9093:9092 environment: KAFKA_ADVERTISED_HOST_NAME: 192.168.1.101 KAFKA_ADVERTISED_PORT: 9093 KAFKA_ZOOKEEPER_CONNECT: 192.168.0.101:2181,192.168.0.101:2182,192.168.0.101:2183 volumes: - ./kafka3/logs:/kafka - ./kafka3/var/run/docker.sock:/var/run/docker.sock kafka-manager: image: sheepkiller/kafka-manager container_name: kafka-manager restart: always ports: - 19000:9000 environment: ZK_HOSTS: 192.168.0.101:2181,192.168.0.101:2182,192.168.0.101:2183
以上是关于kafka安装运行(docker)的主要内容,如果未能解决你的问题,请参考以下文章
centos7 docker安装kafka:2.13-2.8.1