By mounting kafka linux docker

1, the installation docker

2, pulling and zk mirror kafka

docker pull wurstmeister/kafka
docker pull zookeeper:3.5.7

3, create a communications network

docker network create kafkanet

4, create kafka container and zk

   4.1 Creating zk container

docker run --net=kafkanet  --name yhq_zookeeper1  -p 21810:2181  -d zookeeper:3.5.7

  4.2 View zk network

docker inspect yhq_zookeeper1

  Creating a container 4.3 kafka

docker run --net=kafkanet --name yhq_kafka1 -p 9093:9092 \
--link yhq_zookeeper1 \
-e KAFKA_ZOOKEEPER_CONNECT=172.20.0.2:2181 \
-e KAFKA_ADVERTISED_HOST_NAME=192.168.146.190 \
-e KAFKA_ADVERTISED_PORT=9092 \
-d wurstmeister/kafka

 KAFKA_ADVERTISED_HOST_NAME parameters need to be set to the host address 192.168.146.190.

  KAFKA_ZOOKEEPER_CONNECT parameter hbl-zookeeper internal address and port of the container (the container in the same visit each host address to use the container, the instruction for the view docker inspect hbl_zookeeper, the container can be seen in the ip address field Networks).

  4.4 Check communication network, zk are added to the vessel and kafka network

  

   5, kafka container operation

docker exec -it 7cd bash #kafka container ip starts with 7cd, you can view the vessel by docker ps command

  After entering the kafka container, see opt / kafka_2.12-2.4.1 / config / server.properties and zookeeper.properties, you can see already configured zk and other related configuration

broker.id=-1
############################# Zookeeper #############################

# Zookeeper connection string (see zookeeper docs for details).
# This is a comma separated host:port pairs, each corresponding to a zk
# server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002".
# You can also append an optional chroot string to the urls to specify the
# root directory for all kafka znodes.
zookeeper.connect=172.20.0.2:2181

# Timeout in ms for connecting to zookeeper
zookeeper.connection.timeout.ms=6000

############################# Group Coordinator Settings #############################
expensive, rebalances during application startup.
group.initial.rebalance.delay.ms=0

advertised.port=9092
advertised.host.name=192.168.146.190
port=9092
server.properties
dataDir=/tmp/zookeeper      #zookeeper数据目录
# the port at which the clients will connect
clientPort=2181
# disable the per-ip limit on the number of connections since this is a non-production config
maxClientCnxns=0
# Disable the adminserver by default to avoid port conflicts.
# Set the port to something non-conflicting if choosing to enable this
admin.enableServer=false
# admin.serverPort=8080
bash-4.4# 
zookeeper.properties

 

Guess you like

Origin www.cnblogs.com/yaohuiqin/p/12530245.html