Distributed volumes distributes files throughout the bricks in the volume. You can use distributed volumes where the requirement is to scale storage and the redundancy is either not important or is provided by other hardware/software layers.
In this tutorial, we are going to create a Distributed GlusterFS Volume Across two servers. Both servers we already installed Glusterfs server packages, if you didn’t installed yet you can take a look to this article describing ” How to Install and Setup GlusterFS Server on Centos 7 / RHEL 7 and Ubuntu 16.04 LTS“, have an empty disk attached as /dev/sdb. Using this disk, we will create a new logical volume (lv01) that will be mounted for the XFS bricks.
Step 1./ Preparing Servers:
– Configuring /etc/hosts
– GlusterFS components use DNS for name resolutions, if you do not have a DNS on your environment then update /etc/hosts file on every server and ensure that the host names of each server are accordingly resolvable.
# sudo vi /etc/hosts 192.168.1.20 glusterfs01.yallalabs.local glusterfs01 192.168.1.21 glusterfs02.yallalabs.local glusterfs02 192.168.1.30 client01.yallalabs.local client
– Configuring Firewall
– By default, glusterd will listen on tcp/24007, if you have firewall running, open the port or run below command on each node to allow all connections within the cluster nodes:
# firewall-cmd --zone=public --add-rich-rule='rule family="ipv4" source address="" accept' # firewall-cmd --reload
– Preparing Bricks
– Create the partition using the fdisk command:
# fdisk /dev/sdb ... Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): 1 .... Command (m for help): t Selected partition 1 Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM' .... Command (m for help): w
– Type the following command to inform the operating system kernel of creation of the new partition:
– Create a physical volume by using the pvcreate command:
# pvcreate /dev/sdb1 # vgcreate vg01 /dev/sdb1 # lvcreate -l 100%FREE -n lv01 vg01 # mkfs.xfs /dev/mapper/vg01-lv01
– Create a mountpoint brick directory using the following command:
# mkdir -p /gluster/bricks/brick1
– To mount the brick, we need to create an entry in /etc/fstab file :
# vi /etc/fstab /dev/mapper/vg01-lv01 /gluster/bricks/brick1 xfs defaults 0 0
Run the following command to mount the brick.
# mount -a
– Run the df -Th command to verify the brick is successfully mounted:
# df -h
Step 2./ Creating GlusterFS trusted Storage Pool
– To create a trusted GlusterFS storage pool, you can run the following command in the first node:
# gluster peer probe glusterfs02 peer probe: success.
– To verify the status of your node and the gluster server pool, run the following command:
# gluster pool list UUID Hostname State 54537353-2ec0-4f72-b719-6cd9788f4cf7 glusterfs02 Connected 26232d5d-eef3-412b-89d2-06b291a0c424 localhost Connected
Step 3./ Creating GlusterFS Volume
– Create the directory vol01 under /gluster/bricks/brick1/ directory:
# mkdir /gluster/bricks/brick1/vol1
– Create the volume using the following command:
# gluster volume create distvol glusterfs01:/gluster/bricks/brick1/vol1 glusterfs02:/gluster/bricks/brick1/vol1 Creation of distvol has been successful Please start the volume to access data.
– Start the volume using the following command:
# gluster volume start distvol Starting distvol has been successful
– To display the volume information just execute the following command:
# gluster volume info distvol Volume Name: distvol Type: Distribute Volume ID: 85eb66b3-5860-4b09-8d37-78eec98b622d Status: Started Snapshot Count: 0 Number of Bricks: 1 x 2 = 2 Transport-type: tcp Bricks: Brick1: glusterfs01:/bricks/brick1/vol1 Brick2: glusterfs02:/bricks/brick1/vol1 Options Reconfigured: nfs.disable: on transport.address-family: inet
We hope this tutorial was enough Helpful. If you need more information, or have any questions, just comment below and we will be glad to assist you!
If you like our content, please consider buying us a coffee. Thank you for your support!