1、拉取kafka
docker pull wurstmeister/kafka
docker pull wurstmeister/zookeeper
2、创建网络
docker network create app-kafka
3、启动zookeeper
docker run -d \--name zookeeper \-p 2181:2181 \--network app-kafka \--restart always \wurstmeister/zookeeper
4、启动kafka
docker run -d \--name kafka1 \-p 9091:9092 \-e KAFKA_BROKER_ID=1 \-e KAFKA_ZOOKEEPER_CONNECT=192.168.58.131:2181 \-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.58.131:9091 \-e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 \-v /etc/localtime:/etc/localtime \wurstmeister/kafkadocker run -d \--name kafka2 \-p 9092:9092 \-e KAFKA_BROKER_ID=2 \-e KAFKA_ZOOKEEPER_CONNECT=192.168.58.131:2181 \-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.58.131:9092 \-e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 \-v /etc/localtime:/etc/localtime \wurstmeister/kafkadocker run -d \--name kafka3 \-p 9093:9092 \-e KAFKA_BROKER_ID=3 \-e KAFKA_ZOOKEEPER_CONNECT=192.168.58.131:2181 \-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.58.131:9093 \-e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 \-v /etc/localtime:/etc/localtime \wurstmeister/kafka
5、使用图形界面
docker run -d --name kafka-map \--network app-kafka \-p 9101:8080 \-v /docker/kafka-map/data:/usr/local/kafka-map/data \-e DEFAULT_USERNAME=admin \-e DEFAULT_PASSWORD=admin \--restart always dushixiang/kafka-map:latest
- 图形化管理工具
- 访问地址:http://服务器IP:9101/
- DEFAULT_USERNAME:默认账号 admin
- DEFAULT_PASSWORD:默认密码 admin