Latest

Wednesday, 18 December 2019

Configure Stratis Local Storage on CentOS 8

Configure Stratis Local Storage on CentOS 8

Stratis is a Linux local storage management tool that aims to enable easy use of advanced storage features such as thin provisioning, snapshots, and pool-based management & monitoring.

Stratis daemon is originally developed by Red Hat. Stratis is written in RUST language and distributed under Mozilla Public License 2.0. Stratis provides ZFS/Btrfs-style features by integrating layers of existing technology: Linux's device mapper subsystem, and the XFS filesystem.

In this article, we will install and configure Stratis local storage on CentOS 8.

 

Table of Contents:

 Configure Stratis Local Storage on CentOS 8

Stratis Storage Features:

Stratis storage provides following advanced features.

  • Thin Provisioning
  • Pool Based Management and Monitoring
  • FileSystem Snapshots

 

Stratis Storage Building Blocks:

To understand Stratis Storage architecture, you need know the following three buidling blocks.

  • Block Device: A block device can be a disk, partition or Logical Volume (LVM).
  • Storage Pool: A Stratis storage pool consist of one or more Block devices.
  • FileSystem: A FileSystem is a final ready to mount storage. It is provisioned from a Storage Pool.

 

Environment Specification:

We have provisioned virtual machine with minimally installed CentOS 8 with following specification.

  • CPU - 3.4 Ghz (2 cores)
  • Memory - 1 GB
  • Storage - 20 GB
  • Operating System - CentOS 8.0
  • Hostname - stratis-01.centlinux.com
  • IP Address - 192.168.116.206 /24

 

Installing Stratis Local Storage on CentOS 8:

Connect with stratis-01.centlinux.com using ssh as root user.

To setup Stratis Local Storage on CentOS 8, we have to install following two packages.

  • stratisd - Stratis Daemon
  • stratis-cli - Command-line interface to manage stratis local storage.

Both packages are available in default dnf repository, therefore, we are installing it using dnf command.

# dnf install -y stratisd stratis-cli

Installer automatically enables the stratisd service. We are only required to start stratisd service once.

# systemctl start stratisd.service

Stratis has been successfully installed on CentOS 8.

 

Creating Stratis Storage Pools:

We have added four hard disks (10GB each) in our CentOS 8 virtual machine. We will use these disks as block devices for our Stratis storage pools.

# lsblk | grep 'sd[b-e]'
sdb    8:16   0   10G  0 disk
sdc    8:32   0   10G  0 disk
sdd    8:48   0   10G  0 disk
sde    8:64   0   10G  0 disk

Check current storage pools.

# stratis pool list
Name    Total Physical Size  Total Physical Used

Right now, we have no storage pool defined.

Let's create a Stratis storage pool using /dev/sdb block device.

# stratis pool create db_pool /dev/sdb

Check current storage pools again.

# stratis pool list
Name       Total Physical Size  Total Physical Used
db_pool                 10 GiB               52 MiB

 

Add a Block Device to Existing Stratis Storage Pool:

Let's add our second disk to the db_pool stratis storage pool.

# stratis pool add-data db_pool /dev/sdc

Check current storage pools list.

# stratis pool list
Name       Total Physical Size  Total Physical Used
db_pool                 20 GiB               56 MiB

You can see that the total size of the db_pool has been increased.

 

Create Stratis Storage Pool from Multiple Block Devices:

We can alternatively, create a pool using multiple block devices in a single command.

# stratis pool create backup_pool /dev/sdd /dev/sde

Check current storage pools now.

# stratis pool list
Name       Total Physical Size  Total Physical Used
backup_pool             20 GiB               56 MiB
db_pool                 20 GiB               56 MiB

 

Creating Stratis FileSystems:

We have a Stratis storage pool, we can now use it to provision Stratis filesystems as follows.

# stratis fs create db_pool prod_db_fs
# stratis fs create db_pool test_db_fs

Check the list of Stratis filesystems.

# stratis fs list
Pool Name  Name        Used     Created            Device                       UUID
db_pool    prod_db_fs  546 MiB  Dec 17 2019 22:22  /stratis/db_pool/prod_db_fs  d62f6884dffc40a6b8024784b7f60ca8
db_pool    test_db_fs  546 MiB  Dec 17 2019 22:22  /stratis/db_pool/test_db_fs  9ce32861f56b408597550d88e9bf5a44

 

Mounting the Stratis FileSystems:

We have create two Stratis filesystems, one for our Production database (prod_db_fs) and the other for the Test database (test_db_fs).

Now it's time to mount these filesystems.

To mount these filesystems, we need to identify the UUID of the filesystems. We can obtain the UUID using following command.

# blkid | grep /dev/mapper/stratis
/dev/mapper/stratis-1-c943c04939f5432cbe4d3d9985cd462e-thin-fs-d62f6884dffc40a6b8024784b7f60ca8: UUID="d62f6884-dffc-40a6-b802-4784b7f60ca8" TYPE="xfs"
/dev/mapper/stratis-1-c943c04939f5432cbe4d3d9985cd462e-thin-fs-9ce32861f56b408597550d88e9bf5a44: UUID="9ce32861-f56b-4085-9755-0d88e9bf5a44" TYPE="xfs"

We can use these UUIDs to persistently mount our Stratis filesystems.

Create directories to mount Stratis filesystems.

# mkdir /mnt/{prod,test}

Edit /etc/fstab to add automount entries.

# vi /etc/fstab

Add entries for our Stratis filesystems therein.

UUID=d62f6884-dffc-40a6-b802-4784b7f60ca8       /mnt/prod       xfs     defaults,x-systemd.requires=stratisd.service    0 0
UUID=9ce32861-f56b-4085-9755-0d88e9bf5a44       /mnt/test       xfs        defaults,x-systemd.requires=stratisd.service    0 0

Execute following command to update systemd units generated from this file.

# systemctl daemon-reload

Mount all entries in /etc/fstab using mount command.

# mount -a

Verify that our Stratis filesystem are mounted correctly.

# mount | grep /dev/mapper/stratis
/dev/mapper/stratis-1-c943c04939f5432cbe4d3d9985cd462e-thin-fs-d62f6884dffc40a6b8024784b7f60ca8 on /mnt/prod type xfs (rw,relatime,seclabel,attr2,inode64,sunit=2048,swidth=2048,noquota,x-systemd.requires=stratisd.service)
/dev/mapper/stratis-1-c943c04939f5432cbe4d3d9985cd462e-thin-fs-9ce32861f56b408597550d88e9bf5a44 on /mnt/test type xfs (rw,relatime,seclabel,attr2,inode64,sunit=2048,swidth=2048,noquota,x-systemd.requires=stratisd.service)

 

Creating Snapshot of Stratis FileSystems:

Copy some data in /mnt/prod directory.

# cp -r /etc/[a-f]* /mnt/prod

We can take snapshot of the prod_db_fs filesystem using following command.

# stratis fs snapshot db_pool prod_db_fs prod_db_bkp_17dev2019

Check Stratis filesystems.

# stratis fs list
Pool Name  Name                   Used     Created            Device                                  UUID
db_pool    prod_db_bkp_17dev2019  577 MiB  Dec 17 2019 23:28  /stratis/db_pool/prod_db_bkp_17dev2019  b4583769df9e40d790a55f11b705b65d
db_pool    prod_db_fs             577 MiB  Dec 17 2019 22:22  /stratis/db_pool/prod_db_fs             d62f6884dffc40a6b8024784b7f60ca8
db_pool    test_db_fs             546 MiB  Dec 17 2019 22:22  /stratis/db_pool/test_db_fs             9ce32861f56b408597550d88e9bf5a44

A Stratis Snapshot is also a Stratis filesystem, therefore, we can mount it inplace of the actual filesystem to restore a previous state of data, without required to remove the existing filesystem.

 

Removing a Stratis FileSystem:

To remove a filesystem, make sure it is not mounted and then remove it using following command.

# umount /mnt/test
# stratis fs destroy db_pool test_db_pool

 

Removing a Stratis Storage Pool:

To remove a Stratis Storage, make sure that, there isn't any filesystem exists within that pool.

Remove an existing storage pool using following command.

# stratis pool destroy backup_pool

 

Conclusion:

We have successfully installed and configured Stratis local storage on CentOS 8 and explored some of it's advanced features like thin-provisioning and snapshots.

If you find this article useful? Consider supporting us by Buy Me A Coffee


No comments:

Post a Comment

© 2022 CentLinux. All Rights Reserved.