在Centos8|在Centos8 中使用Stratis管理本地存储(一)

Stratis是RHEL8/Centos8中提供的一个新的本地存储管理工具,它将有助于在块设备上创建分层存储。在RHEL8/Centos8中,可以通过安装两个软件包获得Stratis。在RHEL7,我们有了BTRFS文件系统,Red Hat在RHEL 8中删除了BTRFS支持,并提供了Stratis本地存储管理系统。
为了开始使用Stratis,我们需要添加一些磁盘设备,并创建一个单独的池,在一个Stratis池中,可以创建多个文件系统。
安装Stratis
通过下面命令使用yum安装stratis:
[root@localhost ~]# yum -y install stratis*
在Centos8 中使用Stratis管理本地存储(一)在Centos8 中使用Stratis管理本地存储(一)
安装完成之后,设置开机启用并立即启动:
[root@localhost ~]# systemctl enable stratisd --now
查看以下是否启动:
在Centos8 中使用Stratis管理本地存储(一)在Centos8 中使用Stratis管理本地存储(一)
列出可用磁盘
在这添加了5个2GB磁盘,使用下面命令列出磁盘:
[root@localhost ~]# lsblk
在Centos8 中使用Stratis管理本地存储(一)在Centos8 中使用Stratis管理本地存储(一)
列出现有的池和文件系统:
使用下面几条命令列出块设备、stratis池、文件系统:
[root@localhost ~]# stratis blockdev list
[root@localhost ~]# stratis pool list
[root@localhost ~]# stratis filesystem list
在Centos8 中使用Stratis管理本地存储(一)在Centos8 中使用Stratis管理本地存储(一)
创建池和文件系统
首先,我们创建“data01_pool”的池。将/dev/sda,/dev/sdb,/dev/sdc,/dev/sdd添加到该池中:
[root@localhost ~]# stratis pool create data01_pool /dev/sd{a..d}
[root@localhost ~]# stratis pool list
[root@localhost ~]# stratis blockdev list
在Centos8 中使用Stratis管理本地存储(一)在Centos8 中使用Stratis管理本地存储(一)
上面命令创建"data01_pool"池、查看池、查看块设备。
下面从“data01_pool”池中创建两个文件系统:
[root@localhost ~]# stratis filesystem create data01_pool user_data01
[root@localhost ~]# stratis filesystem create data01_pool user_data02
在Centos8|在Centos8 中使用Stratis管理本地存储(一)
文章图片

下面命令列出创建的文件系统:
[root@localhost ~]# stratis filesystem list
或者
[root@localhost ~]# stratis fs list
在Centos8 中使用Stratis管理本地存储(一)在Centos8 中使用Stratis管理本地存储(一)
上图中列出的文件系统中,字段Device是stratis设备的位置。
挂载创建好的文件系统
一旦从池中创建了文件系统,请创建一个挂载点并挂载文件系统。默认情况下在创建文件系统时,它将使用XFS文件系统对其进行格式化。
创建挂载点 [root@localhost ~]# mkdir /user_data01
[root@localhost ~]# mkdir /user_data02
挂载文件系统 [root@localhost ~]# mount /stratis/data01_pool/user_data01 /user_data01/
[root@localhost ~]# mount /stratis/data01_pool/user_data02 /user_data02/
在Centos8 中使用Stratis管理本地存储(一)在Centos8 中使用Stratis管理本地存储(一)
使用df -h查看挂载的情况:
[root@localhost ~]# df -h /user_data*
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/stratis-1-359fd7072d8349d390741a1a71f885fb-thin-fs-0657c26979ed443aa4d3a70c15606e1c 1.0T 7.2G 1017G 1% /user_data01
/dev/mapper/stratis-1-359fd7072d8349d390741a1a71f885fb-thin-fs-b91b970f23d94eb6b2ed56f347f770d2 1.0T 7.2G 1017G 1% /user_data02
在Centos8 中使用Stratis管理本地存储(一)在Centos8 中使用Stratis管理本地存储(一)
希望你已经观察到我们没有格式化文件系统。Stratis程序为我们解决了这一问题,并创建了XFS类型的文件系统。
同样,由于自动精简配置,默认情况下,它将显示文件系统大小为1 TB,并且该大小仅是虚拟的,而不是实际的。要检查实际大小,您将必须使用Stratis命令
使用df -hT /user*匹配出user_data01和user_data02挂载点的文件系统,可以看到他们的类型都是XFS格式。
在Centos8 中使用Stratis管理本地存储(一)在Centos8 中使用Stratis管理本地存储(一)
在/etc/fstab中添加开机挂载的条目
首先需要获取文件系统的UUID,有两种方式:
第一种方式,是通过使用stratis fs list就可以获取到文件系统的UUID。
[root@localhost ~]# stratis fs list
在Centos8 中使用Stratis管理本地存储(一)在Centos8 中使用Stratis管理本地存储(一)
第二种方式,使用blkid获取块存储的uuid,过滤出stratis文件系统:
[root@localhost ~]# blkid|grep stratis
在Centos8 中使用Stratis管理本地存储(一)在Centos8 中使用Stratis管理本地存储(一)
下面就是将挂在信息写入到/etc/fstab中:
[root@localhost ~]# echo "UUID=0657c26979ed443aa4d3a70c15606e1c /user_data01 xfs defaults,x-systemd.requires=stratis.service 0 0" >> /etc/fstab
[root@localhost ~]# echo "UUID=b91b970f23d94eb6b2ed56f347f770d2 /user_data02 xfs defaults,x-systemd.requires=stratis.service 0 0" >> /etc/fstab
在Centos8 中使用Stratis管理本地存储(一)在Centos8 中使用Stratis管理本地存储(一)
在Centos8|在Centos8 中使用Stratis管理本地存储(一)
文章图片

检查Stratis守护程序版本
如果需要检查Stratis运行的守护进程版本,使用如下命令:
[root@localhost ~]# stratis daemon version
2.1.0
在Centos8 中使用Stratis管理本地存储(一)在Centos8 中使用Stratis管理本地存储(一)
【在Centos8|在Centos8 中使用Stratis管理本地存储(一)】总结
Stratis是RHEL8/Centos8中提供的一个新的本地存储管理工具,它将有助于在块设备上创建分层存储。在RHEL8/Centos8中,可以通过安装两个软件包获得Stratis。

    推荐阅读