This is article 12 of the Stick to technical Writing Project (including translation). Set a small goal of 999, at least 2 articles per week.

Just to make fun of you, I am a little lazy recently, and I owe 4 articles. I will make them up later.

introduce

If microservices and containers are the best partners, then modules with multiple instances are certainly indispensable. If methods like Google JIB are not used for image layering (using image cache), it is bound to cause

  • Bandwidth waste: especially the public network bandwidth, if the harbor is self-built, it will easily lead to the single node network adapter is full, if the Harbor federation is used, it will lead to data synchronization and other operation and maintenance problems.
  • Slow cluster pull-up: If the image download is slow, the service pull-up is slow.

For Google JIB, please refer to my other article on Accelerating and simplifying Docker construction (based on Google JIB). This article only introduces Dragonfly + DFDaemon

Dragonfly is a file distribution system based on P2P protocol developed and open source by Alibaba. In addition to using DFGET for file download, also supports dfDaemon for docker image download.

Dragonfly image distribution of the original reason for the explanation, can see ali double 11 mysterious technology: PB level of large-scale file distribution system “Dragonfly”, the article is very detailed, here is not explained.

Google JIB and Dragonfly series articles

Experimental environment

type system ip docker version
supernode Ubuntu Server 16.04.6 LTS X64 192.168.0.44 17.06.2 ~ ce – 0 ~ ubuntu
clinet1 Ubuntu Server 16.04.6 LTS X64 192.168.0.40 17.06.2 ~ ce – 0 ~ ubuntu
clinet2 Ubuntu Server 16.04.6 LTS X64 192.168.0.45 17.06.2 ~ ce – 0 ~ ubuntu

Note: For experimental purposes, it is recommended to use Vmware and back up snapshots during critical operations (for example, just after installing the environment). In this way, you can restore the site in a timely and clean manner and save time wasted when reinstalling the system each time

The installation

Make fun of Dragonfly’s documentation and it’s incredible. Combined with issues + nailing group consult, then sorted out the simplest use of the document.

supernode

Optional: To add docker accelerator to supernode, see cr.console.aliyun.com/cn-hangzhou… If not, you can remove it.

$ cat <<EOD >/etc/docker/daemon.json
{
"registry-mirrors": ["https://xxxx.mirror.aliyuncs.com"] 
}
EOD
$ systemctl restart docker 
Copy the code
$ docker run --name dragonfly-supernode --restart=always -d-p 8001:8001 -p 8002:8002 -v /data/dragonfly/supernode:/home/admin/supernode Registry.cn-hangzhou.aliyuncs.com/dragonflyoss/supernode:0.3.0 - Dsupernode. AdvertiseIp = 192.168.0.44Copy the code

Description:

  • –restart=always Automatically restarts the container when the container exits to prevent abnormal exit caused by kill or OOM exceptions
  • The supernode registry.cn-hangzhou.aliyuncs.com/dragonflyoss/supernode:0.3.0 dragonfly no docker hub mirror, can only use ali cloud
  • – v/data/dragonfly/supernode: / home/admin/supernode will supernode data dir mounted on the host machine
  • -dsupernode. advertiseIp=192.168.0.44 Sets the supernode IP that Clinet can access, which is a big pit. If this parameter is not set, the client may fail to connect to superNode, and docker pull will use Clinet’s network to download the image directly from the real Registry

dfdaemon

Conf [node] address=192.168.0.44 EOD $docker run --name dragonfly-dfClient --restart=always-d-p 65001:65001 -v /root/.small-dragonfly:/root/.small-dragonfly -v /etc/dragonfly.conf:/etc/dragonfly.conf Dragonflyoss/dfclient: v0.3.0 - registry=https://xxx.mirror.aliyuncs.com - ratelimit 100 m $cat < < EOD technicians >/etc/docker/daemon.json {"registry-mirrors": ["http://127.0.0.1:65001"]
}
EOD
$ systemctl restart docker 
Copy the code

Description:

  • In /etc/dragonfly.conf, configure the IP address of the supernode that can be accessed by the client. However, there is no official HA for supernodes. Supernodes cannot be clustered. Downloading Files with Dragonfly is not provided in both Chinese and English. It is mentioned in the details of Downloading Files with Dragonfly and so on (I search for Downloading Files in d7Y org with key words after being blocked).
  • -v /root/.small-dragonfly:/root/.small-dragonfly is used to mount key directories in containers to the host to prevent data loss during restart or image upgrade
  • – registry=https://xxx.mirror.aliyuncs.com where download mirror, can write harbor address, can also write the accelerator address. The default isindex.docker.ioHowever, due to the domestic network, it will probably fail. Very experienced. Official documents are written--registry https://xxx.xx.xIt is not a pit, but for those unfamiliar with Docker, they often wonder whether they can use the accelerator.
  • — Ratelimit 100M is the speed limit. The default value is 20Mdfdaemon#OptionsThere are instructions, however, the documentation is incorrect-ratelimitThe actual is--ratelimitIf you do not change this parameter, you will find that the download is slow.
  • Modify /etc/docker/daemon.json to make docker engine run dfdaemon
  • Systemctl restart docker for daemon to take effect

test

Large file test

$docker pull anjia0532 / kubeflow - images - public. Tensorflow - 1.6.0 - notebook - gpu: v20180604 - b3733835Copy the code

You can use software such as IFtop to check bandwidth usage or logs to determine whether the bandwidth takes effect.



error pulling image configuration: received unexpected HTTP status: 502 Bad Gateway

The last

You need to set related parameters, such as file expiration time, to balance the validity period of files and disk usage.

The resources

Want ads

Friends in Jinan, Shandong, welcome to join us and do things together.

Long-term recruitment, Java programmer, big data engineer, operation and maintenance engineer, front-end engineer.