阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

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

31次阅读
没有评论

共计 2586 个字符,预计需要花费 7 分钟才能阅读完成。

导读 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 管理本地存储(一)
安装完成之后,设置开机启用并立即启动:

[root@localhost ~]# systemctl enable stratisd --now

查看以下是否启动:
在 Centos8 中使用 Stratis 管理本地存储(一)

列出可用磁盘

在这添加了 5 个 2GB 磁盘,使用下面命令列出磁盘:

[root@localhost ~]# lsblk

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

列出现有的池和文件系统:

使用下面几条命令列出块设备、stratis 池、文件系统:

[root@localhost ~]# stratis blockdev list 
[root@localhost ~]# stratis pool list
[root@localhost ~]# stratis filesystem list

在 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 管理本地存储(一)
上面命令创建 ”data01_pool” 池、查看池、查看块设备。

下面从“data01_pool”池中创建两个文件系统:

[root@localhost ~]# stratis filesystem create data01_pool user_data01
[root@localhost ~]# stratis filesystem create data01_pool user_data02

下面命令列出创建的文件系统:

[root@localhost ~]# stratis filesystem list 
或者
[root@localhost ~]# stratis fs list

在 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 管理本地存储(一)
使用 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 管理本地存储(一)
希望你已经观察到我们没有格式化文件系统。Stratis 程序为我们解决了这一问题,并创建了 XFS 类型的文件系统。

同样,由于自动精简配置,默认情况下,它将显示文件系统大小为 1 TB,并且该大小仅是虚拟的,而不是实际的。要检查实际大小,您将必须使用 Stratis 命令

使用 df -hT /user* 匹配出 user_data01 和 user_data02 挂载点的文件系统,可以看到他们的类型都是 XFS 格式。
在 Centos8 中使用 Stratis 管理本地存储(一)

在 /etc/fstab 中添加开机挂载的条目

首先需要获取文件系统的 UUID,有两种方式:

第一种方式,是通过使用 stratis fs list 就可以获取到文件系统的 UUID。

[root@localhost ~]# stratis fs list

在 Centos8 中使用 Stratis 管理本地存储(一)
第二种方式,使用 blkid 获取块存储的 uuid,过滤出 stratis 文件系统:

[root@localhost ~]# blkid|grep 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 管理本地存储(一)

检查 Stratis 守护程序版本

如果需要检查 Stratis 运行的守护进程版本,使用如下命令:

[root@localhost ~]# stratis daemon version 
2.1.0

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

总结

Stratis 是 RHEL8/Centos8 中提供的一个新的本地存储管理工具,它将有助于在块设备上创建分层存储。在 RHEL8/Centos8 中,可以通过安装两个软件包获得 Stratis。文章第二部分:https://www.linuxprobe.com/?p=213460

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2024-07-25发表,共计2586字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中