Docker 安裝kafka
阿新 • • 發佈:2018-11-08
1、安裝zookeeper
(1)下載zookeeper映象。
[[email protected] ~]$ docker search zookeeper NAME DESCRIPTION STARS OFFICIAL AUTOMATED zookeeper Apache ZooKeeper is an open-source server ... 460 [OK] jplock/zookeeper Builds a docker image for Zookeeper versio... 161 [OK] mesoscloud/zookeeper ZooKeeper 73 [OK] wurstmeister/zookeeper 57 [OK] confluentinc/cp-zookeeper Official Confluent Docker Image for Zookeeper 30 mbabineau/zookeeper-exhibitor 23 [OK] digitalwonderland/zookeeper Latest Zookeeper - clusterable 18 [OK] confluent/zookeeper 12 [OK] tobilg/zookeeper-webui Docker image for using `zk-web` as ZooKeep... 10 [OK] debezium/zookeeper Zookeeper image required when running the ... 8 [OK] hyperledger/fabric-zookeeper Fabric Zookeeper docker image for Hyperled... 8 springxd/zookeeper A Docker image that can run a ZooKeeper se... 6 [OK] elevy/zookeeper ZooKeeper configured to execute an ensembl... 6 [OK] 31z4/zookeeper Dockerized Apache Zookeeper. 5 [OK] thefactory/zookeeper-exhibitor Exhibitor-managed ZooKeeper with S3 backup... 5 [OK] bitnami/zookeeper ZooKeeper is a centralized service for dis... 4 [OK] paulbrown/zookeeper Zookeeper on Kubernetes (PetSet) 1 [OK] openshift/zookeeper-346-fedora20 ZooKeeper 3.4.6 with replication support 1 harisekhon/zookeeper Apache ZooKeeper (tags 3.3 - 3.4) 1 [OK] ciscocloud/zookeeper 1 [OK] duffqiu/zookeeper-cli 0 [OK] jamiecressey89/marathon-zookeeper Zookeeper image that uses Marathon's API f... 0 [OK] phenompeople/zookeeper Apache ZooKeeper is an open-source server ... 0 [OK] strimzi/zookeeper 0 midonet/zookeeper Dockerfile for a Zookeeper server. 0 [OK]
具體下載哪個版本,可在https://hub.docker.com上搜索相應的版本,在這裡選擇mesoscloud/zookeeper:3.4.8版本。
[[email protected] ~]$ docker pull mesoscloud/zookeeper:3.4.8 3.4.8: Pulling from mesoscloud/zookeeper 469cfcc7a4b3: Pull complete 0cb794d55c09: Pull complete 49b42dca18f7: Pull complete 1734fcc70024: Pull complete 07fc6b833d94: Pull complete Digest: sha256:9aa170a4c4aa2f3bc8242f5e3dd9df3b9206ecd99697926f26976e58f96d83cc Status: Downloaded newer image for mesoscloud/zookeeper:3.4.8
(2)建立zookeeper目錄,用於存放zookeeper資料及日誌。
[[email protected] ~]$ mkdir zookeeper
[[email protected] ~]$ ll
total 16
……
drwxrwxr-x 2 docker docker 4096 Sep 3 22:46 zookeeper
[[email protected] ~]$ cd zookeeper/
(3)執行並啟動zookeeper容器
docker run -p 2181:2181 --name zookeeper -v $PWD/conf:/opt/zookeeper/conf -v $PWD/data:/tmp/zookeeper -d mesoscloud/zookeeper:3.4.8
--------------------------------------------------------------------------------
[ [email protected] zookeeper]$ docker run -p 2181:2181 --name zookeeper -v $PWD/conf:/opt/zookeeper/conf -v $PWD/data:/tmp/zookeeper -d mesoscloud/zookeeper:3.4.8
73f52be038de1a77f4c0e836f9eae77e273ec1bff19f9f69def210498660e610
[[email protected] zookeeper]$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
73f52be038de mesoscloud/zookeeper:3.4.8 "/usr/local/bin/du..." About a minute ago Up About a minute 0.0.0.0:2181->2181/tcp zookeeper
2、安裝kafka
(1)下載kafka映象。
[[email protected] ~]$ docker search kafka
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
wurstmeister/kafka Multi-Broker Apache Kafka Image 663 [OK]
spotify/kafka A simple docker image with both Kafka and ... 311 [OK]
sheepkiller/kafka-manager kafka-manager 126 [OK]
ches/kafka Apache Kafka. Tagged versions. JMX. Cluste... 106 [OK]
confluentinc/cp-kafka Official Confluent Docker Image for Kafka ... 78
confluentinc/cp-kafka-connect Official Confluent Docker Image for Kafka ... 44
landoop/kafka-topics-ui UI for viewing Kafka Topics config and dat... 21 [OK]
hlebalbau/kafka-manager Kafka Manager Docker Images Build. 18 [OK]
hyperledger/fabric-kafka Fabric Kafka docker image for Hyperledger ... 12
digitalwonderland/kafka Latest Kafka - clusterable 12 [OK]
debezium/kafka Kafka image required when running the Debe... 11 [OK]
bitnami/kafka Apache Kafka is a distributed streaming pl... 10 [OK]
cgswong/confluent-kafka Confluent Platform Kafka 9 [OK]
solsson/kafka http://kafka.apache.org/documentation.html... 9 [OK]
danielqsj/kafka-exporter Kafka exporter for Prometheus 7 [OK]
landoop/kafka-connect-ui Web based UI for Kafka Connect. 7 [OK]
cloudtrackinc/kubernetes-kafka Apache Kafka to Kubernetes Replication Con... 5 [OK]
caiqinzhou/logspout-kafka Logspout adapter for writing Docker contai... 3 [OK]
mesosphere/kafka-client Kafka client 3 [OK]
phenompeople/kafka Apache Kafka is a distributed streaming pl... 2 [OK]
openwhisk/kafkaprovider OpenWhisk trigger provider services for ka... 2 [OK]
coco/coco-kafka-bridge Kafka Bridge listens to a kafka proxy and ... 1 [OK]
vungle/logstash-kafka-es A simple Logstash image to ship json logs ... 1 [OK]
zenreach/kafka-connect Zenreach's Kafka Connect Docker Image 0
amplifymedia/kafka A fork of wurstmeister/kafka. 0
具體下載哪個版本,可在https://hub.docker.com上搜索相應的版本,在這裡選擇wurstmeister/kafka:2.11-2.0.0版本。
[[email protected] ~]$ docker pull wurstmeister/kafka:2.11-2.0.0
2.11-2.0.0: Pulling from wurstmeister/kafka
8e3ba11ec2a2: Pull complete
311ad0da4533: Pull complete
391a6a6b3651: Pull complete
a475bdab8855: Pull complete
15709c44ef71: Pull complete
a663224093f6: Pull complete
Digest: sha256:2e3ff64e70ea983530f590282f36991c0a1b105350510f53cc3d1a0279b83c28
Status: Downloaded newer image for wurstmeister/kafka:2.11-2.0.0
(2)執行並啟動kafka容器
[[email protected] kafka]$ docker run -d --name kafka -p 9092:9092 -e KAFKA_BROKER_ID=0 -e KAFKA_ZOOKEEPER_CONNECT=192.168.1.200:2181 -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.1.200:9092 -e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 -d wurstmeister/kafka:2.11-2.0.0
36f3a86b9fe3eb20c19e5666b68ed2616033e647a5c3607e41ad985405ebf206
[[email protected] kafka]$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
36f3a86b9fe3 wurstmeister/kafka:2.11-2.0.0 "start-kafka.sh" 9 seconds ago Up 7 seconds 0.0.0.0:9092->9092/tcp kafka
73f52be038de mesoscloud/zookeeper:3.4.8 "/usr/local/bin/du..." 31 minutes ago Up 9 minutes 0.0.0.0:2181->2181/tcp zookeeper
下述 兩個引數需改為宿主機器的IP地址,如果不這麼設定,可能會導致在別的機器上訪問不到kafka。
KAFKA_ZOOKEEPER_CONNECT=192.168.1.200:2181
KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.1.200:9092