在RHEL 8中,红帽推出了Stratis存储管理解决方案。与其他存储项目的尝试一样,Stratis 的开发并不是从零开始,而是使用现有的RHEL存储组件。Stratis 以管理物理存储设备池的服务形式运行,并透明地为所创建的文件系统创建和管理卷。由于Stratis使用现有的存储驱动程序和工具,因此Stratis也支持当前在LVM、XFS 和设备映射器中使用的所有高级存储功能。
一、Stratis文件系统介绍
Stratis 是一个卷管理文件系统volume-managing filesystem(VMF),类似于 ZFS 和 Btrfs。它使用了存储“池”的核心思想,该思想被各种 VMF 和 形如 LVM 的独立卷管理器采用。VMF 更进一步与文件系统层结合起来。用户无需在卷上部署选取的文件系统,因为文件系统和卷已经被合并在一起,成为一个概念上的文件树(ZFS 称之为数据集dataset,Brtfs 称之为子卷subvolume,Stratis 称之为文件系统),文件数据位于存储池中,但文件大小仅受存储池整体容量限制。
Stratis分层高级的存储功能
- 自动精简配置Thin provisioning
- 文件系统快照File system snapshots
- 基于池的存储管理Pool-based management
- 存储监控Monitoring
二、创建使用Stratis文件系统
需要先安装相关软件包,并启用
[root@serverb ~]# yum install stratis-cli stratisd
[root@serverb ~]# systemctl enable --now stratisd
创建文件系统
[root@serverb ~]# stratis pool create pool1 /dev/vdb
[root@serverb ~]# ls /stratis/
pool1
[root@serverb ~]# ls /stratis/pool1/
[root@serverb ~]# stratis pool list
Name Total Physical
pool1 5 GiB / 37.63 MiB / 4.96 GiB
[root@serverb ~]# stratis pool add-data pool1 /dev/vdc
[root@serverb ~]# stratis blockdev list pool1
Pool Name Device Node Physical Size Tier
pool1 /dev/vdb 5 GiB Data
pool1 /dev/vdc 5 GiB Data
[root@serverb ~]# stratis filesystem create pool1 filesystem1
[root@serverb ~]# ls /stratis/pool1/filesystem1
/stratis/pool1/filesystem1
[root@serverb ~]# ls /stratis/pool1/filesystem1 -l
lrwxrwxrwx. 1 root root 9 Apr 12 23:59 /stratis/pool1/filesystem1 -> /dev/dm-5
[root@serverb ~]# stratis filesystem list
Pool Name Name Used Created Device UUID
pool1 filesystem1 546 MiB Apr 12 2021 23:59 /stratis/pool1/filesystem1 8329587deb4a4980b1f71578c7de7723
[root@serverb ~]# lsblk --output=UUID /stratis/pool1/filesystem1
UUID
8329587d-eb4a-4980-b1f7-1578c7de7723
挂载使用
[root@serverb ~]# grep stratis /etc/fstab
UUID=8329587d-eb4a-4980-b1f7-1578c7de7723 /opt xfs defaults,x-systemd.requires=stratisd.service 0 0
[root@serverb ~]# mount -a
x-systemd.requires=stratisd.service挂载选项可延迟挂载文件系统,直到systemd在启动过程中启动stratisd. service为止。
三、快照的使用
使用该挂载点并创建文件后,并创建快照,快照创建完成后删除相应的文件,并回到快照里查看原始数据是否存在。
[root@serverb opt]# touch file{1..5}
[root@serverb opt]# ls
file1 file2 file3 file4 file5
[root@serverb opt]# echo "snapshot test!!!" > file1
echo "snapshot testls!" > file1
[root@serverb opt]# cat file
cat: file: No such file or directory
[root@serverb opt]# cat file1
snapshot testls!
[root@serverb opt]# stratis filesystem destroy pool1 snapshot1
[root@serverb opt]# stratis filesystem list
Pool Name Name Used Created Device UUID
pool1 filesystem1 546 MiB Apr 12 2021 23:59 /stratis/pool1/filesystem1 8329587deb4a4980b1f71578c7de7723
[root@serverb opt]# stratis filesystem snapshot pool1 filesystem1 snapshot1
[root@serverb opt]# ll
total 4
-rw-r--r--. 1 root root 17 Apr 13 09:49 file1
-rw-r--r--. 1 root root 0 Apr 13 09:49 file2
-rw-r--r--. 1 root root 0 Apr 13 09:49 file3
-rw-r--r--. 1 root root 0 Apr 13 09:49 file4
-rw-r--r--. 1 root root 0 Apr 13 09:49 file5
[root@serverb opt]# rm -rf file1 //删除文件
[root@serverb opt]# stratis filesystem list
Pool Name Name Used Created Device UUID
pool1 filesystem1 546 MiB Apr 12 2021 23:59 /stratis/pool1/filesystem1 8329587deb4a4980b1f71578c7de7723
pool1 snapshot1 546 MiB Apr 13 2021 09:54 /stratis/pool1/snapshot1 9073ac6f15d14153bd850b83748ad992
[root@serverb opt]# mount /stratis/pool1/snapshot1 /mnt/
[root@serverb opt]# cd /mnt/
[root@serverb mnt]# ls
file1 file2 file3 file4 file5
[root@serverb mnt]# cat file1 //从快照数据中找回文件
snapshot testls!
四、文件系统及快照的销毁
在destory删除操作之前,需要先umount掉相关的挂载点。不然会报错,具体的操作如下:
[root@serverb ~]# stratis pool list
Name Total Physical
pool1 10 GiB / 1.11 GiB / 8.89 GiB
[root@serverb ~]# stratis filesystem destroy pool1 snapshot1
Execution failed:
stratisd failed to perform the operation that you requested. It returned the following information via the D-Bus: ERROR: low-level ioctl error due to nix error: EBUSY: Device or resource busy.
[root@serverb ~]# umount /mnt
[root@serverb ~]# stratis filesystem destroy pool1 snapshot1
[root@serverb ~]# stratis pool list
Name Total Physical
pool1 10 GiB / 587.65 MiB / 9.43 GiB
[root@serverb ~]# umount /opt
[root@serverb ~]# stratis filesystem destroy pool1 filesystem1
[root@serverb ~]# stratis filesystem list
Pool Name Name Used Created Device UUID
如果pool也不再使用,可以使用stratis pool destroy pool1 指令把pool也删除掉。