# Setup GlusterFS

## Note

{% hint style="info" %}
Do all the steps on every server you have.
{% endhint %}

## Configure Hosts file

We use hosts to use names instead of IP addresses.

Edit the `/etc/hosts` with something like this:

{% code title="/etc/hosts" %}

```
10.0.15.10 gfs01
10.0.15.11 gfs02
```

{% endcode %}

## Install GlusterFS

```
apt install glusterfs-server
```

Start the service and enable it.

```
service glusterd start
systemctl enable glusterd

service glusterd status
```

### Make a partition

{% content-ref url="/pages/-M03z2fZXQwoftJ6qShr" %}
[Broken mention](broken://pages/-M03z2fZXQwoftJ6qShr)
{% endcontent-ref %}

BUT create a `xfs` file system. And follow this setup for this file system.

```
mkfs.xfs -i size=512 /dev/sda5
[...]
echo '/dev/sda5 /glusterfs xfs defaults 1 2' >> /etc/fstab
```

## Configure the firewall

The Gluster processes on the nodes need to be able to communicate with each other. To simplify this setup, configure the firewall on each node to accept all traffic from the other node.

We will add only the interface as well, where the Glusters communicate, the interface is `wg0` for example.

```
iptables -I INPUT -i wg0 -p all -s <ip-address> -j ACCEPT
```

## Connect the peers

```
gluster peer probe gfs01
```

Check status:

```
gluster peer status
```

## Set up a GlusterFS volume

Create a directory `gv0` on the partition created for GlusterFS.

```
mkdir /glusterfs/gv0
```

> Do this next two commands only on one node.
>
> ```
> gluster volume create gv0 replica 2 gfs01:/glusterfs/gv0 gfs02:/glusterfs/gv0
> ```
>
> If you only using 2 nodes make sure of the split [brain problem](https://docs.gluster.org/en/latest/Administrator%20Guide/Split%20brain%20and%20ways%20to%20deal%20with%20it/)

Start the volume

```
gluster volume start gv0
```

You can check if it's working on both nodes with the command:

```
gluster volume info
```

## Mounting the GlusterFS Volume

If you want to use the GlusterFS volume, mount the volume to any client.

```
mount -t glusterfs server1:/gv0 /mnt/dStorage
```

## List of sources

1. **HowtoForge**.com \_\_- *Muhammad Arul* - <https://www.howtoforge.com/tutorial/high-availability-storage-with-glusterfs-on-ubuntu-1804/>
2. **Gluster**.org - <https://docs.gluster.org/en/latest/Quick-Start-Guide/Quickstart/>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pascalgolla.gitbook.io/knowledge/io/glusterfs/setup-glusterfs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
