Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Using Docker to quickly build Zookeeper and kafka clusters

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Cluster build image selection

Zookeeper and Kafka clusters run in different containers

Zookeeper official image, version 3.4

Kafka uses wurstmeister/kafka image

Cluster planning hostnameIp addrportlistenerzoo1172.19.0.112184:2181zoo2172.19.0.122185:2181zoo3172.19.0.132186:2181kafka1172.19.0.149092:9092kafka1kafka2172.19.0.159093:9093kafka2Kafka3172.19.0.169094:9094Kafka3 host root OSX192.168.21.139 [DHCP acquisition, will change] to achieve the goal

The kafka cluster is available in the docker network and is on the same network as zookeeper

Host can access broker list of zookeeper cluster and kafka

Cluster restarts automatically when docker restarts

The data files of the cluster are mapped to the host machine directory

Create or rebuild a cluster using the yml file and the $docker-compose up-d command

Docker-compose.ymlversion of $docker-compose up-dzk cluster: '3.4'services: zoo1: image: zookeeper restart: always hostname: zoo1 container_name: zoo1 ports:-2184 volumes:-"/ Users/shaozhipeng/Development/volume/zkcluster/zoo1/data:/data"-"/ Users/shaozhipeng/Development/volume/zkcluster/zoo1/datalog:/datalog" environment: ZOO_MY_ID: 1 ZOO_SERVERS: server.1=0.0.0.0:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888 networks: br17219: ipv4_address: 172.19.0.11 zoo2: image: zookeeper restart: always hostname: zoo2 container_name: zoo2 ports:-2185 volumes:-"/ Users/shaozhipeng/Development/volume/zkcluster/zoo2/data:/data"-"/ Users/shaozhipeng/ Development/volume/zkcluster/zoo2/datalog:/datalog "environment: ZOO_MY_ID: 2 ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=0.0.0.0:2888:3888 server.3=zoo3:2888:3888 networks: br17219: ipv4_address: 172.19.0.12 zoo3: image: zookeeper restart: always hostname: zoo3 container_name: zoo3 ports:-2186 zoo3 container_name volumes:- "/ Users/shaozhipeng/Development/volume/zkcluster/zoo3/data:/data"-"/ Users/shaozhipeng/Development/volume/zkcluster/zoo3/datalog:/datalog" environment: ZOO_MY_ID: 3 ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=0.0.0.0:2888:3888 networks: br17219: ipv4_address: 172.19.0.13networks: br17219: external: Name: docker-compose.yml of the br17219kafka cluster

Kfkluster misspelled a c...

Version: '2'services: kafka1: image: wurstmeister/kafka restart: always hostname: kafka1 container_name: kafka1 ports:-9092 environment: KAFKA_ADVERTISED_HOST_NAME: kafka1 KAFKA_ADVERTISED_PORT: 9092 KAFKA_ZOOKEEPER_CONNECT: zoo1:2181,zoo2:2181 Zoo3:2181 volumes:-/ Users/shaozhipeng/Development/volume/kfkluster/kafka1/logs:/kafka external_links:-zoo1-zoo2-zoo3 networks: br17219: ipv4_address: 172.19.0.14 kafka2: image: wurstmeister/kafka restart: always hostname: kafka2 container_name: kafka2 ports:-9093 kafka2 container_name environment: KAFKA_ADVERTISED_HOST_NAME: kafka2 KAFKA_ADVERTISED_ PORT: 9093 KAFKA_ZOOKEEPER_CONNECT: zoo1:2181 Zoo2:2181 Zoo3:2181 volumes:-/ Users/shaozhipeng/Development/volume/kfkluster/kafka2/logs:/kafka external_links:-zoo1-zoo2-zoo3 networks: br17219: ipv4_address: 172.19.0.15 kafka3: image: wurstmeister/kafka restart: always hostname: kafka3 container_name: kafka3 ports:-9094 environment: KAFKA_ADVERTISED_HOST_NAME: kafka3 KAFKA_ADVERTISED_ PORT: 9094 KAFKA_ZOOKEEPER_CONNECT: zoo1:2181 Zoo2:2181 Zoo3:2181 volumes:-/ Users/shaozhipeng/Development/volume/kfkluster/kafka3/logs:/kafka external_links:-zoo1-zoo2-zoo3 networks: br17219: ipv4_address: 172.19.0.16networks: br17219: name: br17219 result View and Test Host Command Line create topic$ pwd/Users/shaozhipeng/Development/kafka_2.11-2.0.0 bind $. / Kafka-topics.sh-create-zookeeper localhost:2184 Localhost:2185,localhost:2186-- replication-factor 1-- partitions 1-- topic test1Kafka Tool view

Docker ps view the container that is running

Check the host IP address and set Host

So the host can access the kafka cluster.

Original address

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report