{"id":2582,"date":"2016-08-24T15:29:22","date_gmt":"2016-08-24T19:29:22","guid":{"rendered":"https:\/\/www.globo.tech\/learning-center\/?p=2582"},"modified":"2018-01-12T14:08:13","modified_gmt":"2018-01-12T19:08:13","slug":"replicate-storage-across-servers-glusterfs-ubuntu-14","status":"publish","type":"post","link":"https:\/\/www.globo.tech\/learning-center\/replicate-storage-across-servers-glusterfs-ubuntu-14\/","title":{"rendered":"How to Replicate Storage Across Servers using GlusterFS on Ubuntu 14"},"content":{"rendered":"<h1>How to Replicate Storage Across Servers using GlusterFS on Ubuntu 14<\/h1>\n<p>GlusterFS is a highly-available, replicated storage layer that transparently expands storage across servers. If you&#8217;re looking for a way to access the same files on multiple web servers, or to share storage across a containerized cluster, GlusterFS is a great way of ensuring that your data is located with the apps and services that require it. In this guide we&#8217;ll set up an Ubuntu 14.04 LTS GlusterFS cluster on which you can run other services that need a clustered network filesystem.<\/p>\n<h2>Getting Started<\/h2>\n<p>This guide expects that you have the following hardware, real or virtual, in place before beginning:<br \/>\n\u2022 Web server (<a href=\"https:\/\/www.globo.tech\/cloud-server-pricing\" target=\"_blank\">Cloud Server<\/a> or <a href=\"http:\/\/www.globo.tech\/dedicated-server-hosting\" target=\"_blank\">Dedicated Server<\/a>) with configured LAN and WAN interfaces<br \/>\n\u2022 Storage server with only a LAN interface configured<br \/>\n\u2022 Root access on all servers<\/p>\n<h2>Tutorial<\/h2>\n<p>This guide sets up a replicated document root for a web server. The principles can be used for any other shared storage scenario by identifying the parts of the filesystem you&#8217;d like to cluster, and by changing the GlusterFS setup accordingly.<\/p>\n<p>Begin by setting up the LAN network interface.<br \/>\n\u2022 web1: 10.0.0.47<br \/>\n\u2022 gluster1: 10.0.0.48<br \/>\n\u2022 gluster2: 10.0.0.49<\/p>\n<p>In order for the GlusterFS nodes to communicate, we&#8217;ll edit each of their hosts files and set custom hostnames for each system.<\/p>\n<p><code>nano \/etc\/hosts<\/code><br \/>\n<code class=\"gris\">10.0.0.48\tgluster1<br \/>\n10.0.0.49\tgluster2<\/code><\/p>\n<p>GlusterFS needs a directory where files are to be stored. Files in this directory will be transparently replicated between nodes. That same directory will be the web server&#8217;s document root, serving up files via HTTP.<\/p>\n<p><code>mkdir \/data<\/code><\/p>\n<p>With the nodes configured and the directory made, let&#8217;s install GlusterFS itself onto each node in the cluster.<\/p>\n<p><code>apt-get install glusterfs-server<\/code><\/p>\n<p>From gluster1, you&#8217;ll now need to peer with the second node.<\/p>\n<p><code>gluster peer probe gluster2<\/code><br \/>\n<code class=\"gris\">peer probe: success.<\/code><\/p>\n<p>With that accomplished, let&#8217;s display the status of the configured trusted storage pool.<\/p>\n<p><code>gluster peer status<\/code><br \/>\n<code class=\"gris\">Number of Peers: 1<br \/>\nHostname: gluster2<br \/>\nPort: 24007<br \/>\nUuid: c9648c88-2502-46c6-8f70-1d70d83126b5<br \/>\nState: Peer in Cluster (Connected)<\/code><\/p>\n<p>Each Gluster node needs a brick directory where internal data is tracked. Here we set up these directories on each node in the cluster.<\/p>\n<p>Gluster1:<\/p>\n<p><code>mkdir \/data\/brick1<\/code><\/p>\n<p>Gluster2:<\/p>\n<p><code>mkdir \/data\/brick2<\/code><\/p>\n<p>On gluster1, we need to create a storage volume and replication. If the volume is being created on the same disk, \/dev\/sda for example, you&#8217;ll need to use the &#8220;&#8211;force&#8221; flag to force its creation.<\/p>\n<p><code>gluster volume create glustervol1 replica 2 transport tcp gluster1:\/data\/brick1 gluster2:\/data\/brick2 force<\/code><\/p>\n<p>volume create: glustervol1: success: please start the volume to access data<\/p>\n<p>Now launch the volume you&#8217;ve just created on gluster1.<\/p>\n<p><code>gluster volume start glustervol1<\/code><br \/>\n<code class=\"gris\">volume start: glustervol1: success<\/code><\/p>\n<p>The local IP range must now be configured to have access to the newly-created volume. We&#8217;ll take care of that here.<\/p>\n<p><code>gluster volume set glustervol1 auth.allow 10.0.0.*<\/code><br \/>\n<code class=\"gris\">volume set: success<\/code><\/p>\n<p>Let&#8217;s view the status of the volume after the changes we&#8217;ve just made.<\/p>\n<p><code>gluster volume info<\/code><br \/>\n<code class=\"gris\">Volume Name: glustervol1<br \/>\nType: Replicate<br \/>\nVolume ID: 8044a7e7-8812-47b9-8f96-9d09fae1298a<br \/>\nStatus: Started<br \/>\nNumber of Bricks: 1 x 2 = 2<br \/>\nTransport-type: tcp<br \/>\nBricks:<br \/>\nBrick1: gluster1:\/data\/brick1<br \/>\nBrick2: gluster2:\/data\/brick2<br \/>\nOptions Reconfigured:<br \/>\nauth.allow: 10.0.0.*<\/code><\/p>\n<p>Now we&#8217;ll add some fine-tuning for the new volume.<\/p>\n<p><code>gluster volume set glustervol1 performance.write-behind off<br \/>\ngluster volume set glustervol1 performance.io-thread-count 64<br \/>\ngluster volume set glustervol1 network.ping-timeout \"5\"<br \/>\ngluster volume set glustervol1 performance.write-behind-window-size 524288<br \/>\ngluster volume set glustervol1 performance.cache-refresh-timeout 1<\/code><\/p>\n<p>Great, our volume is operating. Next we&#8217;ll set up the web server to retrieve files from the clustered filesystem. Install a basic web server on web1, the web server and GlusterFS client.<\/p>\n<p><code>apt-get install apache2 -y<br \/>\napt-get install glusterfs-client -y<\/code><\/p>\n<p>Next we&#8217;ll mount the GlusterFS volume at \/var\/www\/html.<\/p>\n<p><code>mount.glusterfs gluster1:\/glustervol1 \/var\/www\/html\/<\/code><\/p>\n<p>Having done this, we now confirm that the mount succeeded.<\/p>\n<p><code>mount | grep glusterfs<\/code><br \/>\n<code class=\"gris\">gluster1:\/glustervol1 on \/var\/www\/html type fuse.glusterfs (rw,default_permissions,allow_other,max_read=131072)<\/code><\/p>\n<p>To ensure that the filesystem is mounted on every boot, we&#8217;ll add the GlusterFS mount to \/etc\/fstab on the web server.<\/p>\n<p><code>nano \/etc\/fstab<\/code><\/p>\n<p>Add this line at the end :<\/p>\n<p><code class=\"gris\">gluster1:\/glustervol1      \/var\/www\/html                glusterfs defaults,_netdev,direct-io-mode=disable 0 0<\/code><\/p>\n<p>Now it&#8217;s time to put GlusterFS&#8217; replication through its paces. Create a file on the web1 web server, in its document root.<\/p>\n<p><code>cd \/var\/www\/html<br \/>\ntouch index.html<\/code><\/p>\n<p>Check that the file exists in both nodes of the GlusterFS cluster.<\/p>\n<p>Gluster1:<br \/>\n<code>ls \/data\/brick1<br \/>\nindex.html<\/code><\/p>\n<p>Gluster2:<br \/>\n<code>ls \/data\/brick2<br \/>\nindex.html<\/code><\/p>\n<h2>Conclusion<\/h2>\n<p>You&#8217;re now serving up files that are distributed across this simple 2-node cluster. Expanding this setup to many more machines is a great way to play around with the power of GlusterFS. GlusterFS is a great tool for anyone needing a highly-available storage solution. If you found this article helpful, feel free to share it with your friends and let us know in the comments below!<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>How to Replicate Storage Across Servers using GlusterFS on Ubuntu 14 GlusterFS is a highly-available, replicated storage layer that transparently expands storage across servers. If you&#8217;re looking for a way to access the same files on multiple web servers, or to share storage across a containerized cluster, GlusterFS is a great way of ensuring that<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[71,75],"tags":[],"class_list":["post-2582","post","type-post","status-publish","format-standard","hentry","category-applications","category-ha-clustering","operating_system-ubuntu-14-04"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Replicate Storage Across Servers using GlusterFS on Ubuntu 14 - Globo.Tech<\/title>\n<meta name=\"description\" content=\"This tutorial will show you how to replicate storage accross server using GlusterFS on your Ubuntu 14.04 server. Read now !\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.globo.tech\/learning-center\/replicate-storage-across-servers-glusterfs-ubuntu-14\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Replicate Storage Across Servers using GlusterFS on Ubuntu 14 - Globo.Tech\" \/>\n<meta property=\"og:description\" content=\"This tutorial will show you how to replicate storage accross server using GlusterFS on your Ubuntu 14.04 server. Read now !\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.globo.tech\/learning-center\/replicate-storage-across-servers-glusterfs-ubuntu-14\/\" \/>\n<meta property=\"og:site_name\" content=\"Globo.Tech\" \/>\n<meta property=\"article:published_time\" content=\"2016-08-24T19:29:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-01-12T19:08:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/GloboTech-Logo.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"963\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"GloboTech Communications\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"GloboTech Communications\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/replicate-storage-across-servers-glusterfs-ubuntu-14\/\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/replicate-storage-across-servers-glusterfs-ubuntu-14\/\",\"name\":\"How to Replicate Storage Across Servers using GlusterFS on Ubuntu 14 - Globo.Tech\",\"isPartOf\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\"},\"datePublished\":\"2016-08-24T19:29:22+00:00\",\"dateModified\":\"2018-01-12T19:08:13+00:00\",\"author\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87\"},\"description\":\"This tutorial will show you how to replicate storage accross server using GlusterFS on your Ubuntu 14.04 server. Read now !\",\"breadcrumb\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/replicate-storage-across-servers-glusterfs-ubuntu-14\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.globo.tech\/learning-center\/replicate-storage-across-servers-glusterfs-ubuntu-14\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/replicate-storage-across-servers-glusterfs-ubuntu-14\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.globo.tech\/learning-center\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Replicate Storage Across Servers using GlusterFS on Ubuntu 14\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/\",\"name\":\"Globo.Tech\",\"description\":\"Welcome to the Official Globo.Tech Learning Center\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87\",\"name\":\"GloboTech Communications\",\"sameAs\":[\"http:\/\/www.gtcomm.net\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Replicate Storage Across Servers using GlusterFS on Ubuntu 14 - Globo.Tech","description":"This tutorial will show you how to replicate storage accross server using GlusterFS on your Ubuntu 14.04 server. Read now !","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.globo.tech\/learning-center\/replicate-storage-across-servers-glusterfs-ubuntu-14\/","og_locale":"en_US","og_type":"article","og_title":"How to Replicate Storage Across Servers using GlusterFS on Ubuntu 14 - Globo.Tech","og_description":"This tutorial will show you how to replicate storage accross server using GlusterFS on your Ubuntu 14.04 server. Read now !","og_url":"https:\/\/www.globo.tech\/learning-center\/replicate-storage-across-servers-glusterfs-ubuntu-14\/","og_site_name":"Globo.Tech","article_published_time":"2016-08-24T19:29:22+00:00","article_modified_time":"2018-01-12T19:08:13+00:00","og_image":[{"width":1920,"height":963,"url":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/GloboTech-Logo.png","type":"image\/png"}],"author":"GloboTech Communications","twitter_misc":{"Written by":"GloboTech Communications","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.globo.tech\/learning-center\/replicate-storage-across-servers-glusterfs-ubuntu-14\/","url":"https:\/\/www.globo.tech\/learning-center\/replicate-storage-across-servers-glusterfs-ubuntu-14\/","name":"How to Replicate Storage Across Servers using GlusterFS on Ubuntu 14 - Globo.Tech","isPartOf":{"@id":"https:\/\/www.globo.tech\/learning-center\/#website"},"datePublished":"2016-08-24T19:29:22+00:00","dateModified":"2018-01-12T19:08:13+00:00","author":{"@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87"},"description":"This tutorial will show you how to replicate storage accross server using GlusterFS on your Ubuntu 14.04 server. Read now !","breadcrumb":{"@id":"https:\/\/www.globo.tech\/learning-center\/replicate-storage-across-servers-glusterfs-ubuntu-14\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.globo.tech\/learning-center\/replicate-storage-across-servers-glusterfs-ubuntu-14\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.globo.tech\/learning-center\/replicate-storage-across-servers-glusterfs-ubuntu-14\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.globo.tech\/learning-center\/"},{"@type":"ListItem","position":2,"name":"How to Replicate Storage Across Servers using GlusterFS on Ubuntu 14"}]},{"@type":"WebSite","@id":"https:\/\/www.globo.tech\/learning-center\/#website","url":"https:\/\/www.globo.tech\/learning-center\/","name":"Globo.Tech","description":"Welcome to the Official Globo.Tech Learning Center","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87","name":"GloboTech Communications","sameAs":["http:\/\/www.gtcomm.net"]}]}},"_links":{"self":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2582","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/comments?post=2582"}],"version-history":[{"count":3,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2582\/revisions"}],"predecessor-version":[{"id":4086,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2582\/revisions\/4086"}],"wp:attachment":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/media?parent=2582"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/categories?post=2582"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/tags?post=2582"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}