7

腾讯云容器服务 Docker 容器存储爆满解决方案

 3 years ago
source link: https://cuiqingcai.com/23858.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

腾讯云容器服务 Docker 容器存储爆满解决方案

作者 崔庆才 发表于 2020-11-29 分类于 技术杂谈 阅读次数: 2 本文字数: 1.3k 阅读时长 ≈ 1 分钟

最近的服务都放到腾讯云上了,但是最近遇到了一个问题是 Docker 云磁盘满了,部署的适合提示 no space left 等等。

然后我就登录云主机看了下磁盘情况,好家伙:

ubuntu@VM-0-2-ubuntu:/var/lib/docker/containers$ df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 3869584 0 3869584 0% /dev
tmpfs 777376 15124 762252 2% /run
/dev/vda1 103145380 9460508 89390616 10% /
tmpfs 3886864 24 3886840 1% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 3886864 0 3886864 0% /sys/fs/cgroup
/dev/vdb 10255636 10155252 - 99% /var/lib/docker

vdb 这个磁盘就是我的数据盘,里面放了容器数据,现在已经到了 99% 了,一共就 10G。

然后我就去腾讯云控制台搞了下数据盘的扩容,然后直接扩容到了 200G。

但是回过头来看了下磁盘还是 10G,一变不变。

但 fdisk 已经看到变了:

ubuntu@VM-0-2-ubuntu:/var/lib/docker/containers$ sudo fdisk -l
Disk /dev/vda: 100 GiB, 107374182400 bytes, 209715200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x3fa1d255

Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 209715166 209713119 100G 83 Linux


Disk /dev/vdb: 200 GiB, 214748364800 bytes, 419430400 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

这是因为之前的数据被格式化为了 ext4,但是新扩容的部分并没有。

问了腾讯云的工程师,这时候必须要重新格式化才能用上新的容量,没有好的解决方法。

最后的解决方案:

  • 将当前节点所有 Pod 驱逐到其他的节点。
  • 当前节点退出集群然后配置磁盘,重新操作 mount 和格式化。(但是这里劝别折腾了,终究还是要格式化的。
  • 把节点再加回来,这时候可以选重新格式化数据盘,mount 到 /var/lib/docker。
  • 再把之前的 Pod 收回到本节点就好了。

感觉还是不完善啊,像 Azure Kubernetes 的扩容就方便多了,不用整这么多麻烦事。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK