GlusterFS is one of the best open source distributed file systems. If you want a highly available distributed file system for your applications, GlusterFs is one of the good options.
Now: AWS offers a managed scalable file storage called Elastic File System. If you don’t want the administrative overhead of glusterFS clusters, you can give EFS a try.
GlusterFS Cluster On AWS Ec2
This guide covers all the necessary steps to setup a GlusterFs cluster using ec2 instances and extra EBS volumes. Here we are setting up a two node cluster, however, you can increase the node count based on your needs.
Instance Configurations
1. Create two instances with extra EBS volumes.
2. Make sure the instances can talk to each other.
3. Login to the servers and set the hostnames as node1 and node2 using the following commands.
1
2
|
hostnamectl set–hostname node1
hostnamectl set–hostname node2
|
Run bash
on the terminal for the hostname to show up.
4. Make an entry in the /etc/hosts
file with the IP and hostname of both servers as shown below. The IP’s should be resolvable using the hostnames. Change the IP in the following to your server IP’s.
1
2
|
172.31.21.201 node1
172.31.21.202 node2
|
Instance Port Configuration
You need to open the following ports int he ec2 security groups as well the server firewall if it is enabled.
1
2
3
4
5
|
111
24007 – <code>GlusterFS Daemon.
24008 – <code>GlusterFS Management
38465 to 38467 – <code>GlusterFS NFS service
49152 to n – <code>Depends on number of bricks.
|
Create Mount Points For EBS Volumes
You need to do the following in both the ec2 instances. 1. Format the volume to xfs.
sudo mkfs –t xfs /dev/xvdb
|
xvdb
is the name of the EBS volume. You can list the available devices using lsblk
command.
2. Create a mount directory named /gshare
and mount the formated volume.
1
2
|
sudo mkdir /gshare
sudo mount /share /dev/xvdb
|
3. Add the mount to /etc/fstab
1
|
/dev/xvdb /gshare xfs defaults,nofail
|
GlusterFS Installation
Perform the following steps on both the servers.
1. Create a GlusterFs repo.
1
|
sudo vi /etc/yum.repos.d/Gluster.repo
|
Copy the following to the repo file.
1
2
3
4
5
|
[gluster38]
name=Gluster 3.8
baseurl=http://mirror.centos.org/centos/7/storage/$basearch/gluster-3.8/
gpgcheck=
enabled=1
|
2. Install GlusterFS server.
1
|
sudo yum install glusterfs–server –y
|
3. Start and verify the glusterd service.
1
2
|
sudo systemctl start glusterd
sudo systemctl status glusterd
|
GlusterFs Configuration
1. Form node1 execute the following command to create a trusted storage pool with node2.
1
|
sudo gluster peer probe node2
|
After successful execution, you would get peer probe: success.
as output.
2. Check the peer status using the following command.
1
2
3
4
5
6
7
|
[ec2–user@node1 ~]$ <code>sudo gluster peer status
Number of Peers: 1
Hostname: node2
Uuid: 47ee8304–36ea–4b95–9214–4854bc98b737
State: Peer in Cluster (Connected)
[ec2–user@node1 ~]$
|
3. Create a data
directory on gshare
mount on both the servers.
1
|
sudo mkdir /gshare/data
|
4. Create a GlusterFS HA shared volume.
1
|
sudo gluster volume create gdata replica 2 node1:/gshare/data node2:/gshare/data
|
5. Start the gdata
volume.
1
|
sudo gluster volume start gdata
|
6. By default NFS is disabled. If you want NFS functionality for glusterFs volume, you can enable it using the following command.
sudo gluster volume set gdata nfs.disable off
|
7. Set the volume permissions for gdata
volume for client access. Here I am using 172.*
CIDR. You need to replace it based on your network range.
1
|
sudo gluster volume set gdata auth.allow “172.*”
|
7. To get all the info about the volume, execute the following command.
1
|
sudo gluster volume info gdata
|
GlusterFS Client Setup
1. Enable fuse
kernel module.
1
|
sudo modprobe fuse
|
2. Install all the glusterFS client dependencies.
1
|
sudo yum install fuse fuse–libs openib libibverbs –y
|
3. Install the GlusterFS client.
1
|
sudo yum install glusterfs–client –y
|
GlusterFS Client Configuration
The data will get replicated only if you are writing from a GlusterFS client. You can mount the GlusterFS volume to any number of clients. We highly recommend you to map the gluster nodes to a domain name and use it with the clients for mounting.
Note A client machine is not part of the glusterFS cluster. It is the machine in which you want to mount the replicated volume.
1. Create a client mount directory.
1
|
sudo mkdir /gfdata
|
2. Mount gfdata
directory to the glusterFS replicated volume.
1
|
sudo mount –t glusterfs node1:/gdata /gfdata
|
Troubleshooting GlusterFs
1. You can view all the logs of gluserFS server on the following directory.
1
|
/var/log/glusterfs
|
To monitor logs in real time you can use tail -f
along with the path to log file.
2. All glusterfs client logs are saved in the following with the volume name.
1
|
/var/log/glusterfs/
|