Start 3 zk nodes

pull/135/head
Baohua Yang 2020-01-30 15:26:40 -08:00
parent 1a1ee63dbb
commit 61eb371d15
2 changed files with 64 additions and 12 deletions

18
kafka/Makefile 100644
View File

@ -0,0 +1,18 @@
download:
docker pull yeasy/kafka:latest
start:
docker-compose up
stop:
docker-compose down
restart: stop start
zookeeper:
docker exec -it zookeeper1 bash
kafka:
docker exec -it kafka1 bash
cli:
docker exec -it cli bash

View File

@ -1,19 +1,47 @@
# The minimal kafka service # The minimal kafka service
# github.com/yeasy/docker-compose-files # github.com/yeasy/docker-compose-files
# * zk: zk node for kafka # * zk: zk node for kafka, 0, 1, 2
# * kafka: kafka service, will default to connect to zookeeper # * kafka: kafka service, will default to connect to zookeeper
# * cli: client to test kafka service # * cli: client to test kafka service
version: '2' version: '2'
services: services:
zookeeper: zookeeper1:
image: yeasy/kafka:latest image: yeasy/kafka:latest
container_name: zookeeper container_name: zookeeper1
hostname: zookeeper hostname: zookeeper1
ports:
- "2182:2181" # zk connection port
environment:
- ZK_ID=1 # when bootup, will read this and update the /tmp/zookeeper/myid file
volumes:
- ${PWD}/zookeeper1:/tmp/zookeeper
command: bash -c 'bash /tmp/start_zk.sh'
zookeeper2:
image: yeasy/kafka:latest
container_name: zookeeper2
hostname: zookeeper2
ports:
- "2183:2181" # zk connection port
environment:
- ZK_ID=2 # when bootup, will read this and update the /tmp/zookeeper/myid file
volumes:
- ${PWD}/zookeeper2:/tmp/zookeeper
command: bash -c 'bash /tmp/start_zk.sh'
zookeeper3:
image: yeasy/kafka:latest
container_name: zookeeper3
hostname: zookeeper3
ports: ports:
- "2181:2181" # zk connection port - "2181:2181" # zk connection port
environment:
- ZK_ID=3 # when bootup, will read this and update the /tmp/zookeeper/myid file
volumes:
- ${PWD}/zookeeper3:/tmp/zookeeper
command: bash -c 'bash /tmp/start_zk.sh' command: bash -c 'bash /tmp/start_zk.sh'
kafka0: # kafka service kafka0: # kafka service
@ -25,8 +53,10 @@ services:
environment: environment:
- KAFKA_BROKER_ID=0 # when bootup, will read this and update the server.properties - KAFKA_BROKER_ID=0 # when bootup, will read this and update the server.properties
depends_on: depends_on:
- zookeeper - zookeeper3
command: bash -c 'bash /tmp/start_kafka.sh' - zookeeper1
- zookeeper2
command: bash -c 'sleep 2; bash /tmp/start_kafka.sh'
kafka1: # kafka service kafka1: # kafka service
image: yeasy/kafka:latest image: yeasy/kafka:latest
@ -37,8 +67,10 @@ services:
environment: environment:
- KAFKA_BROKER_ID=1 # when bootup, will read this and update the server.properties - KAFKA_BROKER_ID=1 # when bootup, will read this and update the server.properties
depends_on: depends_on:
- zookeeper - zookeeper1
command: bash -c 'bash /tmp/start_kafka.sh' - zookeeper2
- zookeeper3
command: bash -c 'sleep 2; bash /tmp/start_kafka.sh'
kafka2: # kafka service kafka2: # kafka service
image: yeasy/kafka:latest image: yeasy/kafka:latest
@ -49,14 +81,16 @@ services:
environment: environment:
- KAFKA_BROKER_ID=2 # when bootup, will read this and update the server.properties - KAFKA_BROKER_ID=2 # when bootup, will read this and update the server.properties
depends_on: depends_on:
- zookeeper - zookeeper3
command: bash -c 'bash /tmp/start_kafka.sh' - zookeeper1
- zookeeper2
command: bash -c 'sleep 2; bash /tmp/start_kafka.sh'
cli: # used for testing kafka cmds, see /tmp/*.sh cli: # used for testing kafka cmds, see /tmp/*.sh
image: yeasy/kafka:latest image: yeasy/kafka:latest
container_name: cli container_name: cli
hostname: cli hostname: cli
environment: environment:
- ZK_HOST=zookeeper # zk host to connect to - ZK_HOST=zookeeper1 # zk host to connect to
- KAFKA_HOST=kafka1 # customized the kafka broker to send - KAFKA_HOST=kafka0 # customized the kafka broker to send
command: bash -c 'while true; do sleep 20200116; done' command: bash -c 'while true; do sleep 20200116; done'