{"id":697,"date":"2016-10-06T12:51:34","date_gmt":"2016-10-06T12:51:34","guid":{"rendered":"https:\/\/blog.ngocha.biz\/?p=697"},"modified":"2016-10-06T12:51:34","modified_gmt":"2016-10-06T12:51:34","slug":"replicated-glusterfs-cluster-aws-ec2","status":"publish","type":"post","link":"https:\/\/blog.ngocha.biz\/?p=697","title":{"rendered":"How to Setup a Replicated GlusterFS Cluster on AWS EC2"},"content":{"rendered":"<p><a href=\"http:\/\/searchstorage.techtarget.com\/definition\/GlusterFS-Gluster-File-System?ref=devopscube.com\" rel=\"noopener noreferrer\">GlusterFS<\/a>  is one of the best open source distributed file systems. If you want a highly available distributed file system for your applications, GlusterFs is one of the good options.<\/p>\n<p><strong>Now:<\/strong> AWS offers a managed scalable file storage called <a href=\"https:\/\/aws.amazon.com\/efs\/?ref=devopscube.com\">Elastic File System<\/a>. If you don&#8217;t want the administrative overhead of glusterFS clusters, you can give EFS a try.<\/p>\n<h3 id=\"glusterfs-cluster-on-aws-ec2\">GlusterFS cluster on AWS ec2<\/h3>\n<p>This guide covers all the necessary steps to setup a GlusterFs cluster using ec2 instances and extra EBS volumes. Here we are setting up a two node cluster, however, you can increase the node count based on your needs.<\/p>\n<h3 id=\"instance-configurations\">Instance Configurations<\/h3>\n<p>1. Create two instances with extra EBS volumes.<\/p>\n<p>2. Make sure the instances can talk to each other.<\/p>\n<p>3. Login to the servers and set the hostnames as node1 and node2 using the following commands.<\/p>\n<pre><code>hostnamectl set-hostname node1\nhostnamectl set-hostname node2<\/code><\/pre>\n<p>Run <code>bash<\/code> on the terminal for the hostname to show up.<\/p>\n<p>4. Make an entry in the&nbsp;<code>\/etc\/hosts<\/code>&nbsp;file with the IP and hostname of both servers as shown below. The IP\u2019s should be resolvable using the hostnames. Change the IP in the following to your server IP\u2019s.<\/p>\n<pre><code>172.31.21.201 node1\n172.31.21.202 node2<\/code><\/pre>\n<h3 id=\"instance-port-configuration\">Instance Port Configuration<\/h3>\n<p>You need to open the following ports int he ec2 security groups as well the server firewall if it is enabled.<\/p>\n<pre><code>111\n24007 - GlusterFS Daemon. 24008 - GlusterFS Management 38465 to 38467 - GlusterFS NFS service 49152 to n - Depends on number of bricks.<\/code><\/pre>\n<h3 id=\"create-mount-points-for-ebs-volumes\">Create Mount Points for EBS Volumes<\/h3>\n<p>You need to do the following in both the ec2 instances. 1. Format the volume to xfs. <\/p>\n<pre><code>sudo mkfs -t xfs \/dev\/xvdb<\/code><\/pre>\n<p><code>xvdb<\/code> is the name of the EBS volume. You can list the available devices using <code>lsblk<\/code> command.<\/p>\n<p>2. Create a mount directory named&nbsp;<code>\/gshare<\/code>&nbsp;and mount the formatted volume.<\/p>\n<pre><code>sudo mkdir \/gshare\nsudo mount \/share \/dev\/xvdb<\/code><\/pre>\n<p>3. Add the mount to&nbsp;<code>\/etc\/fstab<\/code><\/p>\n<pre><code>\/dev\/xvdb    \/gshare   xfs   defaults,nofail     0<\/code><\/pre>\n<h3 id=\"glusterfs-installation\">GlusterFS Installation<\/h3>\n<p>Perform the following steps on both the servers.<\/p>\n<ol>\n<li>Create a GlusterFs repo.<\/li>\n<\/ol>\n<pre><code>sudo vi \/etc\/yum.repos.d\/Gluster.repo<\/code><\/pre>\n<p>Copy the following to the repo file.<\/p>\n<pre><code>[gluster38]\nname=Gluster 3.8\nbaseurl=http:\/\/mirror.centos.org\/centos\/7\/storage\/$basearch\/gluster-3.8\/\ngpgcheck=0\nenabled=1<\/code><\/pre>\n<p>2. Install GlusterFS server.<\/p>\n<pre><code>sudo yum install glusterfs-server -y<\/code><\/pre>\n<p>3. Start and verify the glusterd service.<\/p>\n<pre><code>sudo systemctl  start glusterd\nsudo systemctl  status glusterd<\/code><\/pre>\n<h3 id=\"glusterfs-configuration\">GlusterFs Configuration<\/h3>\n<p>1. From node1 execute the following command to create a trusted storage pool with node2. <\/p>\n<pre><code>sudo gluster peer probe node2<\/code><\/pre>\n<p>After successful execution, you would get <code>peer probe: success.<\/code> as output.<\/p>\n<p>2. Check the peer status using the following command.<\/p>\n<pre><code>[ec2-user@node1 ~]$ sudo gluster peer status Number of Peers: 1 Hostname: node2 Uuid: 47ee8304-36ea-4b95-9214-4854bc98b737 State: Peer in Cluster (Connected) [ec2-user@node1 ~]$<\/code><\/pre>\n<p>3. Create a&nbsp;<code>data<\/code>&nbsp;directory on&nbsp;<code>gshare<\/code>&nbsp;mount on both the servers.<\/p>\n<pre><code>sudo mkdir \/gshare\/data<\/code><\/pre>\n<ol start=\"4\">\n<li>Create a GlusterFS HA shared volume.<\/li>\n<\/ol>\n<pre><code>sudo gluster volume create gdata replica 2 node1:\/gshare\/data node2:\/gshare\/data<\/code><\/pre>\n<p>5. Start the&nbsp;<code>gdata<\/code>&nbsp;volume.<\/p>\n<pre><code>sudo gluster volume start gdata<\/code><\/pre>\n<p>6. By default NFS is disabled. If you want NFS functionality for glusterFs volume, you can enable it using the following command.<\/p>\n<pre><code>sudo gluster volume set gdata nfs.disable off<\/code><\/pre>\n<p>7. Set the volume permissions for&nbsp;<code>gdata<\/code>&nbsp;volume for client access. Here I am using&nbsp;<code>172.*<\/code>&nbsp;CIDR. You need to replace it based on your network range.<\/p>\n<pre><code>sudo gluster volume set gdata auth.allow \"172.*\"<\/code><\/pre>\n<p>8. To get all the info about the volume, execute the following command.<\/p>\n<pre><code>sudo gluster volume info gdata<\/code><\/pre>\n<h3 id=\"glusterfs-client-setup\">GlusterFS Client Setup<\/h3>\n<p>1. Enable <code>fuse<\/code> kernel module. <\/p>\n<pre><code>sudo modprobe fuse2. <\/code><\/pre>\n<ol start=\"2\">\n<li>Install all the glusterFS client dependencies. <\/li>\n<\/ol>\n<pre><code>sudo yum install fuse fuse-libs openib libibverbs -y<\/code><\/pre>\n<p>3. Install the GlusterFS client. <\/p>\n<pre><code>sudo yum install  glusterfs-client -y<\/code><\/pre>\n<h3 id=\"glusterfs-client-configuration\">GlusterFS Client Configuration<\/h3>\n<p>The data will get replicated only if you are writing from a GlusterFS client. You can mount the GlusterFS volume to any number of clients. We highly recommend you to map the gluster nodes to a domain name and use it with the clients for mounting.<\/p>\n<p><strong>Note<\/strong> A client machine is not part of the glusterFS cluster. It is the machine in which you want to mount the replicated volume.<\/p>\n<ol>\n<li>Create a client mount directory.<\/li>\n<\/ol>\n<pre><code>sudo mkdir \/gfdata<\/code><\/pre>\n<p>2. Mount&nbsp;<code>gfdata<\/code>&nbsp;directory to the glusterFS replicated volume.<\/p>\n<pre><code>sudo mount -t glusterfs node1:\/gdata \/gfdata<\/code><\/pre>\n<h3 id=\"troubleshooting-glusterfs\">Troubleshooting GlusterFs<\/h3>\n<p>1. You can view all the logs of gluserFS server on the following directory.<\/p>\n<pre><code> \/var\/log\/glusterfs<\/code><\/pre>\n<p>To monitor logs in real time you can use <code>tail -f<\/code> along with the path to log file. <\/p>\n<p>2. All glusterfs client logs are saved in the following with the volume name. <\/p>\n<pre><code>\/var\/log\/glusterfs\/<\/code><\/pre>\n<hr>\n<p><strong>Ngu\u1ed3n:<\/strong> <a href=\"https:\/\/devopscube.com\/replicated-glusterfs-cluster-aws-ec2\/\" target=\"_blank\" rel=\"noopener noreferrer\">How to Setup a Replicated GlusterFS Cluster on AWS EC2 \u2014 DevOpsCube<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Source: https:\/\/devopscube.com\/replicated-glusterfs-cluster-aws-ec2\/<\/p>\n","protected":false},"author":1,"featured_media":698,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-697","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops"],"_links":{"self":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/697","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=697"}],"version-history":[{"count":0,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/697\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/media\/698"}],"wp:attachment":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=697"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=697"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}