GlusterFS is a scalable network filesystem that enables the pooling of storage resources under a global namespace. It's well-suited for cloud storage, media streaming, and data-intensive applications. GlusterFS combines simplicity, scalability, and performance by aggregating storage bricks over a network to form a unified large parallel filesystem.
GlusterFS uses a distributed architecture to connect storage devices over a network, creating a large filesystem. It implements a client-server model with data stored in "bricks" on servers. These bricks are mounted filesystems, and GlusterFS manages the distribution and replication of data across them, ensuring redundancy and availability.
Proper disk setup is crucial for optimal performance. Use tools like fdisk
or parted
to partition the drives, and format them with a filesystem (XFS is recommended).
Example for preparing a disk:
sudo mkfs.xfs /dev/sdb1
sudo mkdir -p /data/brick1
echo '/dev/sdb1 /data/brick1 xfs defaults 0 0' | sudo tee -a /etc/fstab
sudo mount -a
GlusterFS requires specific ports to be open for communication between the nodes. In addition to the default management port (24007
), each node will use an additional port for each brick it hosts. The range of ports used for bricks is defined in the /etc/glusterfs/glusterd.vol
file.
For example, if your /etc/glusterfs/glusterd.vol
specifies a port range of 49152-49251
, you need to allow this range through your firewall. Using firewalld
, you would add the necessary rules as follows:
sudo firewall-cmd --zone=public --add-port=111/tcp --permanent
sudo firewall-cmd --zone=public --add-port=111/udp --permanent
sudo firewall-cmd --zone=public --add-port=24007-24008/tcp --permanent
sudo firewall-cmd --zone=public --add-port=49152-49251/tcp --permanent
sudo firewall-cmd --reload
Install the GlusterFS server package on all nodes that will be part of the GlusterFS cluster.
sudo yum install -y glusterfs-server
sudo systemctl start glusterd
sudo systemctl enable glusterd
Create and start a GlusterFS volume after initializing all nodes.
sudo gluster peer probe server1
sudo gluster peer probe server2
sudo gluster volume create testvol replica 2 server1:/data/brick1 server2:/data/brick1 force
sudo gluster volume start testvol
Manage access to GlusterFS volumes using auth.allow
and auth.reject
options. This restricts volume access to specific IPs or networks.
Example to allow only certain IPs:
sudo gluster volume set testvol auth.allow 192.168.1.*
Install the GlusterFS client and mount the volume to access the distributed filesystem.
Installation on Ubuntu:
sudo apt install -y glusterfs-client
Mounting a volume:
sudo mkdir -p /mnt/glusterfs
sudo mount -t glusterfs server1:/testvol /mnt/glusterfs
To ensure the GlusterFS mount persists across reboots, add it to the /etc/fstab
file.
server1:/testvol /mnt/glusterfs glusterfs defaults,_netdev,backupvolfile-server=server2 0 0
This line in /etc/fstab
tells the system how to mount the GlusterFS volume automatically at boot time, including using an alternate server for the volume file if the primary is unavailable.