docker安裝kafka快速入門docker
1.安裝zookeeperbootstrap
docker search zookeeper
docker pull zookeeper
docker run -d -v /home/soft/zookeeperhost/zookeeperDataDir:/data -v /home/soft/zookeeperhost/zookeeperDataLogDir:/datalog --name zookeeper -p 2181:2181 zookeeperbash
2.安裝kafkaserver
docker search kafka
docker pull wurstmeister/kafka
docker run -d --name kafka -p 9092:9092 --env KAFKA_ADVERTISED_HOST_NAME=localhost -e KAFKA_ZOOKEEPER_CONNECT=localhost:2181 -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 -e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 -e KAFKA_HEAP_OPTS="-Xmx256M -Xms128M" wurstmeister/kafka kafka
3.登陸kafka,建立主題,發送消息,接受消息it
a.進入kafka
docker exec -it kafka bash
cd /opt/kafka_2.11-2.0.0/bin/io
b.建立名爲test的主題
./kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 8 --topic testconsole
c.建立提供者
./kafka-console-producer.sh --broker-list localhost:9092 --topic test入門
d.另起一個標籤,執行以下命令 建立kafka消費者消費消息:
docker exec -it kafka bash
cd /opt/kafka_2.11-2.0.0/bin/
./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginningclass