docker安装kafka集群
安装zookeeper集群参考:https://blog.csdn.net/qq_38270106/article/details/88789737新建docker的kafka配置文件mkdir -p /usr/local/docker-compose/kafka/{kafka1,kafka2,kafka3}cd /usr/local/docker-compose/kafka...
·
安装zookeeper集群
参考:https://blog.csdn.net/qq_38270106/article/details/88789737
新建docker的kafka配置文件
mkdir -p /usr/local/docker-compose/kafka/{kafka1,kafka2,kafka3}
cd /usr/local/docker-compose/kafka
vi docker-compose.yml
version: '2'
services:
kafka1:
image: wurstmeister/kafka
restart: always
hostname: kafka1
container_name: kafka1
ports:
- "9092:9092"
environment:
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://198.168.128.133:9092
KAFKA_ADVERTISED_HOST_NAME: 198.168.128.133
KAFKA_ADVERTISED_PORT: 9092
KAFKA_ZOOKEEPER_CONNECT: zoo1:2181,zoo2:2181,zoo3:2181
JMX_PORT: 9999
volumes:
- /usr/local/docker-compose/kafka/kafka1:/kafka
external_links: # 连接compose文件以外的container
- zoo1
- zoo2
- zoo3
networks:
default:
ipv4_address: 172.23.0.14
kafka2:
image: wurstmeister/kafka
restart: always
hostname: kafka2
container_name: kafka2
ports:
- "9093:9092"
environment:
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://198.168.128.133:9093
KAFKA_ADVERTISED_HOST_NAME: 198.168.128.133
KAFKA_ADVERTISED_PORT: 9093
KAFKA_ZOOKEEPER_CONNECT: zoo1:2181,zoo2:2181,zoo3:2181
JMX_PORT: 9988
volumes:
- /usr/local/docker-compose/kafka/kafka2:/kafka
external_links: # 连接compose文件以外的container
- zoo1
- zoo2
- zoo3
networks:
default:
ipv4_address: 172.23.0.15
kafka3:
image: wurstmeister/kafka
restart: always
hostname: kafka3
container_name: kafka3
ports:
- "9094:9092"
environment:
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://198.168.128.133:9094
KAFKA_ADVERTISED_HOST_NAME: 198.168.128.133
KAFKA_ADVERTISED_PORT: 9094
KAFKA_ZOOKEEPER_CONNECT: zoo1:2181,zoo2:2181,zoo3:2181
JMX_PORT: 9977
volumes:
- /usr/local/docker-compose/kafka/kafka3
external_links: # 连接compose文件以外的container
- zoo1
- zoo2
- zoo3
networks:
default:
ipv4_address: 172.23.0.16
kafka-manager:
image: sheepkiller/kafka-manager:latest
restart: always
container_name: kafa-manager
hostname: kafka-manager
ports:
- "9002:9000"
links: # 连接本compose文件创建的container
- kafka1
- kafka2
- kafka3
external_links: # 连接compose文件以外的container
- zoo1
- zoo2
- zoo3
environment:
ZK_HOSTS: zoo1:2181,zoo2:2181,zoo3:2181
KAFKA_BROKERS: kafka1:9092,kafka2:9093,kafka3:9094
APPLICATION_SECRET: letmein
KM_ARGS: -Djava.net.preferIPv4Stack=true
networks:
default:
ipv4_address: 172.23.0.10
networks:
default:
external: # 使用已创建的网络
name: zookeeper_network
启动集群,在 docker-compose.yml 目录下运行
docker-compose up -d
更多推荐
已为社区贡献2条内容
所有评论(0)