我们这边是用一台百度云服务器(ubuntu 22 0 4)和腾讯云服务器搭建demo(centos stream 9)
root 2023/09/12 18:07:47 docker pull wurstmeister/kafka
root 2023/09/12 18:08:09 apt -y install docker.io
root 2023/09/12 18:08:48 systemctl start docker
root 2023/09/12 18:09:17 docker pull wurstmeister/kafk
root 2023/09/12 18:11:55 docker pull wurstmeister/zookeeper
root 2023/09/12 18:22:24 docker run -it –name zookeeper -p 12181:2181 -d wurstmeister/zookeeper:latest
# 首先需要启动zookeeper,如果不先启动,启动kafka没有地方注册消息
root 2023/09/12 18:25:31 docker run -it –name kafka01 -p 19092:9092 -d -e KAFKA_BROKER_ID=0 -e KAFKA_ZOOKEEPER_CONNECT=182.61.40.160:12181 -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://182.61.40.160:19092 -e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 wurstmeister/kafka:latest
# 启动kafka容器,注意需要启动三台,注意端口的映射,都是映射到9092 # 第一台
这边三台容器都挂在百度云里面
docker ps -a
04d5fe47f7e8 wurstmeister/kafka:latest “start-kafka.sh” 19 minutes ago Up 19 minutes 0.0.0.0:19092->9092/tcp, :::19092->9092/tcp kafka01
#看时间的话这个是容器
69b33d0d7a1f wurstmeister/zookeeper:latest “/bin/sh -c ‘/usr/sb…” 24 minutes ago Up 24 minutes 22/tcp, 2888/tcp, 3888/tcp, 0.0.0.0:12181->2181/tcp, :::12181->2181/tcp zookeeper
#这个是zookeeper的服务
docker run -it –name kafka02 -p 19093:9092 -d -e KAFKA_BROKER_ID=1 -e KAFKA_ZOOKEEPER_CONNECT=182.61.40.160:12181 -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://182.61.40.160:19093 -e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 wurstmeister/kafka:latest
#容器2
docker run -it –name kafka03 -p 19094:9092 -d -e KAFKA_BROKER_ID=2 -e KAFKA_ZOOKEEPER_CONNECT=182.61.40.160:12181 -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://182.61.40.160:19094 -e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 wurstmeister/kafka:latest
#容器3
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fc8b9dde3567 wurstmeister/kafka:latest “start-kafka.sh” About a minute ago Up About a minute 0.0.0.0:19094->9092/tcp, :::19094->9092/tcp kafka03
434be8bfe9c8 wurstmeister/kafka:latest “start-kafka.sh” 2 minutes ago Up 2 minutes 0.0.0.0:19093->9092/tcp, :::19093->9092/tcp kafka02
04d5fe47f7e8 wurstmeister/kafka:latest “start-kafka.sh” 25 minutes ago Up 25 minutes 0.0.0.0:19092->9092/tcp, :::19092->9092/tcp kafka01
69b33d0d7a1f wurstmeister/zookeeper:latest “/bin/sh -c ‘/usr/sb…” 31 minutes ago Up 31 minutes 22/tcp, 2888/tcp, 3888/tcp, 0.0.0.0:12181->2181/tcp, :::12181->2181/tcp zookeeper
#状态
还有一种docker部署方式