- Download zk
docker pull wurstmeister/zookeeper
- Start zk
docker run --network db_network -d --name zookeeper --publish 2181:2181 --volume /etc/localtime:/etc/localtime wurstmeister/zookeeper
- Download kafka
docker pull wurstmeister/kafka
- Start kafka
docker run --network db_network -d --name kafka --publish 9092:9092 --link zookeeper --env KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181 --env KAFKA_ADVERTISED_HOST_NAME=kafka --env KAFKA_ADVERTISED_PORT=9092 --volume /etc/localtime:/etc/localtime wurstmeister/kafka:latest
$ kafka-topics.sh --zookeeper zookeeper:2181 --list
$ kafka-topics.sh --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 3 --topic binlog_test
$ kafka-console-producer.sh --broker-list localhost:9092 --topic binlog_test
$ kafka-console-consumer.sh --bootstrap-server kafka:9092 --topic binlog_test --from-beginning
网友评论