{"id":13048,"date":"2022-06-02T20:21:33","date_gmt":"2022-06-02T17:21:33","guid":{"rendered":"https:\/\/kifarunix.com\/?p=13048"},"modified":"2024-03-09T15:45:51","modified_gmt":"2024-03-09T12:45:51","slug":"install-and-setup-glusterfs-on-ubuntu","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-and-setup-glusterfs-on-ubuntu\/","title":{"rendered":"Install and setup GlusterFS on Ubuntu 22.04\/Ubuntu 20.04"},"content":{"rendered":"\n
Welcome to our guide on how to install and setup GlusterFS on Ubuntu 22.04\/Ubuntu 20.04. Well, so what is GlusterFS? GlusterFS is an opensource distributed and scalable network file system that clusters various disk storage resources into a single global namespace. GlusterFS is suitable for data-intensive tasks such as cloud storage and media streaming.<\/p>\n\n\n\n
While setting up GlusterFS, there are different types of Volume architectures<\/a> that you may want to consider. These include;<\/p>\n\n\n\n In this guide, we are going to learn how to setup As a result, our environment consists of two storage nodes and a single client. Their details are as shown below.<\/p>\n\n\n\n Note, do not use the root partition for GlusterFS. Add another storage partition, preferably on a different drive.<\/p>\n\n\n\n Update and upgrade your system packages.<\/p>\n\n\n\n GlusterFS packages is available on the default Ubuntu 22.04\/Ubuntu 20.04. Run the command below to install GlusterFS server.<\/p>\n\n\n\n Start and enable GlusterFS server ( Check the status;<\/p>\n\n\n\n If Firewall is running, run the command below to allow the Gluster storage nodes to communicate with each other via the Gluster daemon service port, 24007\/TCP<\/p>\n\n\n\n If you are using iptables;<\/p>\n\n\n\n Also allow GlusterFS clients to connect to GlusterFS daemon;<\/p>\n\n\n\n To create a trusted storage pool between the GlusterFS nodes, run the probe from GlusterFS Node01 as shown below;<\/p>\n\n\n\n Sample output;<\/p>\n\n\n\n To check the status of the trusted pool just created above, execute the command below;<\/p>\n\n\n\n If you get Output from the second node;<\/p>\n\n\n\n To list the storage pools;<\/p>\n\n\n\n Create a brick directory for GlusterFS volumes on the GlusterFS storage device mount point on both<\/strong> storage nodes.<\/p>\n\n\n\n A Brick is the basic unit of storage in GlusterFS, represented by an export directory on a server in the trusted storage pool<\/strong>. A brick is expressed by combining a server with an export directory in the following format: `SERVER:EXPORT` For example: `myhostname:\/exports\/myexportdir\/`<\/em>.<\/p>\n\n\n\n Thus, on BOTH<\/strong> Nodes, create brick directory.<\/p>\n\n\n\n Please note that our GlusterFS disk, \/dev\/sdb1 is mounted on \/gfsvolume directory.<\/p>\n\n\n\n Sample output;<\/p>\n\n\n\n Next, create a distributed volume called Run this command on either of the nodes, once.<\/p>\n\n\n\n Sample output;<\/p>\n\n\n\n You can now start the created volume brick.<\/p>\n\n\n\n Sample output;<\/p>\n\n\n\n You can show information about created brick volume using the command below;<\/p>\n\n\n\n In order for the clients to connect to the volumes created, you need to open the respective node volume port on firewall. The ports are shown above.<\/p>\n\n\n\n Also ensure that the nodes can talk to each other on these ports.<\/p>\n\n\n\n For example, on GlusterFS node 01, open port 49152 to allow clients to mount the volume.<\/p>\n\n\n\n On Node 02;<\/p>\n\n\n\n On Ubuntu 22.04\/Ubuntu 20.04, run the command to install GlusterFS client on Ubuntu 22.04\/Ubuntu 20.04;<\/p>\n\n\n\n We are going to use the native GlusterFS client to mount the GlusterFS nodes.<\/p>\n\n\n\n Create the mount point<\/p>\n\n\n\n Mount the distributed volume. If using domain names, ensure they are resolvable.<\/p>\n\n\n\n Run the df command to check the mounted filesystems.<\/p>\n\n\n\n From other clients, you can mount the volume on the other node;<\/p>\n\n\n\n To auto-mount the volume on system boot, you need to add the line below to To test the data distribution, create two test files on the client. One of the file will be stored one of the volumes and the other file on the other volume. see example below;<\/p>\n\n\n\n If you can check on node01,<\/p>\n\n\n\n On node02,<\/p>\n\n\n\n That concludes our guide on setting up GlusterFS on Ubuntu 22.04\/Ubuntu 20.04, specifically how to setup distributed GlusterFS volumes. In our next tutorial, we will learn how to setup replicated GlusterFS volumes.<\/p>\n\n\n\n Install and Configure NFS Server on Rocky Linux 8<\/a><\/p>\n\n\n\n Easily Install and Configure Samba File Server on Ubuntu 22.04<\/a><\/p>\n\n\n\n\n
How to Setup Distributed GlusterFS Volume on Ubuntu 22.04\/Ubuntu 20.04<\/h3>\n\n\n\n
distributed GlusterFS<\/code>. With the distributed volume, files are distributed across various bricks in the volume such that file A is stored on one of the volumes and file B on the other. The purpose of this architecture is to cheaply scale the volume size. However, it doesn’t provide redundancy and a failure of the volume will lead to a complete loss of the data stored in that volume.<\/p>\n\n\n\n
\n
\n
\n
\n
\n
apt update<\/code><\/pre>\n\n\n\n
Install GlusterFS Server on Ubuntu 22.04\/Ubuntu 20.04 Nodes<\/a><\/h3>\n\n\n\n
apt install glusterfs-server<\/code><\/pre>\n\n\n\n
glusterd<\/code>) to run on system boot;<\/p>\n\n\n\n
systemctl enable --now glusterd<\/code><\/pre>\n\n\n\n
systemctl status glusterd<\/code><\/pre>\n\n\n\n
\u25cf glusterd.service - GlusterFS, a clustered file-system server\n Loaded: loaded (\/lib\/systemd\/system\/glusterd.service; enabled; vendor preset: enabled)\n Active: active (running) since Thu 2022-06-02 17:59:13 UTC; 11s ago\n Docs: man:glusterd(8)\n Process: 3346 ExecStart=\/usr\/sbin\/glusterd -p \/var\/run\/glusterd.pid --log-level $LOG_LEVEL $GLUSTERD_OPTIONS (code=exited, status=0\/SUCCESS)\n Main PID: 3347 (glusterd)\n Tasks: 9 (limit: 2241)\n Memory: 7.1M\n CPU: 1.394s\n CGroup: \/system.slice\/glusterd.service\n \u2514\u25003347 \/usr\/sbin\/glusterd -p \/var\/run\/glusterd.pid --log-level INFO\n\nJun 02 17:59:11 gfs02.kifarunix-demo.com systemd[1]: Starting GlusterFS, a clustered file-system server...\nJun 02 17:59:13 gfs02.kifarunix-demo.com systemd[1]: Started GlusterFS, a clustered file-system server.\n<\/code><\/pre>\n\n\n\n
Setup Distributed GlusterFS Volume on Ubuntu 22.04\/Ubuntu 20.04<\/h3>\n\n\n\n
\n
ufw allow from <other-node-IP><\/strong> to any port 24007 proto tcp comment \"GlusterFS Management\"<\/code><\/pre>\n\n\n\n
iptables -A INPUT -s <other-node-IP><\/strong> -p tcp --dport 24007 -j ACCEPT -m comment --comment \"GlusterFS Management\"<\/code><\/pre>\n\n\n\n
cp \/etc\/iptables\/rules.v4{,.old}\niptables-save > \/etc\/iptables\/rules.v4<\/code><\/pre>\n\n\n\n
ufw allow from <Client-IP><\/strong> to any port 24007 proto tcp comment \"GlusterFS Client Access\"<\/code><\/pre>\n\n\n\n
\n
gluster peer probe gfs02.kifarunix-demo.com<\/code><\/pre>\n\n\n\n
peer probe: success.<\/code><\/pre>\n\n\n\n
gluster peer status<\/code><\/pre>\n\n\n\n
Number of Peers: 1\n\nHostname: gfs02.kifarunix-demo.com\nUuid: b81803a8-893a-499e-9a87-6bac00a62822\nState: Accepted peer request (Connected)<\/code><\/pre>\n\n\n\n
State: Peer Rejected (Connected)<\/code>, see the resolution here<\/a>.<\/p>\n\n\n\n
Number of Peers: 1\n\nHostname: gfs01.kifarunix-demo.com\nUuid: 26fe538a-91c2-42a1-b34a-67c2c94c7492\nState: Peer in Cluster (Connected)<\/code><\/pre>\n\n\n\n
gluster pool list<\/code><\/pre>\n\n\n\n
UUID\t\t\t\t\tHostname \tState\nb81803a8-893a-499e-9a87-6bac00a62822\tgfs02.kifarunix-demo.com\tConnected \n26fe538a-91c2-42a1-b34a-67c2c94c7492\tlocalhost \tConnected<\/code><\/pre>\n\n\n\n
\n
mkdir \/gfsvolume\/gv0<\/code><\/pre>\n\n\n\n
df -hT -P \/gfsvolume<\/code><\/pre>\n\n\n\n
Filesystem Type Size Used Avail Use% Mounted on\n\/dev\/sdb1 ext4 3.9G 24K 3.7G 1% \/gfsvolume<\/code><\/pre>\n\n\n\n
distributed_vol<\/code> on the nodes. The name can be anything!<\/p>\n\n\n\n
gluster volume create distributed_vol<\/strong><\/span> transport tcp gfs01:\/gfsvolume\/gv0 gfs02:\/gfsvolume\/gv0<\/code><\/pre>\n\n\n\n
volume create: distributed_vol: success: please start the volume to access data<\/code><\/pre>\n\n\n\n
\n
gluster volume start distributed_vol<\/code><\/pre>\n\n\n\n
volume start: distributed_vol: success<\/code><\/pre>\n\n\n\n
\n
gluster volume info<\/code><\/pre>\n\n\n\n
\nVolume Name: distributed_vol\nType: Distribute\nVolume ID: 98519652-97a2-4fb8-bd1a-9b6a83d8936e\nStatus: Started\nSnapshot Count: 0\nNumber of Bricks: 2\nTransport-type: tcp\nBricks:\nBrick1: gfs01:\/gfsvolume\/gv0\nBrick2: gfs02:\/gfsvolume\/gv0\nOptions Reconfigured:\ntransport.address-family: inet\nstorage.fips-mode-rchecksum: on\nnfs.disable: on\n<\/code><\/pre>\n\n\n\n
\n
gluster volume status<\/code><\/pre>\n\n\n\n
Status of volume: distributed_vol\nGluster process TCP Port RDMA Port Online Pid\n------------------------------------------------------------------------------\nBrick gfs01:\/gfsvolume\/gv0 49152 0 Y 6110 \nBrick gfs02:\/gfsvolume\/gv0 60116 0 Y 4501 \n \nTask Status of Volume distributed_vol\n------------------------------------------------------------------------------\nThere are no active volume tasks\n<\/code><\/pre>\n\n\n\n
\n
ufw allow from <Client-IP-or-Network><\/strong> to any port 49152 proto tcp comment \"GlusterFS Client Access\"<\/code><\/pre>\n\n\n\n
ufw allow from <Node02 IP><\/strong> to any port 49152 proto tcp comment \"GlusterFS Node02\"<\/code><\/pre>\n\n\n\n
ufw allow from <Client-IP-or-Network><\/strong><\/strong> to any port 60116 proto tcp comment \"GlusterFS Client Access\"<\/code><\/pre>\n\n\n\n
ufw allow from <Node01 IP><\/strong><\/strong> to any port 60116 proto tcp comment \"GlusterFS Node01\"<\/code><\/pre>\n\n\n\n
Install GlusterFS Client on Ubuntu 22.04\/Ubuntu 20.04 Client<\/a><\/h3>\n\n\n\n
apt update<\/code><\/pre>\n\n\n\n
apt install glusterfs-client<\/code><\/pre>\n\n\n\n
\n
mkdir \/mnt\/gfsvol<\/code><\/pre>\n\n\n\n
mount -t glusterfs gfs01:\/distributed_vol \/mnt\/gfsvol\/<\/code><\/pre>\n\n\n\n
df -hTP \/mnt\/gfsvol\/<\/code><\/pre>\n\n\n\n
Filesystem Type Size Used Avail Use% Mounted on\ngfs01:\/distributed_vol fuse.glusterfs 7.8G 97M 7.3G 2% \/mnt\/gfsvol<\/code><\/pre>\n\n\n\n
mount -t glusterfs gfs02:\/distributed_vol \/mnt\/gfsvol\/<\/code><\/pre>\n\n\n\n
\/etc\/fstab<\/code>.<\/p>\n\n\n\n
gfs01:\/distributed_vol \/mnt\/gfsvol glusterfs defaults,_netdev 0 0<\/code><\/pre>\n\n\n\n
mkdir \/mnt\/gfsvol\/Test-dir\ntouch \/mnt\/gfsvol\/Test-dir\/{test-file,test-file-two}<\/code><\/pre>\n\n\n\n
ls \/gfsvolume\/gv0\/Test-dir\/\ntest-file-two<\/code><\/pre>\n\n\n\n
ls \/gfsvolume\/gv0\/Test-dir\/\ntest-file<\/code><\/pre>\n\n\n\n
Other Tutorials<\/h2>\n\n\n\n