How to Install and Configure GlusterFS on Ubuntu 16.04

By Hitesh Jethva, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud’s incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.

GlusterFS is a free, open source and scalable network filesystem specially designed for data-intensive tasks such as cloud storage and media streaming. GlusterFS made up of two components a server and a client. The server runs glusterfsd and the client used to mount the exported filesystem. You can achieve high availability by distributing the data across the multiple volumes/nodes using GlusterFS. GlusterFS client can access the storage like local storage. GlusterFS is a file-based scale-out storage that allows you to combine large numbers of commodity storage and compute resources into a high performance and virtualized pool. You can scale both capacity and performance on demand from terabytes to petabytes.

Features

  1. Global namespace and Clustered storage.
  2. Modular and stackable.
  3. Highly available storage.
  4. Built-in replication and geo-replication.
  5. Self-healing and ability to re-balance data.
  6. Software only, runs on commodity hardware.
  7. Multi-brick Block Device volumes and Quota Scalability.

In this tutorial, we will be setting up GlusterFS with two replicas on three Alibaba Cloud Elastic Compute Service (ECS) instances with Ubuntu 16.04.

Requirements

  1. Two fresh Alibaba cloud instance for GlusterFS server with Ubuntu 16.04 and 2 GB external HDD on each.
  2. One fresh Alibaba cloud instance for GlusterFS client with Ubuntu 16.04 installed.
  3. A static IP address 192.168.0.101 on GlusterFS1 192.168.0.102 on GlusterFS2 and 192.168.0.103 on GlusterFS client is configured.

Launch Alibaba Cloud ECS Instance

First, log in to your https://ecs.console.aliyun.com">Alibaba Cloud ECS Console. Create a new ECS instance, choosing Ubuntu 16.04 as the operating system with at least 2GB RAM. Connect to your ECS instance and log in as the root user.

Once you are logged into your Ubuntu 16.04 instance, run the following command to update your base system with the latest available packages.

Configure Hostname Resolution

Before starting, you will need to setup /etc/hosts file on each instance. So each instance can communicate with each other using hostname. You can do this by editing /etc/hosts file on each instance:

Add the following lines:

Save and close the file. Then verify hostname resolution using the following command:

Install GlusterFS

Before starting, you will need to install GlusterFS on both GlusterFS instance. By default, GlusterFS is not available in the Ubuntu 16.04 default repository. So you will need to add the repository for that. You can do this by running the following command on both instance:

Output:

Once the repository is added, update the repository and install the GlusterFS by running the following command:

Next, start the GlusterFS service and enable it to start on boot time with the following command:

You can check the status of GlusterFS with the following command:

Output:

Configure GlusterFS Storage

First, you will need to create a partition on external HDD (/dev/sdb) on both GlusterFS instance.

You can create a partition by running the following command on both instance:

Output:

Now, format the partition with the following command:

Output:

Next, create a storage directory for GlusterFS and mount the partition (/dev/sdb1) on it:

Next, create a persistent mount point by editing /etc/fstab file:

Add the following line:

Save and close the file, when you are finished.

Configure GlusterFS Storage Pool

You will also need to create a trusted storage pool on GlusterFS1 instance by adding GlusterFS2 on it. You can do this by running the following command on GlusterFS1 server:

You can verify the status of the trusted storage pool with the following command:

Output:

You can also list the storage pool with the following command:

Output:

Configure GlusterFS Volume

Next, you will need to create a brick directory with name gvol0 in the mounted file system on both GlusterFS instance:

Now, create the volume named “gvol0” with two replicas by running the following command on GlusterFS1 instance:

Output:

Now, start the volume with the following command:

You can now check the status of created volume with the following command:

Output:

Configure GlusterFS Client

First, you will need to install glusterfs-client package on GlusterFS-Client instance. By default, GlusterFS Client package is not available in the Ubuntu 16.04 default repository. So you will need to add the repository for that. You can do this by running the following command:

Once the repository is added, update the repository and install the GlusterFS CLient by running the following command:

Next, create a directory to mount GlusterFS filesystem:

Now, mount the GlusterFS file system on /glusterfs with the following command:

You can verify the mounted GlusterFS file system with the following command:

Output:

Next, create a persistent mount point by editing /etc/fstab file:

Add the following line:

Save and close the file, when you are finished.

Test GlusterFS

Now, GlusterFS storage, pool and volume are configured. It’s time to test GlusterFS replication and high-availability.

To check replication, mount GlusterFS volume on both GlusterFS instance:

On GlusterFS1:

On GlusterFS2:

Now, go to the GlusterFS Client instance and create some files on the mounted filesystem:

Now, verify both GlusterFS instances by running the following command:

On GlusterFS1:

You should see the same files which we have created on GlusterFS Client:

On GlusterFS2:

You should see the same files which we have created on GlusterFS Client:

Replication is now working fine.

To check the high-availability, shut down the GlusterFS1 instance.

Now, go to the GlusterFS client instance and check the availability of the files:

On GlusterFS Client:

You should see the files even though the GlusterFS1 is down:

Next, create some files on GlusterFS Client:

On GlusterFS Client:

All the file are now written on GlusterFS2. Now, start the GlusterFS1 instance and mount GlusterFS file system:

On GlusterFS1:

Now, check the /mnt directory:

Output:

You should see all the five files in the above output, which we have created on GlusterFS Client, which means the high-availability is working fine.

Related Alibaba Cloud Products

Alibaba Cloud Express Connect is a convenient and efficient network service that provides a fast, stable, secure and private or dedicated network communication between different cloud environments. With Express Connect you can increase the flexibility of your network topology and enhance the quality and security of inter-network communication.

Alibaba Cloud VPC helps you build an isolated network environment based on Alibaba Cloud including customizing the IP address range, network segment, route table, and gateway. In addition, you can connect VPC and a traditional IDC through a leased line, VPN, or GRE to provide hybrid cloud services.

Reference:https://www.alibabacloud.com/blog/how-to-install-and-configure-glusterfs-on-ubuntu-16-04_594086?spm=a2c41.12143889.0.0

Written by

Follow me to keep abreast with the latest technology news, industry insights, and developer trends.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store