Docker安装Kafka

创建一个网络

app-tier:网络名称

–driver:网络类型为bridge


docker network create app-tier --driver bridge

安装zookeeper

Kafka依赖zookeeper所以先安装zookeeper

-p:设置映射端口(默认2181)

-d:后台启动


docker run -d --name zookeeper-server \
    --network app-tier \
    -e ALLOW_ANONYMOUS_LOGIN=yes \
    bitnami/zookeeper:latest

docker run -d --name zookeeper -p 2181:2181 --network app-tier  -v /etc/localtime:/etc/localtime wurstmeister/zookeeper

安装kafka

–name:容器名称

-p:设置映射端口(默认9092 )

-d:后台启动

ALLOW_PLAINTEXT_LISTENER任何人可以访问

KAFKA_CFG_ZOOKEEPER_CONNECT链接的zookeeper

ALLOW_PLAINTEXT_LISTENER任何人可以访问

KAFKA_CFG_ZOOKEEPER_CONNECT链接的zookeeper

KAFKA_CFG_ADVERTISED_LISTENERS当前主机IP或地址


docker run -d --name kafka-server     --network app-tier     -p 9092:9092     -e ALLOW_PLAINTEXT_LISTENER=yes     -e KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper-server:2181     -e KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://120.78.202.142:9092      bitnami/kafka:latest

kafka-map图形化管理工具

访问地址:http://服务器IP:9001/
DEFAULT_USERNAME:默认账号admin
DEFAULT_PASSWORD:默认密码admin


docker run -d --name kafka-map     --network app-tier     -p 9001:8080     -v /opt/kafka-map/data:/usr/local/kafka-map/data     -e DEFAULT_USERNAME=admin     -e DEFAULT_PASSWORD=admin     --restart always dushixiang/kafka-map:latest