docker installation kafka Quick Start

docker installation kafka Quick Start

1. Install zookeeper

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 zookeeper

2. Install kafka

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

3. Log kafka, create topics, send messages, receive messages

a. enter Kafka
Docker Expediting IT Kafka the bash Exec
CD /opt/kafka_2.11-2.0.0/bin/

. b create a theme called test
./kafka-topics.sh --create --zookeeper localhost: 2181 --replication- factor 1 --partitions 8 --topic test

. c create a provider
./kafka-console-producer.sh --broker-list localhost: 9092 --topic test


. d the other from a label, execute the following command to create kafka consumer spending news:
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- beginning

Guess you like

Origin www.cnblogs.com/lookupthesky/p/10948430.html