Docker host upgraded to version 4.9 kernel with OVERLAYFS instead of Devicemapper

Source: Internet
Author: User

The Docker version is 1.9.1 because several machines have not been updated for a long time before the Docker system was run. The Docker storage driver used is devicemapper. This time need to update the Docker management platform, simply will also upgrade the underlying Docker version to the new version, and change Devicemapper to OVERLAYFS. Since the operating system is CentOS Linux release 7.1.1503 (CORE), kernel version 3.10.0-229.el7.x86_64, the kernel version already supports OVERLAYFS. But since the new kernel 4.9 has been released, in the 4.9 kernel version, there are many improvements in hardware and file system, involving Btrfs, XFS, F2FS, Overlayfs UBIFS support, FUSE support POSIX ACL, OVERLAYFS SELinux and other aspects. So this time also upgrades the kernel version to 4.9.


Updated as follows

Kernel version:3.10.0-->4.9.0

Docker version:1.9.1-->1.12.2

Storage DRIVER:DEVICEMAPPER-->OVERLAYFS


One: Upgrade kernel version

(1) Installing the Yum source

$ RPM-UVH http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpmRetrieving http://www.elrepo.org/ Elrepo-release-7.0-2.el7.elrepo.noarch.rpmwarning:/var/tmp/rpm-tmp. X3ppyz:header V4 dsa/sha1 Signature, key ID baadae52:nokeypreparing ... ########################   ######### [100%]updating/installing ... 1:elrepo-release-7.0-2.el7.elrepo ################################# [100%]


(2) Installation kernel

$ yum -y --enablerepo=elrepo-kernel install  kernel-ml-devel-4.9.0  Kernel-ml-4.9.0 ======================================================================= package            Arch       version             repository          size================================================================ ======= installing:kernel-ml         x86_64     4.9.0-1.el7.elrepo  elrepo-kernel      39  Mkernel-ml-devel   x86_64    4.9.0-1.el7.elrepo  elrepo-kernel       11 mtransaction summary========================================= =============================== install  2 packagesinstalled:   kernel-ml.x86_64 0:4.9.0-1.el7.elrepo     kernel-ml-devel.x86_64 0:4.9.0-1.el7.elrepo


(3) Check the current version

$ uname-r3.10.0-229.el7.x86_64


(4) Check the kernel boot sequence

$ Awk-f\ ' $1== "Menuentry" {print $} '/etc/grub2.cfgcentos Linux (4.9.0-1.el7.elrepo.x86_64) 7 (Core) CentOS Linux (4.9. 0-1.EL7.ELREPO.X86_64) 7 (CORE) with Debuggingcentos Linux 7 (CORE), with Linux 3.10.0-229.el7.x86_64centos Linux 7 (CORE) , with Linux 0-rescue-f7e36a944a3d4035a61da37d8d4e2313


(5) Set startup kernel

Based on the above check kernel start order, top-down, starting from 0. If setting 4.9 starts then the following command

$grub 2-set-default 0

Restart

$reboot


(6) Check kernel version

$ uname-r4.9.0-1.el7.elrepo.x86_64

Kernel upgrade complete!!!


II: Upgrade the Docker version

(1) Close the Docker process and uninstall the old version

$ systemctl Stop Docker $ rpm-qa|grep dockerdocker-engine-1.9.1-1.el7.centos.x86_ 64docker-storage-setup-0.5-3.el7.centos.noarchdocker-engine-selinux-1.9.1-1.el7.centos.noarch$ RPM-E docker-engine-1.9.1-1.el7.centos.x86_64$ rpm-e Docker-engine-selinux-1.9.1-1.el7.centos.noarch


(2) Install new version

$ wget https://yum.dockerproject.org/repo/main/centos/7/Packages/ docker-engine-selinux-1.12.2-1.el7.centos.noarch.rpm$ wget https://yum.dockerproject.org/repo/main/centos/7/ packages/docker-engine-1.12.2-1.el7.centos.x86_64.rpm# uses the Yum command to resolve dependency issues, and may cause errors if the direct RPM command is installed. $ yum install-y docker-engine-selinux-1.12.2-1.el7.centos.noarch.rpm$ Yum install-y docker-engine-1.12.2-1.el7.centos.x86_64.rpm


(3) Check the new Docker version

$ docker-vdocker Version 1.12.2, build bb80604

Docker upgrade complete!!!



Three: Using OVERLAYFS

(1) Check if there is a OVERLAYFS module

$ lsmod | grep overlayoverlay 49152 0


No, the following command loads

$ modprobe Overlay


(2) mount a disk for the OVERLAYFS directory

because you didn't use do before Cker the default Loopback Way (because it is not a physical block device, performance is poor, size is limited), but took a separate physical disk to do devicemapper. Now it's time to mount the disk to the OVERLAYFS directory.

Note: Because you want to change the storage mode, format the disk. So the original data must have been gone. Once Docker starts, the original container also does not exist.


If you execute directly Mkfs.xfs/dev/xvdb, will definitely error device is busy, because the previous devicemapper mapping relationship is still, the disk is occupied, is unable to be formatted.


1: View partition status

$ cat /proc/partitionsmajor minor   #blocks   name202         0   68157440 xvda202         1     512000 xvda1202        2     5242880 xvda2202        3     2097152 xvda3202        4           1 xvda4202        5    60303360 xvda5202       16  104857600  xvdb202       17  104856576 xvdb1253         0     106496 dm-0253         1  103698432&Nbsp;dm-1253        2  103698432 dm-2 


2: View the status of Device mapper

$ dmsetup statusdocker--vg-docker--pool:0 1159217152 thin-pooldocker--vg-docker--pool_tdata:0 1159217152 Linear docker--vg-docker--pool_tmeta:0 1179648 Linear


3: View device Mapper Appliance dependencies

$dmsetup depsdocker--vg-docker--pool:2 dependencies: (253, 1) (253, 0) docker--vg-docker--pool_tdata:1 dependencies : (202, +) docker--vg-docker--pool_tmeta:1 dependencies: (202, 17)

The output information (202, 17) corresponds to the XVDB device on the partition, which indicates that XVDB is dependent on the


4: Remove device Mapper mapped devices

$ dmsetup Remove docker--vg-docker--pool$ dmsetup remove docker--vg-docker--pool_tdata$ dmsetup Remove docker--vg-docker--pool_tmeta$ Dmsetup Statusno devices found


5: Format disk

$ mkfs.xfs-f/dev/xvdb


6: Create Docker Data directory, Mount disk

$ mkdir-p/data/docker$ mount/dev/xvdb/data/docker$ df-hfilesystem Size used Avail use% mounted ONDEVTMPFS      16G 0 16G 0%/dev/dev/xvda5 58G 2.3G 56G 4%//dev/xvda2 5.0G 40M 5.0G 1%/home/dev/xvda1 497M 161M 337M 33%/boot/dev/xvdb 100G 33M 100G 1%/data/docker

(3) Modify Docker boot mode to OVERLAYFS

Vim/usr/lib/systemd/system/docker.serviceexecstart=/usr/bin/docker daemon--storage-driver=overlay--graph= "/data /docker "--insecure-registry registry.cntv.net


(4) Reload configure and start Docker

$ systemctl daemon-reload                                       $ systemctl start docker                     $ docker  psCONTAINER ID        IMAGE                COMMAND              CREATED              status              ports                NAMES$ ls  /data/dockercontainers  image  network  overlay  swarm  tmp  trust   Volumes

OVERLAYFS configuration complete!!!




Problems encountered:

This is true for Docker.service in the original default configuration when modifying the Docker boot configuration

Execstart=/usr/bin/dockerd-h fd://

When I change to

Execstart=/usr/bin/dockerd--storage-driver=overlay--graph= "/data/docker"--insecure-registry registry.cntv.net-h fd://

When it started, Docker made an error.

Error content:no sockets found via socket Activation:make sure the service was started by SYSTEMD.


650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/8B/FB/wKiom1hd__CTpon5AABP1mUbVds685.png "title=" 111. PNG "width=" "height=" 119 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:800PX;HEIGHT:119PX; "alt=" wkiom1hd__ Ctpon5aabp1mubvds685.png "/>


This update was found on GitHub. This configuration has changed since version 1.12. The workaround is to remove-h fd://from the Execstart directive and change it to the following resolution.

Execstart=/usr/bin/dockerd--storage-driver=overlay--graph= "/data/docker"--insecure-registry registry.cntv.net

Address: https://github.com/docker/docker/releases/tag/v1.12.5


650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/8B/FB/wKiom1heB7KC6yADAADsyjqBEO8809.png "title=" 2222. PNG "width=" "height=" 661 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:800px;height:661px; "alt=" Wkiom1heb7kc6yadaadsyjqbeo8809.png "/>

This article is from the "Sauce paste" blog, please make sure to keep this source http://heqin.blog.51cto.com/8931355/1885730

Docker host upgraded to version 4.9 kernel with OVERLAYFS instead of Devicemapper

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.