标签:docker lvm
默认情况下,Centos下docker使用的为loop模式存储,这个模式只能在测试环境中使用。
警告信息如下:
WARNING: Usage of loopback devices is strongly discouraged for production use. Either use `--storage-opt dm.thinpooldev` or use `--storage-opt dm.no_warn_on_loop_devices=true` to suppress this warning.
添加用于docker存储的硬盘
创建PV
[root@registry docker]# pvcreate /dev/sdb
创建VG
[root@registry docker]# vgcreate datavg /dev/sdb
创建LV
[root@registry docker]# lvcreate -L 90G -n data datavg
[root@registry docker]# lvcreate -L 5G -n metadata datavg
修改docker启动参数
[root@registry ~]# more /lib/systemd/system/docker.service
ExecStart=/usr/bin/docker daemon -g=/docker --insecure-registry repo.fctty.com -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375 --label label_name=fcrepo --iptables=false --storage-driver=devicemapper --storage-opt dm.datadev=/dev/datavg/data --storage-opt dm.metadatadev=/dev/datavg/metadata
启动docker
[root@registry ~]# systemctl daemon-reload
[root@registry ~]# systemctl start docker
查看更改后的存储
[root@registry ~]# docker info
Server Version: 1.11.1
Storage Driver: devicemapper
Pool Name: docker-253:0-381715-pool
Pool Blocksize: 65.54 kB
Base Device Size: 10.74 GB
Backing Filesystem: xfs
Data file: /dev/datavg/data
Metadata file: /dev/datavg/metadata
Data Space Used: 14.09 MB
Data Space Total: 96.64 GB
Data Space Available: 96.62 GB
至此,docker已成功使用LVM磁盘卷了,不再担心存储爆了。
官方文档参考:https://docs.docker.com/engine/userguide/storagedriver/device-mapper-driver/
本文出自 “再苦不哭” 博客,请务必保留此出处http://wangshijun.blog.51cto.com/748817/1790231
标签:docker lvm
原文地址:http://wangshijun.blog.51cto.com/748817/1790231