Since contact with Docker, it had a keen interest in it, usually require development environment also try to build Docker, compared to the virtual machine does a lot of convenience, this is mainly the record about Docker usually use to build a nice development environment in development. Where all applications are created using a docker placed under dockerapps directory.
Version: 3.5
1.1 Single node deployment
Create a zookeeper directory under dockerapps. This directory contains a directory for data zookeeper persistent application data, comprising a configuration file to configure zoo.cfg zookeeper application, comprising a promoter for zk start.sh single node. The directory structure is shown below:
1 2 3 4
zookeeper/ ├── data ├── start.sh └── zoo.cfg
1.1.1 Creating persistent data directory data
Zk zookeeper created in the directory data persistence directory
1
mkdir data
1.1.2 Creating zoo.cfg profile
Zk created in the directory configuration file zookeeper zoo.cfg, reads as follows:
After completion of the above steps can be started in a single node zk. Execution start.sh
1
sh start.sh
View docker process
1
docker ps
1 2 3
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 39a6cf356e1a zookeeper:3.5 "/docker-entrypoint.…" 11 seconds ago Up 10 seconds 2888/tcp, 3888/tcp, 0.0.0.0:2181->2181/tcp, 8080/tcp zookeeper
Zk into the client zkCli
1
docker exec -it 39a6cf356e1a bin/zkCli.sh
1.2 cluster deployment
For zk cluster deployment, we can use the docker-compose orchestrate. Zk-cluster to create a directory used to store documents related to cluster in the zookeeper directory. Here, for example with three nodes.
1
mkdir zk-cluster
1.2.1 Creating persistent data folder
Here are created data1, data2, data3 to persist data three nodes.
1
mkdir data1 data2 data3
Myid and create files in each directory data, content, respectively, 2, 3
1.2.2 Creating zk profile zoo.cfg
This configuration file can use the same file can also be similar to the data, were created here for simplicity, use the same configuration file, as follows:
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< 大专栏Docker搭建开发环境合集/span> # example sakes. dataDir=/data dataLogDir=/data/log # 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 # # 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 server.1=localhost:2881:3881 server.1=zookeeper1:2888:3888 server.2=zookeeper2:2888:3888 server.3=zookeeper3:2888:3888 4lw.commands.whitelist=*
1.2.3 Creating layout files docker-compose.yml
In zk-cluster directory from creating layout files, as follows:
Zookeeper version: 3.5.5-390fe37ea45dee01bf87dc1c042b5e3dcce88653, built on 05/03/2019 12:07 GMT Clients: /172.18.0.1:41462[0](queued=0,recved=1,sent=0)