docker
docker-compose-kafka-standalone.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| version: '3'
services: zookeeper: image: wurstmeister/zookeeper container_name: zookeeper volumes: - ./zk-data:/data ports: - "2181:2181" kafka: image: wurstmeister/kafka container_name: kafka ports: - "9092:9092" environment: KAFKA_BROKER_ID: 1 KAFKA_ADVERTISED_HOST_NAME: localhost KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092 KAFKA_CREATE_TOPICS: "idea360:2:1" KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092 volumes: - ./kafka-data:/kafka depends_on: - zookeeper
|
docker容器常规操作
1 2 3 4 5 6
| docker exec -it kafka /bin/sh cd /opt/kafka_2.13-2.7.0/bin kafka-topics.sh --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 1 --topic iot kafka-topics.sh --list --zookeeper zookeeper:2181 kafka-console-producer.sh --broker-list 127.0.0.1:9092 --topic iot kafka-console-consumer.sh --bootstrap-server 127.0.0.1:9092 --topic iot --from-beginning
|