{"id":2103,"date":"2016-06-27T17:13:03","date_gmt":"2016-06-27T21:13:03","guid":{"rendered":"https:\/\/www.globo.tech\/learning-center\/?p=2103"},"modified":"2017-04-19T15:57:05","modified_gmt":"2017-04-19T19:57:05","slug":"replicate-storage-across-servers-glusterfs-centos-7","status":"publish","type":"post","link":"https:\/\/www.globo.tech\/learning-center\/replicate-storage-across-servers-glusterfs-centos-7\/","title":{"rendered":"How to Replicate Storage Across Servers using GlusterFS on CentOS 7"},"content":{"rendered":"<p>GlusterFS is a scalable network filesystem. Using common off-the-shelf hardware, you can create large, distributed storage solutions for media streaming, data analysis, and other data- and bandwidth-intensive tasks. If you want to distribute a storage pool across many servers, GlusterFS is a well-tested solution. This guide will walk you through setting up a GlusterFS cluster on CentOS 7.<\/p>\n<h2>Getting Started<\/h2>\n<p>To complete this guide, you will need the following:<br \/>\n\u2022 3 Node (<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>) running CentOS 7.<\/p>\n<p>The first Node is a web server configured to run on both the WAN and LAN. The second and third LAN-only servers are for storage. When finished, these servers will share access to a common storage pool.<\/p>\n<h2>Tutorial<\/h2>\n<p>This tutorial will guide you through setting up a shared document root for a web server. Even so, the principles are the same for setting up any other scenario where you wish to share storage between Linux boxes.<\/p>\n<p>Our network setup for this example will look as follows:<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>Set up the hosts file on these three servers so their hostnames match the above configuration.<\/p>\n<p><code>nano \/etc\/hosts<\/code><br \/>\n<code class=\"gris\">10.0.0.48 gluster1<br \/>\n10.0.0.49 gluster2<\/code><\/p>\n<p>Create the directory in which the storage pool will reside. This directory will be mounted on each node.<\/p>\n<p><code>mkdir \/data<\/code><\/p>\n<p>Next we need to install and enable the GlusterFS package repository onto each node in the cluster.<\/p>\n<p><code>cd \/etc\/yum.repos.d\/<br \/>\nwget http:\/\/download.gluster.org\/pub\/gluster\/glusterfs\/LATEST\/CentOS\/glusterfs-epel.repo<br \/>\nyum -y update<\/code><\/p>\n<p>Then install the GlusterFS package on each node. It should also be enabled to start on boot.<\/p>\n<p><code>yum install epel-release -y<br \/>\nyum install glusterfs-server -y<br \/>\nsystemctl enable glusterd.service<br \/>\nsystemctl start glusterd.service<\/code><\/p>\n<p>We must now peer the gluster1 node with gluster2.<\/p>\n<p><code>gluster peer probe gluster2<\/code><br \/>\n<code class=\"gris\">peer probe: success.<\/code><\/p>\n<p>Let&#8217;s check the status of the trusted storage pool to see how the operation went.<\/p>\n<p><code>gluster peer status<\/code><br \/>\n<code class=\"gris\">Number of Peers: 1<br \/>\nHostname: gluster2<br \/>\nUuid: 00b483de-66a5-4a74-bb49-e06718c83035<br \/>\nState: Peer in Cluster (Connected) <\/code><\/p>\n<p>Now we must create the brick directory on each node in the cluster.<\/p>\n<p>Gluster1:<br \/>\n<code>mkdir \/data\/brick1<\/code><\/p>\n<p>Gluster2:<br \/>\n<code>mkdir \/data\/brick2<\/code><\/p>\n<p>On gluster1, we must create the storage volume and replication.<\/p>\n<p><code>gluster volume create glustervol1 replica 2 transport tcp gluster1:\/data\/brick1 gluster2:\/data\/brick2 force<\/code><\/p>\n<p>If the volume is being created on the same drive as the system, \/dev\/sda for instance, you&#8217;ll need the &#8220;force&#8221; option. Otherwise it isn&#8217;t necessary.<\/p>\n<p><code class=\"gris\">Use \"force\" at the end if the volume is created on the same disk as the system disk ( sda ), if you are using a second disk for the volume ( sdb ) you don't need to force the creation of the storage volume<\/code><br \/>\n<code>volume create: glustervol1: success: please start the volume to access data<\/code><\/p>\n<p>Start the storage volume on gluster1.<\/p>\n<p><code>gluster volume start glustervol1<\/code><br \/>\n<code class=\"gris\">volume start: glustervol1: success<\/code><\/p>\n<p>Now the local IP range needs access to the storage volume on gluster1. We&#8217;ll enable 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>Check the status to see how things are progressing.<\/p>\n<p><code>gluster volume info<\/code><br \/>\n<code class=\"gris\">Volume Name: glustervol1<br \/>\nType: Replicate<br \/>\nVolume ID: c0525f18-103f-45e2-b5e3-ced9ae0b072f<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.*<br \/>\nperformance.readdir-ahead: on<\/code><\/p>\n<p>Fine-tune the GlusterFS volume on gluster1 as shown below:<\/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 performance.cache-size 1073741824<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, let&#8217;s set up the web server to serve up files from the cluster.<\/p>\n<p>Install the web server package on web1, enabling it to start on boot.<\/p>\n<p><code>yum install httpd -y<br \/>\nsystemctl enable httpd.service<br \/>\nsystemctl start httpd.service<\/code><\/p>\n<p>We&#8217;ll next mount the GlusterFS filesystem on \/var\/www\/html so the web server can access it.<\/p>\n<p><code>mount.glusterfs gluster1:\/glustervol1 \/var\/www\/html\/<\/code><\/p>\n<p>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,relatime,user_id=0,group_id=0,default_permissions,allow_other,max_read=131072)<\/code><\/p>\n<p>The mount entry must be added to \/etc\/fstab so it becomes available automatically on boot.<\/p>\n<p><code>nano \/etc\/fstab<\/code><br \/>\nadd 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>Let&#8217;s see if replication is working. Create a file on web1 in the document root.<br \/>\n<code>cd \/var\/www\/html<br \/>\ntouch index.html<\/code><\/p>\n<p>Examine the volume on both Gluster nodes to determine if the file exists.<\/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 now have a robust storage system that spans multiple servers. While this example is targeted at a web server, it is easy to adapt it for other circumstances that might benefit from a shared storage pool. If this guide was helpful to you, kindly share it with others who may also be interested. <\/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>GlusterFS is a scalable network filesystem. Using common off-the-shelf hardware, you can create large, distributed storage solutions for media streaming, data analysis, and other data- and bandwidth-intensive tasks. If you want to distribute a storage pool across many servers, GlusterFS is a well-tested solution. This guide will walk you through setting up a GlusterFS cluster<!-- 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-2103","post","type-post","status-publish","format-standard","hentry","category-applications","category-ha-clustering","operating_system-centos-7"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Replicate Storage Across Servers using GlusterFS on CentOS 7 - Globo.Tech<\/title>\n<meta name=\"description\" content=\"This tutorial will show you how to Replicate Storage Accross Servers using GlusterFS cluster on your CentOS 7 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-centos-7\/\" \/>\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 CentOS 7 - Globo.Tech\" \/>\n<meta property=\"og:description\" content=\"This tutorial will show you how to Replicate Storage Accross Servers using GlusterFS cluster on your CentOS 7 server. Read now!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.globo.tech\/learning-center\/replicate-storage-across-servers-glusterfs-centos-7\/\" \/>\n<meta property=\"og:site_name\" content=\"Globo.Tech\" \/>\n<meta property=\"article:published_time\" content=\"2016-06-27T21:13:03+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-04-19T19:57:05+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\":\"Article\",\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/replicate-storage-across-servers-glusterfs-centos-7\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/replicate-storage-across-servers-glusterfs-centos-7\\\/\"},\"author\":{\"name\":\"GloboTech Communications\",\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/#\\\/schema\\\/person\\\/e17784b37f4a4f49b7bc611847912e87\"},\"headline\":\"How to Replicate Storage Across Servers using GlusterFS on CentOS 7\",\"datePublished\":\"2016-06-27T21:13:03+00:00\",\"dateModified\":\"2017-04-19T19:57:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/replicate-storage-across-servers-glusterfs-centos-7\\\/\"},\"wordCount\":522,\"commentCount\":0,\"articleSection\":[\"Applications\",\"HA &amp; Clustering\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/replicate-storage-across-servers-glusterfs-centos-7\\\/\",\"url\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/replicate-storage-across-servers-glusterfs-centos-7\\\/\",\"name\":\"How to Replicate Storage Across Servers using GlusterFS on CentOS 7 - Globo.Tech\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/#website\"},\"datePublished\":\"2016-06-27T21:13:03+00:00\",\"dateModified\":\"2017-04-19T19:57:05+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/#\\\/schema\\\/person\\\/e17784b37f4a4f49b7bc611847912e87\"},\"description\":\"This tutorial will show you how to Replicate Storage Accross Servers using GlusterFS cluster on your CentOS 7 server. Read now!\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/replicate-storage-across-servers-glusterfs-centos-7\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/replicate-storage-across-servers-glusterfs-centos-7\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.globo.tech\\\/learning-center\\\/replicate-storage-across-servers-glusterfs-centos-7\\\/#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 CentOS 7\"}]},{\"@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 CentOS 7 - Globo.Tech","description":"This tutorial will show you how to Replicate Storage Accross Servers using GlusterFS cluster on your CentOS 7 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-centos-7\/","og_locale":"en_US","og_type":"article","og_title":"How to Replicate Storage Across Servers using GlusterFS on CentOS 7 - Globo.Tech","og_description":"This tutorial will show you how to Replicate Storage Accross Servers using GlusterFS cluster on your CentOS 7 server. Read now!","og_url":"https:\/\/www.globo.tech\/learning-center\/replicate-storage-across-servers-glusterfs-centos-7\/","og_site_name":"Globo.Tech","article_published_time":"2016-06-27T21:13:03+00:00","article_modified_time":"2017-04-19T19:57:05+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":"Article","@id":"https:\/\/www.globo.tech\/learning-center\/replicate-storage-across-servers-glusterfs-centos-7\/#article","isPartOf":{"@id":"https:\/\/www.globo.tech\/learning-center\/replicate-storage-across-servers-glusterfs-centos-7\/"},"author":{"name":"GloboTech Communications","@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87"},"headline":"How to Replicate Storage Across Servers using GlusterFS on CentOS 7","datePublished":"2016-06-27T21:13:03+00:00","dateModified":"2017-04-19T19:57:05+00:00","mainEntityOfPage":{"@id":"https:\/\/www.globo.tech\/learning-center\/replicate-storage-across-servers-glusterfs-centos-7\/"},"wordCount":522,"commentCount":0,"articleSection":["Applications","HA &amp; Clustering"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.globo.tech\/learning-center\/replicate-storage-across-servers-glusterfs-centos-7\/","url":"https:\/\/www.globo.tech\/learning-center\/replicate-storage-across-servers-glusterfs-centos-7\/","name":"How to Replicate Storage Across Servers using GlusterFS on CentOS 7 - Globo.Tech","isPartOf":{"@id":"https:\/\/www.globo.tech\/learning-center\/#website"},"datePublished":"2016-06-27T21:13:03+00:00","dateModified":"2017-04-19T19:57:05+00:00","author":{"@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87"},"description":"This tutorial will show you how to Replicate Storage Accross Servers using GlusterFS cluster on your CentOS 7 server. Read now!","breadcrumb":{"@id":"https:\/\/www.globo.tech\/learning-center\/replicate-storage-across-servers-glusterfs-centos-7\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.globo.tech\/learning-center\/replicate-storage-across-servers-glusterfs-centos-7\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.globo.tech\/learning-center\/replicate-storage-across-servers-glusterfs-centos-7\/#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 CentOS 7"}]},{"@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\/2103","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=2103"}],"version-history":[{"count":10,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2103\/revisions"}],"predecessor-version":[{"id":2852,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2103\/revisions\/2852"}],"wp:attachment":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/media?parent=2103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/categories?post=2103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/tags?post=2103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}