{"id":5692,"date":"2018-07-23T20:37:42","date_gmt":"2018-07-23T16:37:42","guid":{"rendered":"https:\/\/www.howtoforge.com\/tutorial\/high-availability-storage-with-glusterfs-on-ubuntu-1804\/"},"modified":"2018-07-23T20:37:42","modified_gmt":"2018-07-23T16:37:42","slug":"high-availability-storage-with-glusterfs-on-ubuntu-18-04-lts","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/high-availability-storage-with-glusterfs-on-ubuntu-18-04-lts\/","title":{"rendered":"High-Availability Storage with GlusterFS on Ubuntu 18.04 LTS"},"content":{"rendered":"<p>Glusterfs is a scalable network filesystem with capabilities of scaling to several petabytes and handling thousands of clients. It&#8217;s an open source and distributed file system that sets disk storage resources from multiple servers into a single namespace. It&#8217;s suitable for data-intensive tasks such as cloud storage and data media streaming.<\/p>\n<p>In this tutorial, I will show how to set up a high availability storage server with GlusterFS on Ubuntu 18.04 LTS (Bionic Beaver). We will use 3 ubuntu servers, 1 server as a client, and 2 others as a storage. Each storage server will be a mirror of the other, and files will be replicated across both storage servers.<\/p>\n<h2 id=\"prerequisites\">Prerequisites<\/h2>\n<ul>\n<li>3 Ubuntu 18.04 Servers<\/li>\n<ul>\n<li><em>10.0.15.10 &#8211; gfs01<\/em><\/li>\n<li><em>10.0.15.11 &#8211; gfs02<\/em><\/li>\n<li><em>10.0.15.12 &#8211; client01<\/em><\/li>\n<\/ul>\n<li>Root Privileges<\/li>\n<\/ul>\n<h2 id=\"what-we-will-do\">What we will do?<\/h2>\n<ol>\n<li>GlusterFS Pre-Installation<\/li>\n<li>Install GlusterFS Server<\/li>\n<li>Configure GlusterFS Servers<\/li>\n<li>Setup GlusterFS Client<\/li>\n<li>Testing Replicate\/Mirroring<\/li>\n<\/ol>\n<h2 id=\"step-glusterfs-preinstallation\">Step 1 &#8211; GlusterFS Pre-Installation<\/h2>\n<p>The first step we need to do before installing glusterfs on all servers is configuring the hosts&#8217; file and add GlusterFS repository to each server.<\/p>\n<h3 id=\"configure-hosts-file\">Configure Hosts File<\/h3>\n<p>Log in to each server and get the root access with &#8216;sudo su&#8217; command, then edit the &#8216;\/etc\/hosts&#8217; file.<\/p>\n<p class=\"command\">vim \/etc\/hosts<\/p>\n<p>Paste hosts configuration below.<\/p>\n<pre>10.0.15.10 gfs01&#13;\n10.0.15.11 gfs02&#13;\n10.0.15.12 client01<\/pre>\n<p>Save and exit.<\/p>\n<p>Now ping each server using the hostname as below.<\/p>\n<p class=\"command\">ping -c 3 gfs01<br \/>ping -c 3 gfs02<br \/>ping -c 3 client01<\/p>\n<p>Each hostname will resolve to each server IP address.<\/p>\n<p><a class=\"fancybox\" id=\"img-1\" href=\"https:\/\/www.howtoforge.com\/images\/high_availability_storage_with_glusterfs_on_ubuntu_1804\/big\/1.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/high-availability-storage-with-glusterfs-on-ubuntu-18-04-lts.png\" alt=\"Configure the hosts file\" width=\"500\" height=\"356\" title=\"\"><\/a><\/p>\n<h3 id=\"add-glusterfs-repository\">Add GlusterFS Repository<\/h3>\n<p>Install the software-properties-common package to the system.<\/p>\n<p class=\"command\">sudo apt install software-properties-common -y<\/p>\n<p>Add the glusterfs key and repository by running commands below.<\/p>\n<p class=\"command\">wget -O- https:\/\/download.gluster.org\/pub\/gluster\/glusterfs\/3.12\/rsa.pub | apt-key add &#8211;<br \/>sudo add-apt-repository ppa:gluster\/glusterfs-3.12<\/p>\n<p>The command will update all repositories. And we&#8217;ve already added the glusterfs repository to all systems.<\/p>\n<p><a class=\"fancybox\" id=\"img-2\" href=\"https:\/\/www.howtoforge.com\/images\/high_availability_storage_with_glusterfs_on_ubuntu_1804\/big\/2.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/high-availability-storage-with-glusterfs-on-ubuntu-18-04-lts-1.png\" alt=\"Add GlusterFS Repository\" width=\"500\" height=\"219\" title=\"\"><\/a><\/p>\n<h2 id=\"step-install-glusterfs-server\">Step 2 &#8211; Install GlusterFS Server<\/h2>\n<p>In this step, we will install the glusterfs server on &#8216;gfs01&#8217; and &#8216;gfs02&#8217; servers.<\/p>\n<p>Install glusterfs-server using the apt command.<\/p>\n<p class=\"command\">sudo apt install glusterfs-server -y<\/p>\n<p>Now start the glusterd service and enable it to launch everytime at system boot.<\/p>\n<p class=\"command\">sudo systemctl start glusterd<br \/>sudo systemctl enable glusterd<\/p>\n<p>Glusterfs server is now up and running on the &#8216;gfs01&#8217; and &#8216;gfs02&#8217; servers.<\/p>\n<p>Check the services and the installed software version.<\/p>\n<p class=\"command\">systemctl status glusterd<br \/>glusterfsd &#8211;version<\/p>\n<p><a class=\"fancybox\" id=\"img-3\" href=\"https:\/\/www.howtoforge.com\/images\/high_availability_storage_with_glusterfs_on_ubuntu_1804\/big\/3.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/high-availability-storage-with-glusterfs-on-ubuntu-18-04-lts-2.png\" alt=\"Install GlusterFS Server\" width=\"500\" height=\"373\" title=\"\"><\/a><\/p>\n<h2 id=\"step-configure-glusterfs-servers\">Step 3 &#8211; Configure GlusterFS Servers<\/h2>\n<p>Glusterd services are now up and running, and the next step we will do is to configure those servers by creating a trusted storage pool and creating the distributed glusterfs volume.<\/p>\n<h3 id=\"create-a-trusted-storage-pool\">Create a Trusted Storage Pool<\/h3>\n<p>From the &#8216;gfs01&#8217; server, we need to add the &#8216;gfs02&#8217; server to the glusterfs storage pool.<\/p>\n<p>Run the command below.<\/p>\n<p class=\"command\">gluster peer probe gfs02<\/p>\n<p>Now we will see the result &#8216;peer probe: success&#8217;, and we&#8217;ve added the &#8216;gfs02&#8217; server to the storage trusted pool.<\/p>\n<p>Check the storage pool status and list using commands below.<\/p>\n<p class=\"command\">gluster peer status<br \/>gluster pool list<\/p>\n<p>And you will see the &#8216;gfs02&#8217; server is connected to the peer cluster, and it&#8217;s on the pool list.<\/p>\n<p><a class=\"fancybox\" id=\"img-4\" href=\"https:\/\/www.howtoforge.com\/images\/high_availability_storage_with_glusterfs_on_ubuntu_1804\/big\/4.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/high-availability-storage-with-glusterfs-on-ubuntu-18-04-lts-3.png\" alt=\"Create a Trusted Storage Pool\" width=\"500\" height=\"245\" title=\"\"><\/a><\/p>\n<h3 id=\"setup-distributed-glusterfs-volume\">Setup Distributed GlusterFS Volume<\/h3>\n<p>After creating the trusted storage pool, we will create a new distributed glusterfs volume. We will create the new glusterfs volume based on the system directory.<\/p>\n<p><strong>Note:<\/strong><\/p>\n<ul>\n<li>For the server production, it&#8217;s recommended to create the glusterfs volume using the different partition, not using a system directory.<\/li>\n<\/ul>\n<p>Create a new directory &#8216;\/glusterfs\/distributed&#8217; on each bot &#8216;gfs01&#8217; and &#8216;gfs02&#8217; servers.<\/p>\n<p class=\"command\">mkdir -p \/glusterfs\/distributed<\/p>\n<p>And from the &#8216;gfs01&#8217; server, create the distributed glusterfs volume named &#8216;vol01&#8217; with 2 replicas &#8216;gfs01&#8217; and &#8216;gfs02&#8217;.<\/p>\n<p class=\"command\">gluster volume create vol01 replica 2 transport tcp \\<br \/>gfs01:\/glusterfs\/distributed \\<br \/>gfs02:\/glusterfs\/distributed \\<br \/>force<\/p>\n<p>Now we&#8217;ve created the distributed volume &#8216;vol01&#8217; &#8211; start the &#8216;vol01&#8217; and check the volume info.<\/p>\n<p class=\"command\">gluster volume start vol01<br \/>gluster volume info vol01<\/p>\n<p>And following is the result.<\/p>\n<p><a class=\"fancybox\" id=\"img-5\" href=\"https:\/\/www.howtoforge.com\/images\/high_availability_storage_with_glusterfs_on_ubuntu_1804\/big\/5.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/high-availability-storage-with-glusterfs-on-ubuntu-18-04-lts-4.png\" alt=\"Setup Distributed GlusterFS Volume\" width=\"500\" height=\"433\" title=\"\"><\/a><\/p>\n<p>At this stage, we created the &#8216;vol01&#8217; volume with the type &#8216;Replicate&#8217; and 2 bricks on &#8216;gfs01&#8217; and &#8216;gfs02&#8217; server. All data will be distributed automatically to each replica server, and we&#8217;re ready to mount the volume.<\/p>\n<p>Below the &#8216;vol01&#8217; volume info from the &#8216;gfs02&#8217; server.<\/p>\n<p><a class=\"fancybox\" id=\"img-6\" href=\"https:\/\/www.howtoforge.com\/images\/high_availability_storage_with_glusterfs_on_ubuntu_1804\/big\/6.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/high-availability-storage-with-glusterfs-on-ubuntu-18-04-lts-5.png\" alt=\"volume info\" width=\"500\" height=\"329\" title=\"\"><\/a><\/p>\n<h2 id=\"step-setup-glusterfs-client\">Step 4 &#8211; Setup GlusterFS Client<\/h2>\n<p>In this step, we will mount the glusterfs volume &#8216;vol01&#8217; to the Ubuntu client, and we need to install the glusterfs-client to the client server.<\/p>\n<p>Install glusterfs-client to the Ubuntu system using the\u00a0apt command.<\/p>\n<p class=\"command\">sudo apt install glusterfs-client -y<\/p>\n<p>Now create a new directory &#8216;\/mnt\/glusterfs&#8217; when the glusterfs-client installation is complete.<\/p>\n<p class=\"command\">mkdir -p \/mnt\/glusterfs<\/p>\n<p>And mount the distributed glusterfs volume &#8216;vol01&#8217; to the &#8216;\/mnt\/glusterfs&#8217; directory.<\/p>\n<p class=\"command\">sudo mount -t glusterfs gfs01:\/vol01 \/mnt\/glusterfs<\/p>\n<p>Now check the available volume on the system.<\/p>\n<p class=\"command\">df -h \/mnt\/glusterfs<\/p>\n<p>And we will get the glusterfs volume mounted to the &#8216;\/mnt\/glusterfs&#8217; directory.<\/p>\n<p><a class=\"fancybox\" id=\"img-7\" href=\"https:\/\/www.howtoforge.com\/images\/high_availability_storage_with_glusterfs_on_ubuntu_1804\/big\/7.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/high-availability-storage-with-glusterfs-on-ubuntu-18-04-lts-6.png\" alt=\"setup GlusterFS client\" width=\"500\" height=\"241\" title=\"\"><\/a><\/p>\n<p><strong>Additional:<\/strong><\/p>\n<p>To mount glusterfs permanently to the Ubuntu client system, we can add the volume to the &#8216;\/etc\/fstab&#8217;.<\/p>\n<p>Edit the &#8216;\/etc\/fstab&#8217; configuration file.<\/p>\n<p class=\"command\">vim \/etc\/fstab<\/p>\n<p>And paste configuration below.<\/p>\n<pre>gfs01:\/vol01 \/mnt\/glusterfs glusterfs defaults,_netdev 0 0<\/pre>\n<p>Save and exit.<\/p>\n<p>Now reboot the server and when it&#8217;s online, we will get the glusterfs volume &#8216;vol01&#8217; mounted automatically through the fstab.<\/p>\n<h2 id=\"step-testing-replicatemirroring\">Step 5 &#8211; Testing Replicate\/Mirroring<\/h2>\n<p>In this step, we will test the data mirroring on each server nodes.<\/p>\n<p>Mount the glusterfs volume &#8216;vol01&#8217; to each glusterfs servers.<\/p>\n<p>On &#8216;gfs01&#8217; server.<\/p>\n<p class=\"command\">mount -t glusterfs gfs01:\/vol01 \/mnt<\/p>\n<p>On &#8216;gfs02&#8217; server.<\/p>\n<p class=\"command\">mount -t glusterfs gfs02:\/vol01 \/mnt<\/p>\n<p>Now back to the Ubuntu client and go to the &#8216;\/mnt\/glusterfs&#8217; directory.<\/p>\n<p class=\"command\">cd \/mnt\/glusterfs<\/p>\n<p>Create some files using touch command.<\/p>\n<p class=\"command\">touch file01 file02 file03<\/p>\n<p><a class=\"fancybox\" id=\"img-10\" href=\"https:\/\/www.howtoforge.com\/images\/high_availability_storage_with_glusterfs_on_ubuntu_1804\/big\/10.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/high-availability-storage-with-glusterfs-on-ubuntu-18-04-lts-7.png\" alt=\"Test replication\" width=\"500\" height=\"204\" title=\"\"><\/a><\/p>\n<p>Now check on each\u00a0 &#8211; &#8216;gfs01&#8217; and &#8216;gfs02&#8217; &#8211; server, and we will get all the files that we&#8217;ve created from the client machine.<\/p>\n<p class=\"command\">cd \/mnt\/<br \/>ls -lah<\/p>\n<p>Here&#8217;s the result from the &#8216;gfs01&#8217; server.<\/p>\n<p><a class=\"fancybox\" id=\"img-8\" href=\"https:\/\/www.howtoforge.com\/images\/high_availability_storage_with_glusterfs_on_ubuntu_1804\/big\/8.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/high-availability-storage-with-glusterfs-on-ubuntu-18-04-lts-8.png\" alt=\"Result from server 1\" width=\"500\" height=\"190\" title=\"\"><\/a><\/p>\n<p>And here&#8217;s the result from the &#8216;gfs02&#8217; server.<\/p>\n<p><a class=\"fancybox\" id=\"img-9\" href=\"https:\/\/www.howtoforge.com\/images\/high_availability_storage_with_glusterfs_on_ubuntu_1804\/big\/9.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/high-availability-storage-with-glusterfs-on-ubuntu-18-04-lts-9.png\" alt=\"Result from server 2\" width=\"500\" height=\"209\" title=\"\"><\/a><\/p>\n<p>All files that we created from the client machine will be distributed to all the glusterfs volume node servers.<\/p>\n<div>\n<p><b>Share this page:<\/b><\/p>\n<p>\n<a href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fhigh-availability-storage-with-glusterfs-on-ubuntu-1804%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/high-availability-storage-with-glusterfs-on-ubuntu-18-04-lts-10.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fhigh-availability-storage-with-glusterfs-on-ubuntu-1804%2F&amp;text=High-Availability+Storage+with+GlusterFS+on+Ubuntu+18.04+LTS&amp;via=howtoforgecom&amp;related=howtoforgecom\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/high-availability-storage-with-glusterfs-on-ubuntu-18-04-lts-11.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/howtoforgecom\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/high-availability-storage-with-glusterfs-on-ubuntu-18-04-lts-12.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/plus.google.com\/share?url=https%3A%2F%2Fwww.howtoforge.com%2Ftutorial%2Fhigh-availability-storage-with-glusterfs-on-ubuntu-1804%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/07\/high-availability-storage-with-glusterfs-on-ubuntu-18-04-lts-13.png\" height=\"20\" alt=\"\" title=\"\"><\/a>\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Glusterfs is a scalable network filesystem with capabilities of scaling to several petabytes and handling thousands of clients. It&#8217;s an open source and distributed file system that sets disk storage resources from multiple servers into a single namespace. It&#8217;s suitable for data-intensive tasks such as cloud storage and data media streaming. In this tutorial, I &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-5692","post","type-post","status-publish","format-standard","hentry","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/5692","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=5692"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/5692\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=5692"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=5692"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=5692"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}