docker run -d –name zookeeper -p 2181:2181 -t wurstmeister/zookeeper
基于Docker的Kafka集群搭建-腾讯云开发者社区-腾讯云 (tencent.com)
这边装一下docker-compose
docker run -d –name kafka1 -p 9092:9092 -e KAFKA_BROKER_ID=0 -e KAFKA_ZOOKEEPER_CONNECT=119.29.17.67:2181 -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://119.29.17.67:9092 -e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 -t wurstmeister/kafka
bf37a685c7e7092221b44924b67f214bdc7b4fbf26d26a7ea9f0c36fe53e3b27
[root@VM-0-16-centos ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bf37a685c7e7 wurstmeister/kafka “start-kafka.sh” 6 seconds ago Up 6 seconds 0.0.0.0:9092->9092/tcp kafka1
cbc0f4716731 wurstmeister/zookeeper “/bin/sh -c ‘/usr/…” 11 hours ago Up 11 hours 22/tcp, 2888/tcp, 3888/tcp, 0.0.0.0:2181->2181/tcp zookeeper
45c7388bedfd mysql:5.7 “docker-entrypoint…” 4 days ago Up 45 hours 33060/tcp, 0.0.0.0:10050->3306/tcp mysql-master
[root@VM-0-16-centos ~]# docker exec –ti kafka1 /bin/bash
Error response from daemon: No such container: –ti
[root@VM-0-16-centos ~]#
Socket error Event: 32 Error: 10053.
Connection closing…Socket close.
Connection closed by foreign host.
Disconnected from remote host(119.29.17.67) at 11:56:29.
Type `help’ to learn how to use Xshell prompt.
[C:~]$
Connecting to 119.29.17.67:22…
Connection established.
To escape to local shell, press ‘Ctrl+Alt+]’.
WARNING! The remote SSH server rejected X11 forwarding request.
Last failed login: Sun Sep 24 13:19:38 CST 2023 from 162.214.55.183 on ssh:notty
There were 55 failed login attempts since the last successful login.
Last login: Sun Sep 24 11:41:12 2023 from 153.3.123.82
[root@VM-0-16-centos ~]# docker exec -ti kafka1 /bin/bash
root@bf37a685c7e7:/# history
1 history
root@bf37a685c7e7:/#
66 root 2023/09/23 23:25:38 docker rm e6285aa0d3cc
67 root 2023/09/23 23:25:41 docker ps -a
68 root 2023/09/23 23:31:13 docker run -d –name elas -p 9200:9200 -v “$PWD/esdata”:/usr/share/elasticsearch/data elasticsearch -Etransport.host=0.0.0.0 -Ediscovery.zen.minimum_master_nodes=1
69 root 2023/09/23 23:34:13 yum install docker-compose
70 root 2023/09/24 13:24:49 history
docker exec -ti kafka1 /bin/bash
$KAFKA_HOME/bin/kafka-topics.sh –create –topic test –zookeeper zookeeper:2181 –replication-factor 1 –partitions 1
root@bf37a685c7e7:/# $KAFKA_HOME/bin/kafka-topics.sh –create –topic test –zookeeper 119.29.17.67:2181 –replication-factor 1 –partitions 1
Created topic test.