如何清除docker的thinpool设备

时间:2017-12-06 11:03:18

标签: docker redhat device-mapper

我正在使用devicemapper和thinpool设备在Redhat系统上运行docker,正如生产系统所推荐的那样。现在,当我想重新安装docker时,我需要两个步骤:

1)删除docker目录(在我的case / area51 / docker中)
2)清除稀释设备

docker documentation指出当使用devicemapper与dm.metadev和dm.datadev选项时,清除devicemapper的最简单方法是:

  

如果设置新的元数据池,则必须有效。   这可以通过将前4k归零来指示空元数据来实现,如下所示:

$ dd if=/dev/zero of=$metadata_dev bs=4096 count=1

不幸的是,根据文档,dm.metadatadev已被弃用,而是使用dm.thinpooldev 代替。

我的精简版已按this docker instruction的方式创建 所以,我的设置现在看起来像这样:

cat /etc/docker/daemon.json  
{
        "storage-driver": "devicemapper", 
        "storage-opts": [ 
        "dm.thinpooldev=/dev/mapper/thinpool_VG_38401-thinpool",
        "dm.basesize=18G"
        ]  
}

在devicemapper目录下,我看到以下的thinpool设备

ls -l /dev/mapper/thinpool_VG_38401-thinpool*
lrwxrwxrwx 1 root root 7 Dec  6 08:31 /dev/mapper/thinpool_VG_38401-thinpool -> ../dm-8
lrwxrwxrwx 1 root root 7 Dec  6 08:31 /dev/mapper/thinpool_VG_38401-thinpool_tdata -> ../dm-7
lrwxrwxrwx 1 root root 7 Dec  6 08:31 /dev/mapper/thinpool_VG_38401-thinpool_tmeta -> ../dm-6

因此,在成功运行docker之后,我尝试重新安装如上所述并通过将4K零写入tmeta设备并重新启动docker来清除thinpool:

dd if=/dev/zero of=/dev/mapper/thinpool_VG_38401-thinpool_tmeta bs=4096 count=1  
systemctl start docker

并努力与

docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Wed 2017-12-06 10:28:46 UTC; 10s ago
     Docs: https://docs.docker.com
  Process: 1566 ExecStart=/usr/bin/dockerd -G uwsgi --data-root=/area51/docker -H unix:///var/run/docker.sock (code=exited, status=1/FAILURE)
 Main PID: 1566 (code=exited, status=1/FAILURE)
   Memory: 236.0K
   CGroup: /system.slice/docker.service

Dec 06 10:28:45 yoda3 systemd[1]: Starting Docker Application Container Engine...
Dec 06 10:28:45 yoda3 dockerd[1566]: time="2017-12-06T10:28:45.816049000Z" level=info msg="libcontainerd: new containerd process, pid: 1577"
Dec 06 10:28:46 yoda3 dockerd[1566]: time="2017-12-06T10:28:46.816966000Z" level=warning msg="failed to rename /area51/docker/tmp for background deletion: renam...chronously"
Dec 06 10:28:46 yoda3 dockerd[1566]: Error starting daemon: error initializing graphdriver: devmapper: Unable to take ownership of thin-pool (thinpool_VG_38401-...data blocks
Dec 06 10:28:46 yoda3 systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Dec 06 10:28:46 yoda3 systemd[1]: Failed to start Docker Application Container Engine.
Dec 06 10:28:46 yoda3 systemd[1]: Unit docker.service entered failed state.
Dec 06 10:28:46 yoda3 systemd[1]: docker.service failed.

我认为我可以绕过“无法获得瘦身池”的所有权。通过重新启动。但重新启动并尝试再次启动docker后,我收到以下错误:

systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Wed 2017-12-06 10:30:37 UTC; 2min 29s ago
     Docs: https://docs.docker.com
  Process: 3180 ExecStart=/usr/bin/dockerd -G uwsgi --data-root=/area51/docker -H unix:///var/run/docker.sock (code=exited, status=1/FAILURE)
 Main PID: 3180 (code=exited, status=1/FAILURE)
   Memory: 37.9M
   CGroup: /system.slice/docker.service

Dec 06 10:30:36 yoda3 systemd[1]: Starting Docker Application Container Engine...
Dec 06 10:30:36 yoda3 dockerd[3180]: time="2017-12-06T10:30:36.893777000Z" level=warning msg="libcontainerd: makeUpgradeProof could not open /var/run/docker/lib...containerd"
Dec 06 10:30:36 yoda3 dockerd[3180]: time="2017-12-06T10:30:36.901958000Z" level=info msg="libcontainerd: new containerd process, pid: 3224"
Dec 06 10:30:37 yoda3 dockerd[3180]: Error starting daemon: error initializing graphdriver: devicemapper: Non existing device thinpool_VG_38401-thinpool 
Dec 06 10:30:37 yoda3 systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Dec 06 10:30:37 yoda3 systemd[1]: Failed to start Docker Application Container Engine.
Dec 06 10:30:37 yoda3 systemd[1]: Unit docker.service entered failed state.
Dec 06 10:30:37 yoda3 systemd[1]: docker.service failed.

所以,显然将零写入thinpool_meta设备是不对的,它似乎会破坏我的瘦身设备。

此处的任何人都可以告诉我清除精简池设备的正确步骤吗?优选地,解决方案不需要重新启动。

0 个答案:

没有答案