# How to install Glusterfs on Ubuntu and Centos

![How to install Glusterfs on Ubuntu and Centos](https://blogs.q21.in/content/images/size/w2000/2023/01/Screenshot-from-2023-01-03-15-30-54.png align="left")

## ***GLUSTERFS INSTALLATION in UBUNTU and CENTOS***

GlusterFS is an open-source, distributed file system that is designed to scale to multiple petabytes of storage. It uses a client-server architecture that allows for deployment across physical, virtual, and cloud environments. GlusterFS employs a distributed metadata architecture that ensures high availability and performance, making it a popular choice for big data and high-performance computing environments. It supports various storage protocols, including NFS, SMB, and FUSE, and provides data redundancy and replication for fault tolerance. GlusterFS can be managed through a web-based graphical user interface or a command-line interface, making it accessible for both novice and experienced users. It integrates with many other open-source tools and platforms, such as Kubernetes, OpenStack, and Hadoop. GlusterFS is owned and maintained by Red Hat, but it is open source and free to use. Its vibrant community of developers and users contribute to its ongoing development and support, ensuring its continued relevance in the rapidly evolving world of distributed storage.

### **Server side Installation**

***Try to perform the actions in new servers  and make sure you don't get stuck in dpkg and package errors***

ADD host entry so that glusterfs can use dns names instead of IPs

```bash
sudo vim /etc/hosts
```

Paste the following  (change IP's according to you )

```plaintext
172.16.0.119   glusterfs1
172.16.0.138   glusterfs2
```

Install necessary packages ( we are installing version-10)

#### **For Ubuntu**

```bash
apt install software-properties-common -y  && \
echo \n | sudo add-apt-repository ppa:gluster/glusterfs-10 && \ 
sudo apt update -y  && \
apt install glusterfs-server -y  && apt install glusterfs-client -y 
```

Check if Glusterfs is started

```bash
systemctl is-active  glusterd.service
```

If not start the default services .

```bash
systemctl start gluster-ta-volume.service
systemctl start glusterd.service
systemctl start glustereventsd.service
systemctl start glusterfssharedstorage.service
```

Enable the services so that they can start at startup

```bash
systemctl enable gluster-ta-volume.service
systemctl enable glusterd.service
systemctl enable glustereventsd.service
systemctl enable glusterfssharedstorage.service
systemctl status glusterd
```

Glusterd is the main process which should  be in running state ( ignore other services if it throws any errors )

#### **For Rhel and CentOS**

```bash
yum install centos-release-gluster
```

Note : add Epel repo to avoid dependencies issue

```bash
sudo yum -y install epel-release
```

Note: On CentOS 6 , you need to install xfsprogs package to be able to format an XFS file system

```bash
 yum install xfsprogs
```

Install glusterfs

```bash
yum -y install glusterfs glusterfs-fuse glusterfs-server
```

On CentOS 8 the [PowerTools](https://wiki.centos.org/PowerTools) repository needs to be enabled while installing the packages too:

```bash
 dnf --enablerepo=powertools install glusterfs-server
```

start enable and check status of service

```bash
systemctl enable glusterd
systemctl start glusterd
systemctl status glusterd
```

Above steps has to be done in all servers in cluster

---

Add servers to cluster and allow traffic ( change IP )  ---to be run in one server only ( i am running below commands from server1 )

```bash
gluster peer probe glusterfs2   

###for ubuntu ###
iptables -I INPUT -p all -s `<ip-address>` -j ACCEPT

### for rhel and centos ###
iptables -A INPUT -p all -s `<ip-address>` -j ACCEPT
```

add multiple servers using `gluster peer probe <glusterfsservers>` commands . also make alternate arrangements for persistent iptables rules

check the cluster servers status

```bash
gluster peer status
gluster pool list
```

Once you  see the cluster is connected . Proceed further

create Gluster-volume

```bash
gluster volume create testvolume replica 2 glusterfs1:/glustervolume glusterfs2:/glustervolume
```

> *testvolume – name of volume  
>   
> replica         – type of glusterfs cluster  
>   
> 2                   – number of replicas ( 2 servers = 2 replicas , 1 copy of data in each server will be present at any cost )*

If running with root folder use following command to override

```bash
gluster volume create testvolume replica 2 glusterfs1:/glustervolume glusterfs2:/glustervolume force
```

check the volume info

```bash
gluster volume info
```

start Volume if everything works fine

```bash
gluster volume start testvolume
```

server side configs complete

Open ports to connects from clients

#### **Ubuntu**

```bash
sudo iptables -A INPUT  -s <client IP > -p tcp --dport 24007:24008 -j ACCEPT
sudo iptables -A INPUT  -s <client IP > -p tcp --dport 49152:49156 -j ACCEPT
```

#### **Centos**

```bash
sudo iptables -I INPUT  -s <client IP > -p tcp --dport 24007:24008 -j ACCEPT
sudo iptables -I INPUT  -s <client IP > -p tcp --dport 49152:49156 -j ACCEPT
```

### **CLIENT**

setup client server

```bash
## ubuntu ##
sudo apt install glusterfs-client 

##Rhel and centos ##
sudo yum -y install openssh-server wget fuse fuse-libs openib libibverbs
yum -y install glusterfs glusterfs-fuse
```

create directory

```bash
sudo mkdir /mnt/glusterfs/
```

check mounts

```bash
df -h
```

Mount it in specified path (anyone server you can use )

```bash
sudo mount -t glusterfs glusterfs1:/testvolume /mnt/glusterfs
```

Done . You now have a gluster-fs servers with a client
