{"id":2356,"date":"2019-03-10T09:13:18","date_gmt":"2019-03-10T06:13:18","guid":{"rendered":"http:\/\/kifarunix.com\/?p=2356"},"modified":"2024-03-11T22:31:45","modified_gmt":"2024-03-11T19:31:45","slug":"install-and-setup-glusterfs-on-ubuntu-18-04","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-and-setup-glusterfs-on-ubuntu-18-04\/","title":{"rendered":"Install and Setup GlusterFS on Ubuntu 18.04"},"content":{"rendered":"\n<p>Welcome to our guide on how to install and setup GlusterFS on Ubuntu 18.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. Some of the common features for GlusterFS include;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Can scale to several petabytes thus can handle thousands of clients.<\/li>\n\n\n\n<li>Provides high availability through data mirroring. It also supports self healing mechanism that&nbsp;restores data to the correct state following recovery with nearly no overhead.<\/li>\n\n\n\n<li>Provides a unified global namespace that clusters disk and memory resources into a single pool that ensures load balanced I\/O.<\/li>\n\n\n\n<li>Uses elastic hash algorithm to locate data in the storage pool hence linear performance scaling.<\/li>\n\n\n\n<li>Provides elastic volume manager in which data is stored in logical volumes that are abstracted from the hardware and logically partitioned from each other. This ensures that storage can be added or removed while data continues to be online with no application interruption.<\/li>\n\n\n\n<li>Gluster is fully POSIX-compliant and does not require any unique APIs for data access.<\/li>\n\n\n\n<li>Supports industry standard protocols like NFS, SMB, CIFS, HTTP and FTP.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Installing GlusterFS on Ubuntu 18.04<\/h2>\n\n\n\n<p>While setting up GlusterFS, there are different types of Volume architectures that you may want to consider. These include;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Distributed Glusterfs Volume<\/li>\n\n\n\n<li>Replicated Glusterfs Volume<\/li>\n\n\n\n<li>Distributed Replicated Glusterfs Volume<\/li>\n\n\n\n<li>Striped Glusterfs Volume<\/li>\n\n\n\n<li>Distributed Striped Glusterfs Volume<\/li>\n<\/ul>\n\n\n\n<p>In this guide, we are going to learn how to setup <code>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&#8217;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<p>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<ul class=\"wp-block-list\">\n<li>Storage Node 1:\n<ul class=\"wp-block-list\">\n<li>Hostname: gfsnode01.example.com<\/li>\n\n\n\n<li>IP address: 192.168.43.30<\/li>\n\n\n\n<li>Gluster Storage Disk: \/dev\/sdb1<\/li>\n\n\n\n<li>Mount Point: \/gfsvolume<\/li>\n\n\n\n<li>OS: Ubuntu 18.04<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Storage Node 2:\n<ul class=\"wp-block-list\">\n<li>Hostname: gfsnode02.example.com<\/li>\n\n\n\n<li>IP address: 192.168.43.177<\/li>\n\n\n\n<li>Gluster Storage Disk: \/dev\/sdb1<\/li>\n\n\n\n<li>Mount Point: \/gfsvolume<\/li>\n\n\n\n<li>OS: Ubuntu 18.04<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>GlusterFS Client:\n<ul class=\"wp-block-list\">\n<li>Hostname: gfsclient.example.com<\/li>\n\n\n\n<li>IP address: 192.168.43.197<\/li>\n\n\n\n<li>OS: Ubuntu 18.04<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p>Ensure that the hostsnames are resolvable. If you dont have a DNS server, then populate the hosts file of each Server accordingly such that the three servers are reachable via the hostnames.<\/p>\n\n\n\n<p>Another thing to consider is the NTP server. Ensure that the time is synchronized for the three servers.<\/p>\n\n\n\n<p>Update and upgrade your system packages.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt update<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Install GlusterFS Server on Ubuntu 18.04 Nodes<\/h3>\n\n\n\n<p>GlusterFS-3 is available on the default Ubuntu 18.04. Hence, to install the latest release, GlisterFS-5, you need to add the glusterfs-5 PPA repository.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo apt-get install software-properties-common\nsudo add-apt-repository ppa:gluster\/glusterfs-5<\/code><\/pre>\n\n\n\n<p>Once you add the PPA repository, update the systems.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt update<\/code><\/pre>\n\n\n\n<p>Install GlusterFS-5 server on both nodes;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt install glusterfs-server<\/code><\/pre>\n\n\n\n<p>GlusterFS server (<code>glusterd<\/code>) is set to run by default after installation. Enable it to run on system boot.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl enable glusterd<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Install GlusterFS Client on Ubuntu 18.04 Client<\/h3>\n\n\n\n<p>Add the PPA repositories<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt-get install software-properties-common\nadd-apt-repository ppa:gluster\/glusterfs-5<\/code><\/pre>\n\n\n\n<p>Install GlusterFS-5 client on the Client server;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt install glusterfs-client<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Setup Distributed GlusterFS Volume on Ubuntu 18.04<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">Configure Firewall<\/h3>\n\n\n\n<p>If UFW is running, run the command below to allow the storage nodes to communicate with each other.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo ufw allow from <strong>&lt;other-node-IP&gt;<\/strong><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Configure GlusterFS Trusted Pool<\/h3>\n\n\n\n<p>To create a trusted storage pool between the nodes, run the probe from Storage Node01 as shown below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>gluster peer probe u18svrnode02.example.com\npeer probe: success.<\/code><\/pre>\n\n\n\n<p>To check the status of the trusted pool just created above, execute the command below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>gluster peer status<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>Number of Peers: 1\n\nHostname: u18svrnode02.example.com\nUuid: 5a2dd392-9e3b-4710-8803-e6055694a955\nState: Peer in Cluster (Connected)<\/code><\/pre>\n\n\n\n<p>If you get <code>State: Peer Rejected (Connected)<\/code>, see the resolution <a href=\"https:\/\/staged-gluster-docs.readthedocs.io\/en\/release3.7.0beta1\/Administrator%20Guide\/Resolving%20Peer%20Rejected\/\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\n\n\n\n<p>To list the storage pools;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>gluster pool list<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>UUID\t\t\t\t\tHostname                \tState\n5a2dd392-9e3b-4710-8803-e6055694a955\tu18svrnode02.example.com\tConnected \n639199cd-575a-441b-996b-313c5ab703bd\tlocalhost               \tConnected<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Create Distributed GlisterFS Volume<\/h3>\n\n\n\n<p>Create a brick directory for GlusterFS volumes on the GlusterFS storage device mount point on <strong>both<\/strong> storage nodes.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mkdir \/gfsvolume\/gv0<\/code><\/pre>\n\n\n\n<p>Next, create a distributed volume called <code>distributed_vol<\/code> on both nodes<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>gluster volume create <code>distributed_vol<\/code> transport tcp u18svrnode01:\/gfsvolume\/gv0 u18svrnode02:\/gfsvolume\/gv0<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code> volume create: distributed_vol: success: please start the volume to access data<\/code><\/pre>\n\n\n\n<p>Start the created volume.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>gluster volume start distributed_vol<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>volume start: distributed_vol: success<\/code><\/pre>\n\n\n\n<p>Show information about the created volume.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>gluster volume info<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>Volume Name: distributed_vol\nType: Distribute\nVolume ID: acc2cf8f-5177-4e2e-9772-dc0f1b791abe\nStatus: Started\nSnapshot Count: 0\nNumber of Bricks: 2\nTransport-type: tcp\nBricks:\nBrick1: u18svrnode01:\/gfsvolume\/gv0\nBrick2: u18svrnode02:\/gfsvolume\/gv0\nOptions Reconfigured:\ntransport.address-family: inet\nnfs.disable: on<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Mount the Volume on GlusterFS client<\/h3>\n\n\n\n<p>We are going to use the native GlusterFS client to mount the GlusterFS nodes.<\/p>\n\n\n\n<p>Create the mount point<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mkdir \/mnt\/gfsvol<\/code><\/pre>\n\n\n\n<p>Mount the distributed volume.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mount -t glusterfs u18svrnode01.example.com:\/distributed_vol \/mnt\/gfsvol\/<\/code><\/pre>\n\n\n\n<p>Run the df command to check the mounted filesystems.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>df -hTP \/mnt\/gfsvol\/<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>Filesystem                                Type            Size  Used Avail Use% Mounted on\n<strong>u18svrnode01.example.com:\/distributed_vol fuse.glusterfs  2.0G   88M  2.0G   5% \/mnt\/gfsvol<\/strong><\/code><\/pre>\n\n\n\n<p>To automount the volume on system boot, you need to add the line below to <code>\/etc\/fstab<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>u18svrnode01.example.com:\/distributed_vol \/mnt\/gfsvol glusterfs defaults,_netdev 0 0<\/code><\/pre>\n\n\n\n<p>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<pre class=\"wp-block-preformatted\"><code>mkdir \/mnt\/gfsvol\/Test-dir\ntouch \/mnt\/gfsvol\/Test-dir\/test-file\ntouch \/mnt\/gfsvol\/Test-dir\/test-file-two<\/code><\/pre>\n\n\n\n<p>If you can check on node01,<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ls \/gfsvolume\/gv0\/Test-dir\/\ntest-file-two<\/code><\/pre>\n\n\n\n<p>On node02,<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ls \/gfsvolume\/gv0\/Test-dir\/\ntest-file<\/code><\/pre>\n\n\n\n<p>Well, In this guide, you have learnt how setup distributed GlusterFS volumes and verified to be working. In our next tutorial, we will learn how to setup replicated Glusterfs volumes.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome to our guide on how to install and setup GlusterFS on Ubuntu 18.04. Well, so what is GlusterFS? GlusterFS is an opensource distributed and<\/p>\n","protected":false},"author":1,"featured_media":13046,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[39,345,121],"tags":[346,5340,5339,67],"class_list":["post-2356","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-storage","category-glusterfs","category-howtos","tag-glusterfs","tag-glusterfs-setup","tag-install-glusterfs-on-ubuntu","tag-ubuntu-18-04","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/2356"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=2356"}],"version-history":[{"count":5,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/2356\/revisions"}],"predecessor-version":[{"id":21130,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/2356\/revisions\/21130"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/13046"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=2356"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=2356"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=2356"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}