Docker安装Kafka
先安装zk
1
| docker pull bitnami/kafka:2.7.0
|
启动
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| mkdir -p /opt/maxzhao/kafka/data mkdir -p /opt/maxzhao/kafka/config mkdir -p /opt/maxzhao/kafka/logs sudo docker stop kafka1 sudo docker remove kafka1 sudo docker run --hostname kafka1 --name kafka1 \ -e "KAFKA_CFG_NODE_ID=1" \ -e "KAFKA_CFG_PROCESS_ROLES=controller,broker" \ -e "KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093" \ -e "KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://:9092" \ -e "ALLOW_PLAINTEXT_LISTENER=true" \ -e "KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT" \ -e "KAFKA_ZOOKEEPER_PROTOCOL=PLAINTEXT" \ -e "KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=1@kafka1:9093" \ -e "KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER" \ -e "KAFKA_CFG_INTER_BROKER_LISTENER_NAME=PLAINTEXT" \ -e "KAFKA_CFG_ZOOKEEPER_CONNECT=zk1:2181" \ -e "KAFKA_KRAFT_CLUSTER_ID=eflow-kafka-cluster" \ -e "KAFKA_HEAP_OPTS=-Xmx8192m -Xms1024m" \ -p 59092:9092 \ -p 59093:9093 \ -p 59094:9094 \ -v /opt/maxzhao/kafka/data/:/bitnami/kafka/data \ -v /opt/maxzhao/kafka/config/:/bitnami/kafka/config \ -v /opt/maxzhao/kafka/logs/:/kafka-logs \ --restart always -d bitnami/kafka:2.7.0 sudo docker ps
|
查询端口占用
1
| sudo netstat -tulpn | grep 59092
|
“ALLOW_PLAINTEXT_LISTENER=true” 线上环境不能使用
本文地址: https://github.com/maxzhao-it/blog/post/4179414/