网上docker 安装kafka环境教程大多数会采用下面命令
docker run -d --name kafka -p 9092:9092 \
-e KAFKA_BROKER_ID=0-e KAFKA_ZOOKEEPER_CONNECT=192.xxx.xxx.xxx:2181 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.xxx.xxx.xxx:9092-e \
KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092-t bitnami/kafka:2.7.0
- –name=“容器新名字” 为容器指定一个名称;
- -d: 后台运行容器并返回容器ID,也即启动守护式容器(后台运行);
- -p: 指定端口映射,小写p
启动kafka容器时发现容器并没有正常启动,通过查看日志发现提示:
- 查看日志命令
docker logs kafka
- 日志错误提示
INFO ==>**StartingKafka setup **15:04:41.47 ERROR ==>The KAFKA_CFG_LISTENERS environment variable does not configure a secure listener. Set the environment variable ALLOW_PLAINTEXT_LISTENER=yes toallow the container tobe started witha plaintext listener. This is only recommended for development.15:04:41.48 ERROR ==>The KAFKA_ZOOKEEPER_PROTOCOL environment variable does not configure a secure protocol. Set the environment variable ALLOW_PLAINTEXT_LISTENER=yes toallow the container tobe started witha plaintext listener. This is only recommended for development.
这是因为在启动容器时没有指定环境变量ALLOW_PLAINTEXT_LISTENER 允许使用PLAINTEXT侦听器。
启动命令时加上指定环境变量
-e ALLOW_PLAINTEXT_LISTENER=yes
docker run -d --name kafka -p 9092:9092 \
-e KAFKA_BROKER_ID=0 -e KAFKA_ZOOKEEPER_CONNECT=192.xxx.xxx.xxx:2181 \
-e ALLOW_PLAINTEXT_LISTENER=yes \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.xxx.xxx.xxx:9092 -e \KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 -t bitnami/kafka:2.7.0
成功:
本文转载自: https://blog.csdn.net/qq_31686241/article/details/125966127
版权归原作者 yuio呀 所有, 如有侵权,请联系我们删除。
版权归原作者 yuio呀 所有, 如有侵权,请联系我们删除。