为什么要更改 data,metadata呢?我们运行环境中涉及大量数据操作,数据增长有时候很快,由于之前规划不足,所以磁盘很快达到瓶颈需要进行重新部署。
这就需要调整原来的一些docker配置。
操作系统环境采样
[root@fp-web-130 storage]# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core)
[root@fp-web-130 storage]# uname -r3.10.0-327.el7.x86_64
[root@fp-web-130 storage]# docker versionClient: Version: 18.03.0-ce API version: 1.37 Go version: go1.9.4 Git commit: 0520e24 Built: Wed Mar 21 23:09:15 2018 OS/Arch: linux/amd64 Experimental: false Orchestrator: swarm
Server: Engine: Version: 18.03.0-ce API version: 1.37 (minimum version 1.12) Go version: go1.9.4 Git commit: 0520e24 Built: Wed Mar 21 23:13:03 2018 OS/Arch: linux/amd64 Experimental: false
在更改之前,docker info 查看下,当前docker的存储情况。
此时,data的目录大小是:107G,Metadata的目录大小是:2.147G
docker info一下 修改之前
[root@fp-web-130 storage]# docker info
Containers: 22 Running: 0 Paused: 0 Stopped: 22Images: 47Server Version: 18.03.0-ceStorage Driver: devicemapper Pool Name: docker-8:21-2457601-pool Pool Blocksize: 65.54kB Base Device Size: 10.74GB Backing Filesystem: xfs Udev Sync Supported: true Data file: /dev/loop0 Metadata file: /dev/loop1 Data loop file: /mnt/docker/storage/devicemapper/devicemapper/data Metadata loop file: /mnt/docker/storage/devicemapper/devicemapper/metadata Data Space Used: 3.333GB Data Space Total: 107.4GB //默认大小 Data Space Available: 102GB Metadata Space Used: 4.874MB Metadata Space Total: 2.147GB //默认2G Metadata Space Available: 2.143GB Thin Pool Minimum Free Space: 10.74GB Deferred Removal Enabled: true Deferred Deletion Enabled: true Deferred Deleted Device Count: 0 Library Version: 1.02.107-RHEL7 (2015-10-14)Logging Driver: json-fileCgroup Driver: cgroupfsPlugins: Volume: local Network: bridge host macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslogSwarm: inactiveRuntimes: runcDefault Runtime: runcInit Binary: docker-initcontainerd version: cfd04396dc68220d1cecbe686a6cc3aa5ce3667crunc version: 4fc53a81fb7c994640722ac585fa9ca548971871init version: 949e6faSecurity Options: seccomp Profile: defaultKernel Version: 3.10.0-327.el7.x86_64Operating System: CentOS Linux 7 (Core)OSType: linuxArchitecture: x86_64CPUs: 8Total Memory: 15.66GiBName: fp-web-130ID: ETLX:HANE:UUNX:KHX4:2ZXU:DVQN:UIOU:ZDAP:SLZG:3RYD:VPPM:O6GFDocker Root Dir: /mnt/docker/storageDebug Mode (client): falseDebug Mode (server): falseRegistry: https://index.docker.io/v1/Labels:Experimental: falseInsecure Registries: 127.0.0.0/8Live Restore Enabled: false
WARNING: devicemapper: usage of loopback devices is strongly discouraged for production use. Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.WARNING: bridge-nf-call-iptables is disabledWARNING: bridge-nf-call-ip6tables is disabled
关键要执行的命令如下:
dd if=/dev/zero of=data bs=1G count=0 seek=500dd if=/dev/zero of=metadata bs=1G count=0 seek=10
参数说明:
If:in xxx from xxxOf:out xxxbs:block size 块大小Count:seek:创建的数量数据大小计算 data = bs * seek
这里是写的一个shell脚本
#!/bin/bash
DATA_SIZE=$1METADATA_SIZE=$2
if [ "$DATA_SIZE" = "" ]; then DATA_SIZE=1000fi
if [ "$METADATA_SIZE" = "" ]; then METADATA_SIZE=10fi
执行命令
[root@fp-web-130 storage]# sh resize_docker.sh 1000 100+0 records in0+0 records out0 bytes (0 B) copied, 0.000127523 s, 0.0 kB/s0+0 records in0+0 records out0 bytes (0 B) copied, 0.000110421 s, 0.0 kB/s
docker info一下查看修改过之后池大小
[root@fp-web-130 storage]# docker info
Containers: 22 Running: 0 Paused: 0 Stopped: 22Images: 47Server Version: 18.03.0-ceStorage Driver: devicemapper Pool Name: docker-8:21-2457601-pool Pool Blocksize: 65.54kB Base Device Size: 10.74GB Backing Filesystem: xfs Udev Sync Supported: true Data file: /dev/loop0 Metadata file: /dev/loop1 Data loop file: /mnt/docker/storage/devicemapper/devicemapper/data Metadata loop file: /mnt/docker/storage/devicemapper/devicemapper/metadata Data Space Used: 3.333GB Data Space Total: 1.074TB //已经改变 Data Space Available: 102GB Metadata Space Used: 9.142MB Metadata Space Total: 10.74GB //已经改变大小 Metadata Space Available: 10.73GB Thin Pool Minimum Free Space: 107.4GB Deferred Removal Enabled: true Deferred Deletion Enabled: true Deferred Deleted Device Count: 0 Library Version: 1.02.107-RHEL7 (2015-10-14)Logging Driver: json-fileCgroup Driver: cgroupfsPlugins: Volume: local Network: bridge host macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslogSwarm: inactiveRuntimes: runcDefault Runtime: runcInit Binary: docker-initcontainerd version: cfd04396dc68220d1cecbe686a6cc3aa5ce3667crunc version: 4fc53a81fb7c994640722ac585fa9ca548971871init version: 949e6faSecurity Options: seccomp Profile: defaultKernel Version: 3.10.0-327.el7.x86_64Operating System: CentOS Linux 7 (Core)OSType: linuxArchitecture: x86_64CPUs: 8Total Memory: 15.66GiBName: fp-web-130ID: ETLX:HANE:UUNX:KHX4:2ZXU:DVQN:UIOU:ZDAP:SLZG:3RYD:VPPM:O6GFDocker Root Dir: /mnt/docker/storageDebug Mode (client): falseDebug Mode (server): falseRegistry: https://index.docker.io/v1/Labels:Experimental: falseInsecure Registries: 127.0.0.0/8Live Restore Enabled: false
WARNING: devicemapper: usage of loopback devices is strongly discouraged for production use. Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.WARNING: bridge-nf-call-iptables is disabledWARNING: bridge-nf-call-ip6tables is disabled
lsblk一下
注意: sdb磁盘我分了1个主分区 sdb1, 一个扩展分区sdb2, 在扩展分区上创建的sd5逻辑分区,由于整个磁盘是200G, 所以给sdb5 100G的空间 我们看回环设备大小目前已经变化成了docker的回环设备loop0变成了 1T空间,loop1变成了10G空间 之前我们是把docker镜像和容器存储位置从/var/lib/docker 改变到了 新加的磁盘的/mnt/docker/storage 位置上了。 虽然我们更改了配置的大小,但是需要新硬盘大小支撑,所以只要保证硬盘大小和我们设置的大小对应即可。 具体如何更改docker的镜像和容器存储位置,请看我的一篇文章 https://www.cnblogs.com/aozhejin/p/15861052.html
手机扫一扫
移动阅读更方便
你可能感兴趣的文章