赞
踩
参考:https://blog.csdn.net/u010308917/article/details/125157774
添加自定义物理卷
–待补充–
fdisk -l
输出如下
Disk /dev/loop0: 73.9 MiB, 77492224 bytes, 151352 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
Disk /dev/loop1: 180.94 MiB, 189726720 bytes, 370560 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
Disk /dev/loop2: 40.86 MiB, 42840064 bytes, 83672 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
Disk /dev/sda: 200 GiB, 214748364800 bytes, 419430400 sectors
Disk model: VMware Virtual S
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: gpt
Disk identifier: CBA6DFE0-3C73-4BAD-8A3F-1A84C07DED81
Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 4198399 4194304 2G Linux filesystem
/dev/sda3 4198400 419428351 415229952 198G Linux filesystem
Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 sectors
Disk model: VMware Virtual S
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
新增 /dev/sdb 20g物理卷未被使用
fdisk /dev/sdb
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-419430399, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-419430399, default 419430399):
Created a new partition 1 of type ‘Linux’ and of size 200 GiB.
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition ‘Linux’ to ‘Linux LVM’.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
fdisk -l
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 41943039 41940992 20G 8e Linux LVM
Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 99 GiB, 106296246272 bytes, 207609856 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
已经被分配 sdb1
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
// 修改driver未zfs
/etc/docker/daemon.json
{
"storage-driver": "zfs"
}
zpool list
创建docker的挂载物理卷
zpool create -f mine-docker -m /var/lib/docker /dev/sdb1
注: /var/lib/docker 必须不存在,由该命令创建
创建docker快照
zfs snapshot mine-docker@start
zfs rollback docker@start
zpool destroy mine-docker@start
使用方式与zfs有所不同,需要使用subvolume创建Btrfs文件系统(专用目录)
btrfs subvolume create mine
btrfs subvolume del mine
创建btrfs
mkfs.btrfs -f /dev/sdb
挂载
mount -t btrfs /dev/sdb /var/lib/docker
安装docker
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
修改docker驱动
vim /etc/docker/daemon.json
{
"storage-driver": "btrfs"
}
docker info查看
https://zhuanlan.zhihu.com/p/31082518
fdisk -l 查看
将sdb1物理卷格式为btrfs
mkfs.btrfs -f /dev/sdb1
手动创建要挂载的文件夹
mkdir /var/lib/docker
将btrfs挂载sdb1
mount /dev/sdb1 /var/lib/docker
snapper -c mine create-config /var/lib/docker
snapper list-configs
snapper -c <配置名称> delete-config
snapper -c mine delete-config
snapper -c <配置名称> list
查询mine下有那些快照
snapper -c mine list
snapper -c <配置名称> create
snapper -c mine create -p
-p 会打印快照编号
snapper -c <配置名称> list
snapper -c mine list
snapper -c <配置名称> delete <快照 1 编号> [<快照 2 编号>…]
snapper -c mine delete 1
在/var/lib/docker
touch a.txt
snapper -c <配置名称> status <快照 1 编号>…<快照 2 编号>
snapper -c mine status 1..2
snapper -c <配置名称> undochange <快照编号>…<0>
# 由4回退到3
snapper -c mine undochange 3..4
lvm: 使用起来复杂,且备份占用内存,不太推荐使用
zfs(不推荐): 使用简单, 不占用内存,单独做文件夹得快照可以使用,使用docker得备份不推荐使用,docker启动会自动识别驱动器为zfs,docker-compose的回滚会直接出现容器找不到,docker直接挂掉
btrfs(不推荐): 问题有点多,没研究下去,跟zfs一样,docker会自动识别驱动器
snapper(推荐): zfs和btrfs都是通过操作snapper去实现的该功能,docker不会指定文件目录的驱动器,多次测试稳定的docker回滚,上手快,命令简单易使用
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。