Docker Storage Pool expansion under CentOS7

Foreword: When docker was just starting, the RHEL kernel did not support AUFS as the backend storage of docker, which delayed the porting work. Later, Red Hat and Docker cooperated to develop a back-end storage framework based on Device Mapper technology, which is now the device-mapper plug-in.

question

systemctl start docker.service prompts startup failure.

analyze

Use the command to view the docker startup log:

# journalctl -xe
  • 1

It is found that the docker-pool capacity is insufficient and new space cannot be allocated. The error message is as follows:

 Insufficient Free Extents for a docker-pool
  • 1

Since docker on centos uses a storage pool, which is an LVM-based block system, the problem can be solved as long as the capacity of the docker-pool is increased.

Gather evidence

You can't read the log, for example, is there an idle hard disk? Which hard disk is the physical volume attached to? Which physical volume is the volume group attached to? How big are each logical volume?

Check disk capacity:

# df -h# fdisk -l
  • 1
  • 2

View physical volume (pv) information:

# pvscan
  • 1

View volume group (vg) information:

# vgdisplay
  • 1

View logical volume (lv) information:

# lvdisplay
  • 1

Solve the problem

  • View the usage of the volume group (vg) and the physical volume (PV) of the volume group:
# pvs -o+pv_used
  • 1

It is found that there is no remaining space in sdc, and the query results are as follows:

# pvs -o+pv_used
  PV         VG         Fmt  Attr PSize   PFree Used    
  /dev/sdc2  VolGroup00 lvm2 a--  558.69g    0   558.69g
  • 1
  • 2
  • 3
  • Adding a new hard drive solved the problem. I am afraid that there is no new hard disk, and it is necessary to re-partition and move the physical volume.

    1. fdisk /dev/sde;
    2. Both primary and extended partitions can be created;
    3. Create a logical partition; there is a pit here, the hard disk cannot be formatted without creating a logical partition, and if the hard disk cannot be formatted, pvcreate will report an error.
    4. Format the logical partition mkfs.ext3 /dev/sde2;
  • Create physical volumes

# pvcreate /dev/sde2
  • 1
  • Add a new physical volume sde2 to the volume group VolGroup00 to increase the capacity of the volume group
# vgextend VolGroup00 /dev/sde2
  • 1
  • Extend the size of the LVM logical volume (lv) with the new space in the vg
# lvextend -L +1T /dev/VolGroup00/docker-pool
  • 1
  • Restart the computer to make the division take effect, which is more violent and easy to use (soft refresh uses resizefs2).
resize2fs   /dev/VolGroup00/docker-pool
  • 1

Unfortunately, I get an error when I execute resize2fs. Reboot directly to solve the problem.

  • The last step restarts the docker service
systemctl start docker.service
  • 1

I'm finally going to see the Buddha, I'm still a little excited when I think about it~~

However, the startup failed again. The first thing to do is to look at the log!

journalctl -xe
  • 1

发现172.17.0.1这个ip无法bind, 看了看网卡,日,docker0的虚拟net-card没了。 
这里不卖关子了,大部分情况是/var/lib/docker下的配置出错了,解决方案有两种:

  1. 创建docker用户组,保证用户有足够的权限运行docker。

        sudo usermod -aG docker $(whoami)
    • 1
  2. 简单暴力我喜欢的方法,直接删掉/var/lib/docker,相当于重置docker的运行配置,重启解决问题。(友情提示:删除之前要备份,文件再拷贝过去就可以正常用了)

        sudo service docker stop
        sudo rm -rf /var/lib/docker
        sudo service docker start 
    • 1
    • 2
    • 3
  3. 一切都平静了,去喝杯咖啡。

        ➜  # docker info
        Containers: 37
        Running: 5
        Paused: 0
        Stopped: 32
        Images: 365
        Server Version: 1.10.3
        Storage Driver: devicemapper
        Pool Name: VolGroup00-docker--pool
        Pool Blocksize: 524.3 kB
        Base Device Size: 107.4 GB
        Backing Filesystem: xfs
        Data file: 
        Metadata file: 
        Data Space Used: 263.7 GB
        Data Space Total: 1.388 TB
        Data Space Available: 1.124 TB
        Metadata Space Used: 35.59 MB
        Metadata Space Total: 604 MB
        Metadata Space Available: 568.4 MB
        Udev Sync Supported: true
        Deferred Removal Enabled: true
        Deferred Deletion Enabled: false
        Deferred Deleted Device Count: 0
        Library Version: 1.02.107-RHEL7 (2016-06-09)
        Execution Driver: native-0.2
        Logging Driver: json-file
        Plugins: 
        Volume: local
        Network: bridge null host
        Kernel Version: 3.10.0-327.36.3.el7.x86_64
        Operating System: CentOS Linux 7 (Core)
        OSType: linux
        Architecture: x86_64
        Number of Docker Hooks: 2
        CPUs: 24
        Total Memory: 251.7 GiB
        Name: localhost.localdomain
        ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        WARNING: bridge-nf-call-iptables is disabled
        WARNING: bridge-nf-call-ip6tables is disabled
        Registries: 190087c6.m.daocloud.io (secure), docker.io (secure
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42

docker storage pool再多说几句。因为是基于LVM的,所以镜像和容器都在块系统中,也就是VolGroup00这个池子里。/var/lib/docker主要存储的是镜像和容器的配置文件和device-mapper映射文件等,所以这个目录不会太大。

 

http://blog.csdn.net/counsellor/article/details/53413743

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326660917&siteId=291194637