在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

下面命令列出創建的文件系統:

[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管理本地存儲(一)

檢查Stratis守護程序版本

如果需要檢查Stratis運行的守護進程版本,使用如下命令:

[root@localhost ~]# stratis daemon version 
2.1.0

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

總結

Stratis是RHEL8/Centos8中提供的一個新的本地存儲管理工具,它將有助於在塊設備上創建分層存儲。在RHEL8/Centos8中,可以通過安裝兩個軟件包獲得Stratis。文章第二部分:https://www.linuxprobe.com/?p=213460

本文原創地址:https://www.linuxprobe.com/linux-stratis-install.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章