Gluster FileSystem - One Click Install
Tags: glusterfs, beginners, programming, devops
Published: 2022-02-09 09:22:14

## DAY 4 - GlusterFS on Cloud 
☁️[100 days of Cloud- **Day Four**](https://github.com/anuvindhs/100daysofcloud)
 ✅[Follow Me on Twitter](https://twitter.com/anuvindhs)


![cover](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dnjliqqwq7riqtxg2py7.gif)

[Tweet This Blog](https://link.anuvindh.com/twitter/DAY-4-GFS-cloud.html)  - [Read on GitHub](https://github.com/anuvindhs/100daysofcloud) - [read iCTPro.co.nz](https://ictpro.co.nz) 

## What is Gluster File System

GlusterFS (Gluster File System) is an open source Distributed File System that can scale out in building-block fashion to store multiple petabytes of data.

## Use Cases
streaming media , content delivery. Scale-out storage systems based on GlusterFS are suitable for unstructured data such as documents, images, audio and video files, and log files.

## Prerequisite

- Minimum Three VM,For this demo we deploy it in AWS EC2.
- git on VM's
Make sure EC2/VM have git installed</br>
 To check 
 ```bash 
 git --version
 ```
 
 To install git </br>
 
  ```bash
  sudo apt install git-all
  ```

- Open ports on Security Groups 

**Security Group** For GFS

|  Type | Protocol  | Ports  | Source |Description   |
| :------------: | :------------: | :------------: | :------------: |:------------: |
| SSH| SSH   | 22  | Administration Host Security Group   |Administration Host Security Group |
|  Custom TCP Rule  |  TCP | 2007  |  GlusterFS Security Group Secure Transport Server Security Group  | Gluster Daemon |
|  Custom TCP Rule  |TCP   | 111  | GlusterFS Security Group SecureTransport Server Security Group   | Portmapper |
| Custom TCP Rule   |TCP   | 49152-49251   |  GlusterFS Security Group SecureTransport Server Security Group  |Each brick for every volume on your host requires its own port  |
| Custom TCP Rule   | TCP  |  2049  | GlusterFS Security Group SecureTransport Server Security Group    | NFS |

## Tutorial
In this tutorial 
Code Repo - [github](https://github.com/anuvindhs/How-to-install-GlusterFS.git)

-  I will launching three ubuntu ec2 instance install.
-  Install Gluster FS.
-  Peer Servers.
-  Create Gluster Volume.
-  Test the replication.

If you dont know how to launch ec2 , use this [link](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EC2_GetStarted.html)

### Step 1
- launching ec2 , am using **Ubuntu Server 20.04 LTS** . Also make sure you enable **Auto-assign Public IP** .
- Am naming three servers as **MasterNode , GlusterFS-01, GlusterFS-01**, easy for understanding.
- Note down public IP for MasterNode , GlusterFS-01, GlusterFS-01

### Step 2
- **First** SSH into GlusterFS-01.
Get root privilages to run command 

```bash
sudo su -
```

```bash 
wget https://raw.githubusercontent.com/anuvindhs/How-to-install-GlusterFS/main/install.sh
```

```bash 
chmod u+x install.sh
```

```bash 
./install.sh
 ```

![install sh](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jj13d82v7njzsz8uvp2e.gif)

| Info  | Screenshots  |
| ------------ | ------------ |
| Enter your Server Name  | ![ServerName](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k9ky896t8kjtynh3mlw6.png) |
|System will Automatically Update Ubuntu|![OS update](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/083yk1ya3rsyuhb018lc.png)|
|Installing GlusterFS and Dependencies , once installed restart the servers|![GFS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t1ye15f9nouv7s4nkyzf.png)|
|If you wish to see the installation data|![debug](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mv7vniilkyqeegtdd5o9.png)|

- Do this for **GlusterFS-02** and **MasterNode**

Now you have success fully installed GlusterFS

## Peering GlusterFS 🤝🏼
This is really important , we need to configure the hostname for all three servers

On each server type
 ```bash
sudo nano /etc/hosts/
```
|  Nodes | /etc/hosts data  | 
| ------------ | ------------ |
|  MasterNode | ![msnode](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ddwt87j7ug68uvj6ktbk.gif)| 
|  GlusterFS-01 | ![gfs01](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fvk5kfm2twic8eg24kbr.gif)  | 
|GlusterFS-02|![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lwh4tzvbp1zop3nxsd81.gif)|

**MasterNode**
52.62.40.54 MasterNode
54.252.253.181 GlusterFS-01
13.236.188.52 GlusterFS-02
**GlusterFS-01**
127.0.0.1 GlusterFS-01
52.62.40.54 MasterNode
13.236.188.52 GlusterFS-02
**GlusterFS-02**
52.62.40.54 MasterNode
54.252.253.181 GlusterFS-01
13.236.188.52 GlusterFS-02

make sure you add your **public ip**

now lets ping all nodes from all servers
`ping Masternode
ping GlusterFs-01
ping GlusterFS-02`

if all servers pings successfully, we are going to peer the servers now

Go to **Masternode** 
```bash
gluster peer probe GlusterFS-01
gluster peer probe GlusterFS-02
```

![peer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2kizb6as0obtu33e25dr.gif)
 
## Creating Gluster Volume 💽

On Masternode
```bash
sudo gluster volume create gv0 replica 3 transport tcp Masternode:/glusterfs glusterfs-01:/glusterfs glusterfs-02:/glusterfs force
```
```bash
sudo gluster volume start gv0
```

Congratulations 🎉 you have successfully configured the GlusterFS

## Testing Gluster-FS replication

lets check the gluster volume info

![Volume info](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hxpkxiqyuazqrqr0y0v1.gif)

### Create folder for replication test 📁
```bash
sudo mkdir -p /myfiles
```
### Mount the /GlusterFS to /myfiles Folder
```bash
sudo mount -t glusterfs Masternode:/glusterfs /myfiles
cd /myfiles
sudo touch file_{0..9}.test
ls /glusterfs
```

You will be able to see the replicated files on each server



{% user anuvindhs %}