赞
踩
创建ZooKeeper 挂载目录(数据挂载目录、配置挂载目录和日志挂载目录)
mkdir -p /export/server/docker/zookeeper/data # 数据挂载目录
mkdir -p /export/server/docker/zookeeper/conf # 配置挂载目录
mkdir -p /export/server/docker/zookeeper/logs # 日志挂载目录
添加配置文件,挂载在/export/server/docker/zookeeper/conf 文件夹下
cd /export/server/docker/zookeeper/conf
vim zoo.cfg
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/data
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
## Metrics Providers
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true
docker run -d \
--name zookeeper \
--privileged=true \
-p 2181:2181 \
--restart=always \
-v /export/server/docker/zookeeper/data:/data \
-v /export/server/docker/zookeeper/conf:/conf \
-v /export/server/docker/zookeeper/logs:/datalog \
zookeeper
查看容器状态
docker ps
查看容器日志
docker logs zookeeper
查看运行状态
docker exec -it zookeeper /bin/bash
./bin/zkServer.sh status
docker run -d --name kafka \
-p 9092:9092 \
-e KAFKA_BROKER_ID=0 \
-e KAFKA_ZOOKEEPER_CONNECT=192.168.43.10:2181 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.43.10:9092 \
-e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 wurstmeister/kafka
进入kafka容器内部
docker exec -it kafka /bin/sh
#进入容器
docker exec -it ${CONTAINER ID} /bin/bash
cd /opt/kafka_2.13-2.8.1/bin
#单机方式:创建一个主题
bin/kafka-topics.sh --create --zookeeper 192.168.10.100:2181 --replication-factor 1 --partitions 1 --topic mykafka
#运行一个生产者
bin/kafka-console-producer.sh --broker-list 192.168.10.100:9092 --topic mykafka
#运行一个消费者
bin/kafka-console-consumer.sh --zookeeper 192.168.10.100:2181 --topic mykafka --from-beginning
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。