In this blog, we will explore the distributed volume configuration of GlusterFS
Blog Series
Creating a Distributed Volume on an XFS Filesystem
We’ll next create a distributed volume on a new disk and will configure this as an XFS filesystem.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
root@gluster01:~# mkfs.xfs /dev/sdb meta-data=/dev/sdb isize=512 agcount=4, agsize=1310720 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=1, sparse=1, rmapbt=0 = reflink=1 data = bsize=4096 blocks=5242880, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0, ftype=1 log =internal log bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 root@gluster01:~# root@gluster01:~# root@gluster01:~# blkid /dev/sdb /dev/sdb: UUID="e5401130-bb60-4873-bac9-7c3799e7acd9" TYPE="xfs" root@gluster01:~# |
How to mount an xfs file system
1 2 3 4 5 6 7 |
root@gluster01:~# mkdir /glusterfs root@gluster01:~# root@gluster01:~# mount /dev/sdb /glusterfs/ root@gluster01:~# df -HT /glusterfs/ Filesystem Type Size Used Avail Use% Mounted on /dev/sdb xfs 22G 184M 22G 1% /glusterfs |
Creating a Distributed Volume
In a distributed volume files are spread randomly across the bricks in the volume so that means in short no redundancy is provided at hardware layers and data is just spread around as shown
Create a Gluster FS Volume
1 2 3 4 |
root@gluster01:/# gluster vol create test-distributed-stripe gluster01:/glusterfs/brick-stripe1 gluster02:/glusterfs/brick-stripe2 gluster03:/glusterfs/brick-stripe3 volume create: test-distributed-stripe: success: please start the volume to access data root@gluster01:/# root@gluster01:/# |
Verify the Gluster volume info
As seen, we can now notice that in distributed volume my data is split on every server participating in my cluster.
1 |
root@gluster01:/glusterfs# gluster volume info |
Start the volume
1 2 3 |
root@gluster01:/# gluster vol start test-distributed-stripe volume start: test-distributed-stripe: success root@gluster01:/# |
Mount the GlusterFS
With all this in place, we can test the GlusterFS distributed file system. On gluster01, gluster02, and gluster03 issue the command to mount the GlusterFS volume to a mount point. I’ve created a new directory named as /demo so we will mount our F.S to it.
1 2 3 |
mount -t glusterfs gluster01:/test-distributed-stripe /demo ssh gluster02 mount -t glusterfs gluster02:/test-distributed-stripe /demo ssh gluster03 mount -t glusterfs gluster03:/test-distributed-stripe /demo |
Accessing Data – Setting Up GlusterFS Client
There are several ways you can mount the GlusterFS – ( NFS, CIFS, and Gluster FS ) are all supported. In this demo, we will just stick with the default glusterfs client.
1 2 3 4 5 6 7 |
root@gluster04:~# sudo apt install glusterfs-client -y Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: attr glusterfs-common ibverbs-providers libgfapi0 libgfchangelog0 libgfrpc0 libgfxdr0 libglusterfs0 libibverbs1 libnl-route-3-200 librdmacm1 libtirpc-common libtirpc3 python3-prettytable |
Mount the distributed file system with the command:
1 |
root@gluster04:~# mount -t glusterfs gluster01:/test-distributed-stripes /distributed-cluster |
Automatically Mounting Volumes
You can configure your system to automatically mount the Gluster volume each time your system starts.
1 2 |
root@gluster04:~# tail -2 /etc/fstab gluster01:/test-distributed-stripe /mnt/glusterfs glusterfs defaults,_netdev 0 0 |
Testing the Filesystem
With all this in place, i will just put a small for loop to create several files from my client
1 2 3 4 |
for f in {a..z} {A..Z} {0..99} do echo hello > "$f.txt" done |
Verification from Gluster level
I can see all my files on all my cluster nodes
GlusterFS distributed file system is finally up and running.