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

How are kafka and zookeeper installed

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Editor to share with you how to install kafka and zookeeper, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Kafka and zookeeper installation

Write compose

Zookeeper: image: wurstmeister/zookeeper ports:-"2181 kafka: image: wurstmeister/kafka volumes: -. / data/etc/localtime:/etc/localtime -. / data/var/run/docker.sock:/var/run/docker.sock ports: -" 9092 kafka: KAFKA_ADVERTISED_HOST_NAME: 192.168.110.147 # # Host Machine IP KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 KAFKA_ADVERTISED_PORT: 9092 kafka-manager: image: sheepkiller/kafka-manager environment: ZK_HOSTS: 192.168.110.147 # # zookeeper address ports:-"9091 kafka-manager 9000" # host port:container_port

Start installation

Luwei@luweideMacBook-Pro-2 lnmp% docker-compose up-d zookeeperPulling zookeeper (wurstmeister/zookeeper:)... latest: Pulling from wurstmeister/zookeepera3ed95caeb02: Pull completeef38b711a50f: Pull completee057c74597c7: Pull complete666c214f6385: Pull completec3d6a96f1ffc: Pull complete3fe26a83e0ca: Pull complete3d3a7dd3a3b1: Pull completef8cc938abe5f: Pull complete9978b75f7a58: Pull complete4d4dbcc8f8cc: Pull complete8b130a9baa49: Pull complete6b9611650a73: Pull complete5df5aac51927: Pull complete76eea4448d9b: Pull complete8b66990876c6: Pull completef0dd38204b6f: Pull completeDigest: sha256:7a7fd44a72104bfbd24a77844bad5fabc86485b036f988ea927d1780782a6680Status: Downloaded newer image for wurstmeister/zookeeper:latestCreating lnmp_zookeeper_1... Doneluwei@luweideMacBook-Pro-2 lnmp docker-compose up- d kafkalnmp_kafka_1 is up-to-dateluwei@luweideMacBook-Pro-2 lnmp docker-compose up- d kafka Starting lnmp_kafka_1... Done

View installation results

Luwei@luweideMacBook-Pro-2 ~% docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES28a2a3b33856 sheepkiller/kafka-manager ". / start-kafka-manag..." 3 minutes ago Up 3 minutes 0.0.0.0 9000/tcp lnmp_kafka-manager_1d6ae300116f3 wurstmeister/zookeeper 9091-> 9000/tcp lnmp_kafka-manager_1d6ae300116f3 wurstmeister/zookeeper "/ bin/sh-c'/ usr/sb …" 9 minutes ago Up 8 minutes 22/tcp, 2888/tcp, 3888/tcp 0.0.0.0seconds 2181-> 2181/tcp lnmp_zookeeper_1c9de041d5ace wurstmeister/kafka "start-kafka.sh" 15 minutes ago Up 4 seconds 0.0.0.0minutes ago Up 9092-> 9092/tcp lnmp_kafka_192b5e1563062 mysql:5.7.16 "docker-entrypoint.s..." 2 weeks ago Up 6 hours 0.0.0.0 3306/tcp my_mysql5729f0b85f1284 registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g 3307-> 3306/tcp my_mysql5729f0b85f1284 registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g "/ bin/sh-c'/ home/o …" 3 weeks ago Up 6 hours 0.0.0.0 docker-entrypoint 1521-> 1521/tcp oracle89c169b8bd14 nginx:alpine "/ docker-entrypoint." 4 weeks ago Up 6 hours (healthy) 0.0.0.0 healthy 81-> 80/tcp 0.0.0.0hours 444-> 443/tcp nginxe0e4fa4bf177 lnmp_php72 "entrypoint php-fpm" 4 weeks ago Up 6 hours (healthy) 9000-9001/tcp php72a1ddf67627cd lnmp_php56 "entrypoint php-fpm" 4 weeks ago Up 6 hours (healthy) 9000/tcp php56324aa6c8b071 lnmp_php71 "entrypoint php-fpm" 4 weeks ago Up 6 hours (healthy) 9000/tcp Php714fd5d2ce7612 mongo:4.4.0 "docker-entrypoint.s..." 4 weeks ago Up 6 hours 0.0.0.0 27017/tcp mongo4.4f212f81e0546 redis:4-alpine 27018-> 27017/tcp mongo4.4f212f81e0546 redis:4-alpine "docker-entrypoint.s …" 4 weeks ago Up 6 hours (healthy) 0.0.0.0 healthy 6379-> 6379/tcp redise42962aa16c8 mysql:5.6 "docker-entrypoint.s …" 4 weeks ago Restarting (137) 50 seconds ago mysqlluwei@luweideMacBook-Pro-2%

Connect the kafka container

Luwei@luweideMacBook-Pro-2 ~% docker exec-it lnmp_kafka_1 / bin/bashbash-5.1#

Create topic

Bash-5.1# find /-name kafka-topics.sh/opt/kafka_2.13-2.7.1/bin/kafka-topics.shbash-5.1# / opt/kafka_2.13-2.7.1/bin/kafka-topics.sh-- create-- zookeeper 192.168.110.147 opt/kafka_2.13 2181-- replication-factor 1-- partitions 1-- topic testCreated topic test.bash-5.1#

View the theme created

Bash-5.1# / opt/kafka_2.13-2.7.1/bin/kafka-topics.sh-- list-- zookeeper 192.168.110.147:2181testbash-5.1#

Start the producer

Bash-5.1# find /-name kafka-console-producer.sh/opt/kafka_2.13-2.7.1/bin/kafka-console-producer.shbash-5.1# / opt/kafka_2.13-2.7.1/bin/kafka-console-producer.sh-- broker-list 192.168.110.147 9092-- topic mykafka > hello donglei [2021-11-22 08V 05V 19506] WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 3: {mykafka=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient) >

Start the consumer

Bash-5.1# / opt/kafka_2.13-2.7.1/bin/kafka-console-consumer.sh-bootstrap-server 192.168.110.147 2.7.1/bin/kafka-console-consumer.sh 9092-topic mykafka-from-beginninghello donglei is all the contents of this article "how are kafka and zookeeper installed?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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

Development

Wechat

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

12
Report