centos7-docker安装与配置kafka+zookeeper+kafkamanager
一、默认docker环境已经OK
拉镜像
docker pull wurstmeister/zookeeper
docker pull wurstmeister/kafka
docker pull sheepkiller/kafka-manager
删镜像
docker rmi +镜像id
查看镜像
[root@build-science-system-services-03 ~]# docker images
二、运行相关容器
启动zookeeper:
docker run -d --name zookeeper -p 2191:2181 --restart=always wurstmeister/zookeeper
启动kafka:
docker run -d --name kafka -p 9082:9092 --link zookeeper:zookeeper --env KAFKA_BROKER_ID=100 --env HOST_IP=192.168.100.202 --env KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181 --env KAFKA_ADVERTISED_HOST_NAME=192.168.100.202 --env KAFKA_ADVERTISED_PORT=9082 --restart=always wurstmeister/kafka
启动kafka-manager:
docker run -d --name kafka-manager -p 9000:9000 \
--link zookeeper:zookeeper --link kafka:kafka --env ZK_HOSTS=zookeeper:2181 \
--restart=always sheepkiller/kafka-manager
三、Kafka tool连接
生产kafka使用了SASL
四、Kafka-manager
Docker命令理解和注意事项
docker run -p 2191:2181 -v /data/zookeeper/data:/data -v /data/zookeeper/datalog:/datalog -v /data/zookeeper/conf:/conf --name some-zookeeper --restart always -d zookeeper
外面为2191端口,docker里为2181端口,外面数据目录为/data/zookeeper/data,里面数据目录为/data(先进docker看:docker exec -it some-zookeeper bash,其中some-zookeeper为镜像名,进docker里面看具体的目录路径是多少再填到冒号后面,同时给前面的赋权)
[root@build-science-system-services-03 zookeeper]# docker logs -f some-zookeeper (查看some-zookeeper这个容器的日志)
/docker-entrypoint.sh: line 43: /conf/zoo.cfg: Permission denied
ZooKeeper JMX enabled by default
Using config: /conf/zoo.cfg
cd /data/zookeeper
chmod 777 *
然后再重新启动
挂载出来到linux的路径修改配置文件,会同步映射修改docker中的配置
强制删除容器
[root@build-science-system-services-03 zookeeper]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
558dbe4b9657 zookeeper "/docker-entrypoint.…" 9 minutes ago Up 8 minutes 2888/tcp, 3888/tcp, 8080/tcp, 0.0.0.0:2191->2181/tcp, :::2191->2181/tcp some-zookeeper
a74e70f5d5d0 xuxueli/xxl-job-admin:2.3.0 "sh -c 'java -jar $J…" 10 days ago Up 10 days 0.0.0.0:8889->8080/tcp, :::8889->8080/tcp xxl-job-admin
ae305e009774 mysql:5.7 "docker-entrypoint.s…" 10 days ago Up 10 days 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp mysql
[root@build-science-system-services-03 zookeeper]# docker rm -f 558dbe4b9657
部分参考:https://blog.51cto.com/zyrs/2747202