GlusterFS, an open-source distributed file system developed by RedHat, offers a scalable solution for managing large volumes of data. With its ease of installation and maintenance, GlusterFS is an ideal choice for businesses seeking high-availability file system storage. In this comprehensive guide, we will walk you through the process of installing and configuring GlusterFS on AlmaLinux 9 servers.
Prerequisites
Before we begin, make sure you have the following:
- Two or more AlmaLinux 9 servers (for this guide, we’ll use srv1 with the IP address 192.168.10.41 and srv2 with the IP address 192.168.10.42)
- A non-root user with root administrator privileges
- A separate disk for creating the GlusterFS cluster
Preparing Disk and Partition
To ensure the safety of your data, it is recommended to use a dedicated disk for creating the GlusterFS cluster. In this guide, we will use the /dev/sdb disk on both servers.
- Check the available disks on your system by running the following command:
sudo fdisk -l
- Create a new partition on the /dev/sdb disk by executing the command:
sudo fdisk /dev/sdb
- Press
n
to create a new partition. - Select
p
for primary partition type. - Choose partition number
1
. - Leave the first and last sector as default.
- Press
w
to save the changes.
- Format the newly created partition (/dev/sdb1) with the ext4 file system:
sudo mkfs.ext4 /dev/sdb1
- Create two directories on each server that will serve as the mount points for the GlusterFS volume:
# Runthis on srv1 sudo mkdir -p /data/vol1 # Runthis on srv2 sudo mkdir -p /data/vol2
- Mount the /dev/sdb1 partition to the respective directories on each server:
# Runthis on srv1 sudo mount /dev/sdb1 /data/vol1 sudo mkdir -p /data/vol1/brick0 # Runthis on srv2 sudo mount /dev/sdb1 /data/vol2 sudo mkdir -p /data/vol2/brick0
Configuring FQDN
To ensure proper communication between the AlmaLinux servers, we need to set up fully qualified domain names (FQDNs) for each server.
- Set the hostname for srv1 and srv2:
sudo hostnamectl set-hostname srv1.example.lan sudo hostnamectl set-hostname srv2.example.lan
- Open the /etc/hosts file using the nano editor:
sudo nano /etc/hosts
- Add the following configuration, replacing the IP addresses and hostnames with the appropriate values:
192.168.10.41 srv1.example.lan srv1 192.168.10.42 srv2.example.lan srv2
- Save and exit the file.
- Verify the FQDN configuration and IP address mapping with the following command:
sudo hostname -f ping -c3 srv1.example.lan ping -c3 srv2.example.lan
Installing GlusterFS
Now that we have prepared the servers and configured the FQDNs, we can proceed with installing GlusterFS.
- Add the GlusterFS repository to your servers by running the following command:
sudo dnf install centos-release-gluster9
- Verify the list of repositories on your system to ensure the GlusterFS repository is added:
sudo dnf repolist
- Install the GlusterFS packages on each server:
sudo dnf install glusterfs glusterfs-libs glusterfs-server
- Add the GPG key of the GlusterFS repository:
sudo dnf install glusterfs glusterfs-libs glusterfs-server
- Start and enable the glusterfsd service:
sudo systemctl enable glusterfsd.service sudo systemctl start glusterfsd.service
- Verify the status of the glusterfsd service:
sudo systemctl status glusterfsd.service
- Configure the firewall to allow GlusterFS traffic:
sudo firewall-cmd --add-service=glusterfs --permanent sudo firewall-cmd --reload
- Verify the list of available services on the firewall:
sudo firewall-cmd --list-all
Initializing GlusterFS Cluster
With GlusterFS installed and the firewall configured, we can now initialize the GlusterFS cluster.
- On srv1, initialize the GlusterFS cluster by running the following command, replacing
srv2.hwdomain.lan
with the FQDN of your second server:
sudo gluster peer probe srv2.example.lan
- Check the GlusterFS cluster status on srv1:
sudo gluster peer status
- Switch to srv2 and verify the GlusterFS cluster status:
sudo gluster peer status
Creating GlusterFS Volume
Now that the GlusterFS cluster is initialized, we can create a GlusterFS volume that will be mounted by client machines.
- Create a new GlusterFS volume named
testvol
with two replicas on srv1 and srv2:
sudo gluster volume create testvol replica 2 srv1.example.lan:/data/vol1/brick0 srv2.example.lan:/data/vol2/brick0
- Start the
testvol
volume:
sudo gluster volume start testvol
- Verify the status of the GlusterFS volume:
sudo gluster volume status
- Obtain detailed information about the GlusterFS volume:
sudo gluster volume info
Mounting GlusterFS Volume to Client
To access the GlusterFS volume from client machines, we need to install the GlusterFS client package and mount the volume.
- Install the GlusterFS client package on your client machine:
sudo dnf install centos-release-gluster9 sudo dnf install glusterfs-client
- Create a directory on the client machine for mounting the GlusterFS volume:
sudo mkdir -p /backup
- Mount the
testvol
volume from srv1 to the /backup directory on the client machine:
sudo mount.glusterfs srv1.example.lan:/testvol /backup
- Verify the list of mounted file systems on the client machine:
sudo df -h
- Access the mounted volume and perform read and write operations:
cd /backup touch file{1..5}.md ls
- Verify that the files are replicated to the GlusterFS cluster:
# Runthis on srv1 ls /data/vol1/brick0 # Runthis on srv2 ls /data/vol2/brick0
Conclusion
Congratulations! You have successfully installed GlusterFS on AlmaLinux 9 and created a GlusterFS cluster using two servers. By following this guide, you have learned how to prepare disks and partitions, configure FQDNs, install GlusterFS, initialize the cluster, create volumes, and mount them on client machines.
With GlusterFS, you can now store and manage large volumes of data efficiently and securely. If you require robust and scalable cloud hosting solutions, consider exploring Shape.host’s SSD Linux VPS services. Shape.host offers reliable and high-performance hosting options to meet your business needs.
Remember to refer to the official documentation for detailed information on advanced GlusterFS configurations and maintenance tasks. Happy GlusterFS deployment!