{"id":11813,"date":"2019-03-17T12:10:42","date_gmt":"2019-03-17T12:10:42","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=11813"},"modified":"2019-03-17T12:10:42","modified_gmt":"2019-03-17T12:10:42","slug":"introduction-to-clusters-in-linux","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/17\/introduction-to-clusters-in-linux\/","title":{"rendered":"Introduction to Clusters in Linux"},"content":{"rendered":"<p>Hi all, this time I decided to share my knowledge about Linux clustering with you as a series of guides titled \u201c<strong>Linux Clustering For a Failover Scenario<\/strong>\u201c.<\/p>\n<div id=\"attachment_14838\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/What-is-Clustering-in-Linux.jpeg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-14838\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/What-is-Clustering-in-Linux-620x294.jpeg\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/What-is-Clustering-in-Linux-620x294.jpeg 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/What-is-Clustering-in-Linux-720x340.jpeg 720w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/What-is-Clustering-in-Linux.jpeg 782w\" alt=\"What is Clustering in Linux\" width=\"620\" height=\"294\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">What is Clustering in Linux and Advantages\/Disadvantages \u2013 Part 1<\/p>\n<\/div>\n<p>Following are the 4-article series about\u00a0<strong>Clustering<\/strong>\u00a0in Linux:<\/p>\n<div id=\"exam_announcement\"><b>Part 1<\/b>:\u00a0<b>Introduction to Linux Clustering and Advantages\/Disadvanges of Clustering<\/b><\/div>\n<div id=\"exam_announcement\"><b>Part 2<\/b>:\u00a0<a href=\"https:\/\/www.tecmint.com\/cman-multi-node-cluster-setup-in-linux\/\" target=\"_blank\" rel=\"noopener\">How to Install and Configure Cluster with Two Nodes in Linux<\/a><\/div>\n<div id=\"exam_announcement\"><b>Part 3<\/b>:\u00a0<a href=\"https:\/\/www.tecmint.com\/fencing-and-adding-a-failover-to-clustering-server\/\" target=\"_blank\" rel=\"noopener\">Fencing and Adding a Failover to Clustering<\/a><\/div>\n<div id=\"exam_announcement\"><b>Part 4<\/b>:\u00a0<a href=\"https:\/\/www.tecmint.com\/sync-cluster-configuration-and-verify-failover-setup-in-nodes\/\" target=\"_blank\" rel=\"noopener\">How to Sync Cluster Configuration and Verify Failover Setup in Nodes<\/a><\/div>\n<p>First of all, you will need to know what clustering is, how it is used in industry and what kind of advantages and drawbacks it has etc.<\/p>\n<h3>What is Clustering<\/h3>\n<p><strong>Clustering<\/strong>\u00a0is establishing connectivity among two or more servers in order to make it work like one. Clustering is a very popular technic among Sys-Engineers that they can cluster servers as a failover system, a load balance system or a parallel processing unit.<\/p>\n<p>By this series of guide, I hope to guide you to create a Linux cluster with two nodes on\u00a0<strong>RedHat<\/strong>\/<strong>CentOS<\/strong>\u00a0for a failover scenario.<\/p>\n<p>Since now you have a basic idea of what clustering is, let\u2019s find out what it means when it comes to failover clustering. A failover cluster is a set of servers that works together to maintain the high availability of applications and services.<\/p>\n<p>For an example, if a server fails at some point, another node (server) will take over the load and gives end user no experience of down time. For this kind of scenario, we need at least\u00a0<strong>2<\/strong>\u00a0or\u00a0<strong>3<\/strong>\u00a0servers to make the proper configurations.<\/p>\n<p>I prefer we use\u00a0<strong>3<\/strong>\u00a0servers; one server as the red hat cluster enabled server and others as nodes (back end servers). Let\u2019s look at below diagram for better understanding.<\/p>\n<pre><strong>Cluster Server<\/strong>: <strong>172.16.1.250<\/strong>\r\n<strong>Hostname<\/strong>: <strong>clserver.test.net<\/strong>\r\n\r\n<strong>node01<\/strong>: <strong>172.16.1.222<\/strong>\r\n<strong>Hostname<\/strong>: <strong>nd01server.test.net<\/strong>\r\n\r\n<strong>node02<\/strong>: <strong>172.16.1.223<\/strong>\r\n<strong>Hostname<\/strong>: <strong>nd02server.test.net <\/strong>  \r\n<\/pre>\n<div id=\"attachment_14750\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Clustering.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-14750\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Clustering.jpg\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Clustering.jpg 720w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Clustering-620x297.jpg 620w\" alt=\"Clustering Diagram \" width=\"620\" height=\"297\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Clustering Diagram<\/p>\n<\/div>\n<p>In above scenario, cluster management is done by a separate server and it handles two nodes as shown by the diagram. Cluster management server constantly sends heartbeat signals to both nodes to check whether if anyone is failing. If anyone has failed, the other node takes over the load.<\/p>\n<h4>Advantages of Clustering Servers<\/h4>\n<ol>\n<li>Clustering servers is completely a scalable solution. You can add resources to the cluster afterwards.<\/li>\n<li>If a server in the cluster needs any maintenance, you can do it by stopping it while handing the load over to other servers.<\/li>\n<li>Among high availability options, clustering takes a special place since it is reliable and easy to configure. In case of a server is having a problem providing the services furthermore, other servers in the cluster can take the load.<\/li>\n<\/ol>\n<h4>Disadvantages of Clustering Servers<\/h4>\n<ol>\n<li>Cost is high. Since the cluster needs good hardware and a design, it will be costly comparing to a non-clustered server management design. Being not cost effective is a main disadvantage of this particular design.<\/li>\n<li>Since clustering needs more servers and hardware to establish one, monitoring and maintenance is hard. Thus increase the infrastructure.<\/li>\n<\/ol>\n<p>Now let\u2019s see what kind of packages\/installations we need to configure this setup successfully. The following packages\/RPMs can be downloaded by\u00a0<strong>rpmfind.net<\/strong>.<\/p>\n<ol>\n<li>Ricci (ricci-0.16.2-75.el6.x86_64.rpm)<\/li>\n<li>Luci (luci-0.26.0-63.el6.centos.x86_64.rpm)<\/li>\n<li>Mod_cluster (modcluster-0.16.2-29.el6.x86_64.rpm)<\/li>\n<li>CCS (ccs-0.16.2-75.el6_6.2.x86_64.rpm)<\/li>\n<li>CMAN(cman-3.0.12.1-68.el6.x86_64.rpm)<\/li>\n<li>Clusterlib (clusterlib-3.0.12.1-68.el6.x86_64.rpm)<\/li>\n<\/ol>\n<p>Let\u2019s see what each installation does for us and their meanings.<\/p>\n<ol>\n<li><strong>Ricci<\/strong>\u00a0is a daemon which used for cluster management and configurations. It distributes\/dispatches receiving messages to the nodes configured.<\/li>\n<li><strong>Luci<\/strong>\u00a0is a server that runs on the cluster management server and communicates with other multiple nodes. It provides a web interface to make things easier.<\/li>\n<li><strong>Mod_cluster<\/strong>\u00a0is a load balancer utility based on httpd services and here it is used to communicate the incoming requests with the underlying nodes.<\/li>\n<li><strong>CCS<\/strong>\u00a0is used to create and modify the cluster configuration on remote nodes through ricci. It is also used to start and stop the cluster services.<\/li>\n<li><strong>CMAN<\/strong>\u00a0is one of the primary utilities other than ricci and luci for this particular setup, since this acts as the cluster manager. Actually, cman stands for CLUSTER MANAGER. It is a high-availability add-on for RedHat which is distributed among the nodes in the cluster.<\/li>\n<\/ol>\n<p>Read the article, understand the scenario we\u2019re going to create the solution to, and set the pre-requisites for the implementation. Let\u2019s meet with the Part 2, in our upcoming article, where we learn How to install and create the cluster for the given scenario.<\/p>\n<h3>References:<\/h3>\n<ol>\n<li><a href=\"https:\/\/access.redhat.com\/documentation\/en-US\/Red_Hat_Enterprise_Linux\/6\/html\/High_Availability_Add-On_Overview\/ch-cman.html\" target=\"_blank\" rel=\"nofollow noopener\">ch-cman Documentation<\/a><\/li>\n<li><a href=\"http:\/\/mod-cluster.jboss.org\/\" target=\"_blank\" rel=\"nofollow noopener\">Mod Cluster Documentation<\/a><\/li>\n<\/ol>\n<p>Keep connected with\u00a0<strong>Tecmint<\/strong>\u00a0for handy and latest How To\u2019s. Stay Tuned up for the\u00a0<strong>part 02<\/strong>\u00a0(Linux Servers clustering with 2 Nodes for a failover scenario on RedHAT\/CentOS \u2013 Creating the cluster) soon.<\/p>\n<p>Hi all. Before we start the second part, let\u2019s review about what we have done in\u00a0<strong>Part 01<\/strong>. In Part 01 of this clustering series, we\u2019ve discussed about clustering technique and in which cases it can be used along with the advantages and disadvantages of clustering. And also we have covered the pre-requisites for this setup and what each package will do after we configured the kind of a setup.<\/p>\n<div id=\"attachment_14834\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Setup-Cluster-with-Multi-Nodes.jpeg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-14834\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Setup-Cluster-with-Multi-Nodes.jpeg\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Setup-Cluster-with-Multi-Nodes.jpeg 782w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Setup-Cluster-with-Multi-Nodes-620x294.jpeg 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Setup-Cluster-with-Multi-Nodes-720x340.jpeg 720w\" alt=\"Setup Cluster with Multi Nodes\" width=\"620\" height=\"294\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Setup Cluster with Multi Nodes \u2013 Part 2<\/p>\n<\/div>\n<p>You can review\u00a0<strong>Part 01<\/strong>\u00a0and\u00a0<strong>Part 03<\/strong>\u00a0from below links.<\/p>\n<ol>\n<li><a href=\"https:\/\/www.tecmint.com\/what-is-clustering-and-advantages-disadvantages-of-clustering-in-linux\/\" target=\"_blank\" rel=\"noopener\">What is Clustering and Advantages\/Disadvantages of Clustering<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/fencing-and-adding-a-failover-to-clustering-server\/\">Fencing and Adding a Failover to Cluster \u2013 Part 3<\/a><\/li>\n<\/ol>\n<p>As I said in my last article, that we prefer 3 servers for this setup; one server act as a cluster server and others as nodes.<\/p>\n<pre><strong>Cluster Server<\/strong>: <strong>172.16.1.250<\/strong>\r\n<strong>Hostname<\/strong>: <strong>clserver.test.net<\/strong>\r\n\r\n<strong>node01<\/strong>: <strong>172.16.1.222<\/strong>\r\n<strong>Hostname<\/strong>: <strong>nd01server.test.net<\/strong>\r\n\r\n<strong>node02<\/strong>: <strong>172.16.1.223<\/strong>\r\n<strong>Hostname<\/strong>: <strong>nd02server.test.net <\/strong>  \r\n<\/pre>\n<p>In today\u2019s\u00a0<strong>Part 2<\/strong>, we will see how to install and configure clustering on Linux. For this we need to install below packages in all three servers.<\/p>\n<ol>\n<li>Ricci (ricci-0.16.2-75.el6.x86_64.rpm)<\/li>\n<li>Luci (luci-0.26.0-63.el6.centos.x86_64.rpm)<\/li>\n<li>Mod_cluster (modcluster-0.16.2-29.el6.x86_64.rpm)<\/li>\n<li>CCS (ccs-0.16.2-75.el6_6.2.x86_64.rpm)<\/li>\n<li>CMAN(cman-3.0.12.1-68.el6.x86_64.rpm)<\/li>\n<li>Clusterlib (clusterlib-3.0.12.1-68.el6.x86_64.rpm)<\/li>\n<\/ol>\n<h3>Step 1: Installing Clustering in Linux<\/h3>\n<p>So let\u2019s start installing these packages in all\u00a0<strong>three servers<\/strong>. You can easily install all these packages using\u00a0<strong>yum<\/strong>package manager.<\/p>\n<p>I will start by installing \u201c<strong>ricci<\/strong>\u201d package on all these three servers.<\/p>\n<pre># yum install \u201cricci\u201d\r\n<\/pre>\n<div id=\"attachment_14813\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-Ricci-Package.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-14813\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-Ricci-Package-620x370.jpg\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-Ricci-Package-620x370.jpg 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-Ricci-Package-1024x611.jpg 1024w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-Ricci-Package.jpg 1262w\" alt=\"Install Ricci Package\" width=\"620\" height=\"370\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Install Ricci Package<\/p>\n<\/div>\n<p>After\u00a0<strong>ricci<\/strong>\u00a0installation is done, we can see it has installed\u00a0<strong>mod_cluster<\/strong>\u00a0and\u00a0<strong>cluster lib<\/strong>\u00a0as its dependencies.<\/p>\n<div id=\"attachment_14814\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Ricci-Installed-Summary.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-14814\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Ricci-Installed-Summary-620x344.png\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Ricci-Installed-Summary-620x344.png 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Ricci-Installed-Summary.png 720w\" alt=\"Ricci Installed Summary\" width=\"620\" height=\"344\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Ricci Installed Summary<\/p>\n<\/div>\n<p>Next I\u2019m installing\u00a0<strong>luci<\/strong>\u00a0using\u00a0<strong>yum install \u201cluci\u201d<\/strong>\u00a0command.<\/p>\n<pre># yum install \"luci\"\r\n<\/pre>\n<div id=\"attachment_14815\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-Luci-Package.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-14815\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-Luci-Package-620x372.jpg\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-Luci-Package-620x372.jpg 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-Luci-Package-1024x615.jpg 1024w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-Luci-Package.jpg 1259w\" alt=\"Install Luci Package\" width=\"620\" height=\"372\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Install Luci Package<\/p>\n<\/div>\n<p>After the installation of\u00a0<strong>luci<\/strong>, you can see it has installed the dependencies it needed.<\/p>\n<div id=\"attachment_14816\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Luci-Package-Summary.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-14816\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Luci-Package-Summary-620x173.jpg\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Luci-Package-Summary-620x173.jpg 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Luci-Package-Summary-1024x285.jpg 1024w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Luci-Package-Summary.jpg 1228w\" alt=\"Luci Package Installed Summary\" width=\"620\" height=\"173\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Luci Package Installed Summary<\/p>\n<\/div>\n<p>Now, let\u2019s install\u00a0<strong>ccs<\/strong>\u00a0package in the servers. For that I entered\u00a0<strong>yum install ccs.x86_64<\/strong>\u00a0which is shown in the list when I issued\u00a0<strong>yum list |grep \u201cccs\u201d<\/strong>\u00a0or else you can simply issue\u00a0<strong>yum install \u201cccs\u201d<\/strong>.<\/p>\n<pre># yum install \u201cccs\u201d\r\n<\/pre>\n<div id=\"attachment_14817\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-CSS-Package.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-14817\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-CSS-Package-620x162.jpg\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-CSS-Package-620x162.jpg 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-CSS-Package-1024x268.jpg 1024w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-CSS-Package.jpg 1263w\" alt=\"Install CSS Package\" width=\"620\" height=\"162\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Install CSS Package<\/p>\n<\/div>\n<p>Let\u2019s install\u00a0<strong>cman<\/strong>\u00a0as the last requirement for this particular setup. The command is\u00a0<strong>yum install \u201ccman\u201d<\/strong>\u00a0or\u00a0<strong>yum install cman.x86_64<\/strong>\u00a0as shown in the yum list as I mentioned earlier.<\/p>\n<pre># yum install \u201ccman\u201d\r\n<\/pre>\n<div id=\"attachment_14818\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-CMAN-Package.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-14818\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-CMAN-Package-620x369.jpg\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-CMAN-Package-620x369.jpg 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-CMAN-Package-1024x610.jpg 1024w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Install-CMAN-Package.jpg 1262w\" alt=\"Install CMAN Package\" width=\"620\" height=\"369\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Install CMAN Package<\/p>\n<\/div>\n<p>We need to confirm the installations are in place. Issue below command to see whether the packages we needed are installed properly in all three servers.<\/p>\n<pre># rpm -qa | egrep \"ricci|luci|modc|cluster|ccs|cman\"\r\n<\/pre>\n<div id=\"attachment_14819\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/All-Packages-Installed.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14819\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/All-Packages-Installed.jpg\" alt=\"All Packages Installed\" width=\"585\" height=\"234\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">All Packages Installed<\/p>\n<\/div>\n<p>Perfect all the packages are installed and all we need to do is configuring the setup.<\/p>\n<h3>Step 2: Configure Cluster in Linux<\/h3>\n<p><strong>1.<\/strong>\u00a0As the first step for setting up the cluster, you need to start the\u00a0<strong>ricci<\/strong>\u00a0service on all three servers.<\/p>\n<pre># service ricci start \r\nOR\r\n# \/etc\/init.d\/ricci start \r\n<\/pre>\n<div id=\"attachment_14820\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Start-Ricci-Service.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14820\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Start-Ricci-Service.jpg\" alt=\"Start Ricci Service on Cluster Server\" width=\"507\" height=\"231\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Start Ricci Service on Cluster Server<\/p>\n<\/div>\n<div id=\"attachment_14821\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Start-Ricci-On-Node-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14821\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Start-Ricci-On-Node-1.jpg\" alt=\"Start Ricci On Node 01\" width=\"508\" height=\"225\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Start Ricci On Node 01<\/p>\n<\/div>\n<div id=\"attachment_14822\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Start-Ricci-On-Node-2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14822\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Start-Ricci-On-Node-2.jpg\" alt=\"Start Ricci On Node 02\" width=\"510\" height=\"195\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Start Ricci On Node 02<\/p>\n<\/div>\n<p><strong>2.<\/strong>\u00a0Since\u00a0<strong>ricci<\/strong>\u00a0is started in all servers, now it\u2019s time to create the cluster. This is where\u00a0<strong>ccs<\/strong>\u00a0package comes to our help when configuring the cluster.<\/p>\n<p>If you don\u2019t want to use\u00a0<strong>ccs<\/strong>\u00a0commands then you will have to edit the\u00a0<code>\u201ccluster.conf\u201d<\/code>\u00a0file for adding the nodes and do other configs. I guess easiest way is to use following commands. Let\u2019s have a look.<\/p>\n<p>Since I haven\u2019t created the cluster yet, there\u2019s no\u00a0<strong>cluster.conf<\/strong>\u00a0file created in\u00a0<strong>\/etc\/cluster<\/strong>\u00a0location yet as shown below.<\/p>\n<pre># cd \/etc\/cluster\r\n# pwd\r\n# ls\r\n<\/pre>\n<div id=\"attachment_14823\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Cluster-Directory.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14823\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Cluster-Directory.jpg\" alt=\"Check Cluster Configuration File\" width=\"490\" height=\"195\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Check Cluster Configuration File<\/p>\n<\/div>\n<p>In my case, I do this in\u00a0<strong>172.16.1.250<\/strong>\u00a0which is dedicated for cluster management. Now onwards, everytime we try to use\u00a0<strong>ricci<\/strong>\u00a0server, it will ask for\u00a0<strong>ricci\u2019s<\/strong>\u00a0password. So you will have to set the password of\u00a0<strong>ricci<\/strong>\u00a0user in all servers.<\/p>\n<p>Enter passwords for\u00a0<strong>ricci<\/strong>\u00a0user.<\/p>\n<pre># passwd ricci\r\n<\/pre>\n<div id=\"attachment_14824\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Set-Ricci-Password.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14824\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Set-Ricci-Password.jpg\" alt=\"Set Ricci Password\" width=\"513\" height=\"199\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Set Ricci Password<\/p>\n<\/div>\n<p>Now enter the command as shown below.<\/p>\n<pre># ccs -h 172.16.1.250 --createcluster tecmint_cluster\r\n<\/pre>\n<p>You can see after entering above command,\u00a0<strong>cluster.conf<\/strong>\u00a0file is created in\u00a0<strong>\/etc\/cluster<\/strong>\u00a0directory.<\/p>\n<div id=\"attachment_14825\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Create-Cluster-Configuration.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14825\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Create-Cluster-Configuration.jpg\" alt=\"Create Cluster Configuration\" width=\"557\" height=\"204\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Create Cluster Configuration<\/p>\n<\/div>\n<p>This is how my default\u00a0<strong>cluster.conf<\/strong>\u00a0looks like before I do the configs.<\/p>\n<div id=\"attachment_14826\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Cluster-Configuration.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14826\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Cluster-Configuration.jpg\" alt=\"Cluster Configuration\" width=\"520\" height=\"271\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Cluster Configuration<\/p>\n<\/div>\n<p><strong>3.<\/strong>\u00a0Now let\u2019s add the two nodes to the system. In here also we use\u00a0<strong>ccs<\/strong>\u00a0commands to make the configurations. I\u2019m not going to manually edit the\u00a0<strong>cluster.conf<\/strong>\u00a0file but use the following syntax.<\/p>\n<pre># ccs -h 172.16.1.250 --addnode 172.16.1.222\r\n<\/pre>\n<div id=\"attachment_14827\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Add-Nodes-to-Cluster.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14827\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Add-Nodes-to-Cluster.jpg\" alt=\"Add Nodes to Cluster\" width=\"521\" height=\"115\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Add Nodes to Cluster<\/p>\n<\/div>\n<p>Add the other node too.<\/p>\n<pre># ccs -h 172.16.1.250 --addnode 172.16.1.223\r\n<\/pre>\n<div id=\"attachment_14828\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Add-Node-To-Cluster.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14828\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Add-Node-To-Cluster.jpg\" alt=\"Add Second Node to Cluster\" width=\"514\" height=\"101\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Add Second Node to Cluster<\/p>\n<\/div>\n<p>This is how\u00a0<strong>cluster.conf<\/strong>\u00a0file looks like after adding the node servers.<\/p>\n<div id=\"attachment_14829\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Cluster-Configuration-wth-Nodes.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14829\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Cluster-Configuration-wth-Nodes.jpg\" alt=\"Cluster Configuration with Nodes\" width=\"520\" height=\"280\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Cluster Configuration with Nodes<\/p>\n<\/div>\n<p>You also can enter below command to verify node details.<\/p>\n<pre># ccs \u2013h 172.16.1.250 --lsnodes\r\n<\/pre>\n<div id=\"attachment_14830\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Confirm-Cluster-Node-Details.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14830\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/07\/Confirm-Cluster-Node-Details.jpg\" alt=\"Confirm Cluster Node Details\" width=\"511\" height=\"114\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Confirm Cluster Node Details<\/p>\n<\/div>\n<p>Perfect. You have successfully created the cluster yourself and added two nodes. For further details about\u00a0<strong>ccs<\/strong>command options, enter\u00a0<strong>ccs \u2013help<\/strong>\u00a0command and study the details. Since now you know how to create the cluster and add nodes to it, I will post\u00a0<strong>Part 03<\/strong>\u00a0soon for you.<\/p>\n<p>In the previous two guides, we\u2019ve discussed how to install cluster, creating a cluster and adding nodes to the cluster, also we\u2019ve studied how\u00a0<strong>cluster.conf<\/strong>\u00a0appears to be after the necessary configurations are done.<\/p>\n<p>Today, in this third part of clustering series, we are going to discuss about what is fencing, failover and how to configure them in our setup.<\/p>\n<div id=\"attachment_15031\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Fencing-and-Add-Failover-to-Cluster.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-15031\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Fencing-and-Add-Failover-to-Cluster-620x294.jpg\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Fencing-and-Add-Failover-to-Cluster-620x294.jpg 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Fencing-and-Add-Failover-to-Cluster-720x340.jpg 720w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Fencing-and-Add-Failover-to-Cluster.jpg 782w\" alt=\"Fencing and Add Failover to Cluster\" width=\"620\" height=\"294\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Fencing and Add Failover to Cluster \u2013 Part 3<\/p>\n<\/div>\n<p>First of all let\u2019s see what is meant by\u00a0<strong>Fencing<\/strong>\u00a0and\u00a0<strong>Failover<\/strong>.<\/p>\n<h4>What is Fencing?<\/h4>\n<p>If we think of a setup with more than one nodes, it is possible that one or more nodes can be failed at some point of time. So in this case fencing is isolating the malfunctioning server from the cluster in order to protect and secure the synced resources. Therefore we can add a fence to protect the resources shared within the cluster.<\/p>\n<h4>What is Failover?<\/h4>\n<p>Imagine a scenario, where a server has important data for an organization which the stakeholders need the organization to keep the server up and running without any down time experienced. In this case we can duplicate the data to another server (now there are two servers with identical data and specs) which we can use as the fail-over.<\/p>\n<p>By any chance, one of the servers goes down, the other server which we have configured as the fail-over will take over the load and provides the services which were given by the first server. In this method, users will not be experienced the down time period which was caused to the primary server.<\/p>\n<p>You can go through the\u00a0<strong>Part 01<\/strong>\u00a0and\u00a0<strong>Part 02<\/strong>\u00a0of this clustering series here:<\/p>\n<ol>\n<li><a href=\"https:\/\/www.tecmint.com\/what-is-clustering-and-advantages-disadvantages-of-clustering-in-linux\/\" target=\"_blank\" rel=\"noopener\">What is Clustering and Advantages\/Disadvantages \u2013 Part 1<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/cman-multi-node-cluster-setup-in-linux\/\" target=\"_blank\" rel=\"noopener\">Setup Cluster with Two Nodes in Linux \u2013 Part 2<\/a><\/li>\n<\/ol>\n<p>As we\u2019ve already discussed about our testing environment setup in last two articles, that we\u2019re using three servers for this setup, the first server act as a Cluster server and other two as nodes.<\/p>\n<pre><strong>Cluster Server<\/strong>: <strong>172.16.1.250<\/strong>\r\n<strong>Hostname<\/strong>: <strong>clserver.test.net<\/strong>\r\n\r\n<strong>node01<\/strong>: <strong>172.16.1.222<\/strong>\r\n<strong>Hostname<\/strong>: <strong>nd01server.test.net<\/strong>\r\n\r\n<strong>node02<\/strong>: <strong>172.16.1.223<\/strong>\r\n<strong>Hostname<\/strong>: <strong>nd02server.test.net <\/strong>  \r\n<\/pre>\n<h3>Step 1: How to Add Fencing to Cluster Server<\/h3>\n<p><strong>1.<\/strong>\u00a0First we have to enable fencing on the cluster server, for this I will use below two commands.<\/p>\n<pre># ccs -h 172.16.1.250 --setfencedaemon post_fail_delay=0\r\n# ccs -h 172.16.1.250 --setfencedaemon post_join_delay=10\r\n<\/pre>\n<div id=\"attachment_15023\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Enable-Fencing.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-15023\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Enable-Fencing.jpg\" alt=\"Enable Fencing on Cluster\" width=\"578\" height=\"104\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Enable Fencing on Cluster<\/p>\n<\/div>\n<p>As you can see we use\u00a0<strong>ccs<\/strong>\u00a0command to add the configurations to cluster. Following are definitions of the options I have used in the command.<\/p>\n<ol>\n<li><strong>-h<\/strong>: Cluster host IP address.<\/li>\n<li><strong>\u2013setfencedaemon<\/strong>: Applies the changes to the fencing daemon.<\/li>\n<li><strong>post_fail_delay<\/strong>: Time in seconds which the daemon waits before fencing a victim server when a node has been failed.<\/li>\n<li><strong>post_join_delay<\/strong>: Time in seconds which the daemon waits before fencing victim server when a node has joined the cluster.<\/li>\n<\/ol>\n<p><strong>2.<\/strong>\u00a0Now let\u2019s add a fence device for our cluster, execute below command to add a fence device.<\/p>\n<pre># ccs -h 172.16.1.250 --addfencedev tecmintfence agent=fence_virt\r\n<\/pre>\n<p>This is how I executed the command and how the\u00a0<code>cluster.conf<\/code>\u00a0file looks like after adding a fence device.<\/p>\n<div id=\"attachment_15024\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Add-Fencing-Device.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-15024\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Add-Fencing-Device.jpg\" alt=\"Add Fencing Device in Cluster\" width=\"602\" height=\"370\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Add Fencing Device in Cluster<\/p>\n<\/div>\n<p>You can execute below command to see what kind of\u00a0<strong>fence<\/strong>\u00a0options you can use to create a fence device. I used\u00a0<strong>fence_virt<\/strong>\u00a0since I use VMs for my setup.<\/p>\n<pre># ccs -h 172.16.1.250 --lsfenceopts\r\n<\/pre>\n<div id=\"attachment_15025\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Fence-Options.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-15025\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Fence-Options-298x450.jpg\" sizes=\"auto, (max-width: 298px) 100vw, 298px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Fence-Options-298x450.jpg 298w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Fence-Options.jpg 478w\" alt=\"Fence Options\" width=\"298\" height=\"450\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Fence Options<\/p>\n<\/div>\n<h3>Step 2: Add Two Nodes to Fence Device<\/h3>\n<p><strong>3.<\/strong>\u00a0Now I\u2019m going to add a method to the created fence device and add hosts in to it.<\/p>\n<pre># ccs -h 172.16.1.250 --addmethod Method01 172.16.1.222\r\n# ccs -h 172.16.1.250 --addmethod Method01 172.16.1.223\r\n<\/pre>\n<p>You have to add the methods you have created while ago for the both nodes you have in your setup. Following is how I added methods and my\u00a0<strong>cluster.conf<\/strong>.<\/p>\n<div id=\"attachment_15026\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Add-Nodes-to-Fence-Device.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-15026\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Add-Nodes-to-Fence-Device-437x450.jpg\" sizes=\"auto, (max-width: 437px) 100vw, 437px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Add-Nodes-to-Fence-Device-437x450.jpg 437w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Add-Nodes-to-Fence-Device.jpg 560w\" alt=\"Add Nodes to Fence Device\" width=\"437\" height=\"450\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Add Nodes to Fence Device<\/p>\n<\/div>\n<p><strong>4.<\/strong>\u00a0As the next step, you will have to add the fence methods you created for the both nodes, to the fence device we created namely \u201c<strong>tecmintfence<\/strong>\u201d.<\/p>\n<pre># ccs -h 172.16.1.250 --addfenceinst tecmintfence 172.16.1.222 Method01\r\n# ccs -h 172.16.1.250 --addfenceinst tecmintfence 172.16.1.223 Method01\r\n<\/pre>\n<p>I have successfully associated my methods with the fence device and this is how my\u00a0<strong>cluster.conf<\/strong>\u00a0looks like now.<\/p>\n<div id=\"attachment_15027\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Add-Fence-to-Nodes.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-15027\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Add-Fence-to-Nodes-481x450.jpg\" sizes=\"auto, (max-width: 481px) 100vw, 481px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Add-Fence-to-Nodes-481x450.jpg 481w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Add-Fence-to-Nodes.jpg 635w\" alt=\"Add Fence to Nodes\" width=\"481\" height=\"450\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Add Fence to Nodes<\/p>\n<\/div>\n<p>Now you have successfully configured fence device, methods and added your nodes to it. As the last step of\u00a0<strong>part 03<\/strong>, I will now show you how to add a failover to the setup.<\/p>\n<h3>Step 3: Add Failover to Cluster Server<\/h3>\n<p><strong>5.<\/strong>\u00a0I use below syntax of commands to create my fail-over to the cluster setup.<\/p>\n<pre># ccs -h 172.16.1.250 --addfailoverdomain tecmintfod ordered\r\n<\/pre>\n<div id=\"attachment_15028\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Add-Failover-to-Cluster.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-15028\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Add-Failover-to-Cluster-591x450.jpg\" sizes=\"auto, (max-width: 591px) 100vw, 591px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Add-Failover-to-Cluster-591x450.jpg 591w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Add-Failover-to-Cluster.jpg 732w\" alt=\"Add Failover to Cluster\" width=\"591\" height=\"450\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Add Failover to Cluster<\/p>\n<\/div>\n<p><strong>6.<\/strong>\u00a0As you have created the fail-over domain, now you can add two nodes to it.<\/p>\n<pre># ccs -h 172.16.1.250 --addfailoverdomainnode tecmintfod 172.16.1.222 1\r\n# ccs -h 172.16.1.250 --addfailoverdomainnode tecmintfod 172.16.1.223 2\r\n<\/pre>\n<div id=\"attachment_15029\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Add-Nodes-to-Failover.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-15029\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Add-Nodes-to-Failover-540x450.jpg\" sizes=\"auto, (max-width: 540px) 100vw, 540px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Add-Nodes-to-Failover-540x450.jpg 540w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/08\/Add-Nodes-to-Failover.jpg 749w\" alt=\"Add Nodes to Cluster Failover\" width=\"540\" height=\"450\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Add Nodes to Cluster Failover<\/p>\n<\/div>\n<p>As it is shown above, you can see\u00a0<strong>cluster.conf<\/strong>\u00a0bears all the configurations I have added for the fail-over domain.<\/p>\n<p>Hope you have enjoyed the\u00a0<strong>Part 3<\/strong>\u00a0of this series. Last part of the Clustering guide series will be posted soon which will teach you to add resources to the cluster, sync them and start-up the cluster.<\/p>\n<p>Hello folks. First of all, my apologies for the delay of the last part of this cluster series. Let\u2019s get on to work without getting any more delayed.<\/p>\n<p>As we many of you have completed all three previous parts, I will brief you what we have completed so far. Now we already have enough knowledge to install and configure cluster packages for two nodes and enable fencing and failover in a clustered environment.<\/p>\n<div id=\"attachment_16275\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/10\/Sync-Cluster-Configuration-and-Verify-FailOver.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-16275\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/10\/Sync-Cluster-Configuration-and-Verify-FailOver.png\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/10\/Sync-Cluster-Configuration-and-Verify-FailOver.png 718w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/10\/Sync-Cluster-Configuration-and-Verify-FailOver-620x295.png 620w\" alt=\"Sync Cluster Configuration and Verify FailOver\" width=\"620\" height=\"295\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Sync Cluster Configuration and Verify FailOver \u2013 Part 4<\/p>\n<\/div>\n<p>You can refer my previous parts if you don\u2019t remember since it took a little longer to post the last part.<\/p>\n<p><i class=\"fa fa-check\"><\/i>\u00a0<a href=\"https:\/\/www.tecmint.com\/what-is-clustering-and-advantages-disadvantages-of-clustering-in-linux\/\" target=\"_blank\" rel=\"noopener\">Introduction to Linux Clustering and Advantages\/Disadvanges of Clustering \u2013 Part 1<\/a><\/p>\n<p><i class=\"fa fa-check\"><\/i>\u00a0<a href=\"https:\/\/www.tecmint.com\/cman-multi-node-cluster-setup-in-linux\/\" target=\"_blank\" rel=\"noopener\">How to Install and Configure Cluster with Two Nodes in Linux \u2013 Part 2<\/a><\/p>\n<p><i class=\"fa fa-check\"><\/i>\u00a0<a href=\"https:\/\/www.tecmint.com\/fencing-and-adding-a-failover-to-clustering-server\/\" target=\"_blank\" rel=\"noopener\">Fencing and Adding a Failover to Clustering \u2013 Part 3<\/a><\/p>\n<p>We will start by adding resources to the cluster. In this case we can add a file system or a web service as your need. Now I have\u00a0<strong>\/dev\/sda3<\/strong>\u00a0partition mounted to\u00a0<strong>\/x01<\/strong>\u00a0which I wish to add as a file system resource.<\/p>\n<p><strong>1.<\/strong>\u00a0I use below command to add a file system as a resource:<\/p>\n<pre># ccs -h 172.16.1.250 --addresource fs name=my_fs device=\/dev\/mapper\/tecminttest_lv_vol01 mountpoint=\/x01 fstype=ext3\r\n<\/pre>\n<div id=\"attachment_16265\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/10\/Add-Filesystem-to-Cluster.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-16265\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/10\/Add-Filesystem-to-Cluster-620x90.jpg\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/10\/Add-Filesystem-to-Cluster-620x90.jpg 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/10\/Add-Filesystem-to-Cluster.jpg 997w\" alt=\"Add Filesystem to Cluster\" width=\"620\" height=\"90\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Add Filesystem to Cluster<\/p>\n<\/div>\n<p>Additionally, if you want to add a service also, you can by using below methodology. Issue the following command.<\/p>\n<pre># ccs -h 172.16.1.250 --addservice my_web domain=testdomain recovery=relocate autostart=1\r\n<\/pre>\n<p>You can verify it by viewing the\u00a0<code>cluster.conf<\/code>\u00a0file as we did in previous lessons.<\/p>\n<p><strong>2.<\/strong>\u00a0Now enter following entry in\u00a0<strong>cluster.conf<\/strong>\u00a0file to add a reference tag to the service.<\/p>\n<pre>&lt;fs ref=\"my_fs\"\/&gt;\r\n<\/pre>\n<div id=\"attachment_16266\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/10\/Add-Service-to-Cluster.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-16266\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/10\/Add-Service-to-Cluster-602x450.jpg\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/10\/Add-Service-to-Cluster-602x450.jpg 602w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/10\/Add-Service-to-Cluster.jpg 830w\" alt=\"Add Service to Cluster\" width=\"602\" height=\"450\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Add Service to Cluster<\/p>\n<\/div>\n<p><strong>3.<\/strong>\u00a0All set. No we will see how we can sync the configurations we made to cluster among the 2 nodes we have. Following command will do the needful.<\/p>\n<pre># ccs -h 172.16.1.250 --sync --activate\r\n<\/pre>\n<div id=\"attachment_16267\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/10\/Sync-Cluster-Configuration.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-16267\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/10\/Sync-Cluster-Configuration.jpg\" alt=\"Sync Cluster Configuration\" width=\"508\" height=\"201\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Sync Cluster Configuration<\/p>\n<\/div>\n<p><strong>Note<\/strong>: Enter passwords we set for\u00a0<strong>ricci<\/strong>\u00a0in the early stages when we were installing packages.<\/p>\n<p>You can verify your configurations by using below command.<\/p>\n<pre># ccs -h 172.16.1.250 --checkconf\r\n<\/pre>\n<div id=\"attachment_16268\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/10\/Verify-Cofiguration.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-16268\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/10\/Verify-Cofiguration.jpg\" alt=\"Verify Cluster Configuration\" width=\"511\" height=\"166\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Verify Cluster Configuration<\/p>\n<\/div>\n<p><strong>4.<\/strong>\u00a0Now it\u2019s time to start the things up. You can use one of below commands as you prefer.<\/p>\n<p>To start only one node use the command with relevant IP.<\/p>\n<pre># ccs -h 172.16.1.222 start\r\n<\/pre>\n<p>Or if you want to start all nodes use\u00a0<code>--startall<\/code>\u00a0option as follows.<\/p>\n<pre># ccs -h 172.16.1.250 \u2013startall\r\n<\/pre>\n<p>You can use stop or\u00a0<code>--stopall<\/code>\u00a0if you needed to stop the cluster.<\/p>\n<p>In a scenario like if you wanted to start the cluster without enabling the resources (resources will automatically be enabled when the cluster is started), like a situation where you have intentionally disabled the resources in a particular node in order to disable fencing loops, you don\u2019t want to enable those resources when the cluster is starting.<\/p>\n<p>For that purpose you can use below command which starts the cluster but does not enable the resources.<\/p>\n<pre># ccs -h 172.16.1.250 --startall --noenable \r\n<\/pre>\n<p><strong>5.<\/strong>\u00a0After the cluster has been started up, you can view the stats by issuing\u00a0<strong>clustat<\/strong>\u00a0command.<\/p>\n<pre># clustat\r\n<\/pre>\n<div id=\"attachment_16269\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/10\/Check-Cluster-Status.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-16269\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/10\/Check-Cluster-Status-620x283.jpg\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/10\/Check-Cluster-Status-620x283.jpg 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/10\/Check-Cluster-Status.jpg 712w\" alt=\"Check Cluster Status\" width=\"620\" height=\"283\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Check Cluster Status<\/p>\n<\/div>\n<p>Above output says there are two nodes in the cluster and both are up and running at the moment.<\/p>\n<p><strong>6.<\/strong>\u00a0You can remember we have added a failover mechanism in our previous lessons. Want to check it works? This is how you do it. Force\u00a0<strong>shutdown<\/strong>\u00a0one node and look for cluster stats using\u00a0<strong>clustat<\/strong>\u00a0command for the results of failover.<\/p>\n<p>I have shut down my\u00a0<strong>node02server(172.16.1.223)<\/strong>\u00a0using\u00a0<strong>shutdown -h now<\/strong>\u00a0command. Then executed\u00a0<strong>clustat<\/strong>command from my\u00a0<strong>cluster_server(172.16.1.250)<\/strong>.<\/p>\n<div id=\"attachment_16270\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/10\/Check-Cluster-FailOver.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-16270\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/10\/Check-Cluster-FailOver-620x283.jpg\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/10\/Check-Cluster-FailOver-620x283.jpg 620w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/10\/Check-Cluster-FailOver.jpg 712w\" alt=\"Check Cluster FailOver\" width=\"620\" height=\"283\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Check Cluster FailOver<\/p>\n<\/div>\n<p>Above output clarifies you that\u00a0<strong>node 1<\/strong>\u00a0is online while\u00a0<strong>node 2 has gone offline<\/strong>\u00a0as we shut it down. Yet service and the file system we shared are still online as you can see if you check it on\u00a0<strong>node01<\/strong>\u00a0which is online.<\/p>\n<pre># df -h \/x01\r\n<\/pre>\n<div id=\"attachment_16271\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/10\/Verify-Cluster-Node.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-16271\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2015\/10\/Verify-Cluster-Node.jpg\" alt=\"Verify Cluster Node\" width=\"591\" height=\"301\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Verify Cluster Node<\/p>\n<\/div>\n<p>Refer the\u00a0<code>cluster.conf<\/code>\u00a0file with whole config set relevant to our setup used for\u00a0<strong>tecmint<\/strong>.<\/p>\n<pre>&lt;?xml version=\"1.0\"?&gt;\r\n&lt;cluster config_version=\"15\" name=\"tecmint_cluster\"&gt;\r\n        &lt;fence_daemon post_join_delay=\"10\"\/&gt;\r\n        &lt;clusternodes&gt;\r\n                &lt;clusternode name=\"172.16.1.222\" nodeid=\"1\"&gt;\r\n                        &lt;fence&gt;\r\n                                &lt;method name=\"Method01\"&gt;\r\n                                        &lt;device name=\"tecmintfence\"\/&gt;\r\n                                &lt;\/method&gt;\r\n                        &lt;\/fence&gt;\r\n                &lt;\/clusternode&gt;\r\n                &lt;clusternode name=\"172.16.1.223\" nodeid=\"2\"&gt;\r\n                        &lt;fence&gt;\r\n                                &lt;method name=\"Method01\"&gt;\r\n                                        &lt;device name=\"tecmintfence\"\/&gt;\r\n                                &lt;\/method&gt;\r\n                        &lt;\/fence&gt;\r\n                &lt;\/clusternode&gt;\r\n        &lt;\/clusternodes&gt;\r\n        &lt;cman\/&gt;\r\n        &lt;fencedevices&gt;\r\n                &lt;fencedevice agent=\"fence_virt\" name=\"tecmintfence\"\/&gt;\r\n        &lt;\/fencedevices&gt;\r\n        &lt;rm&gt;\r\n                &lt;failoverdomains&gt;\r\n                        &lt;failoverdomain name=\"tecmintfod\" nofailback=\"0\" ordered=\"1\" restricted=\"0\"&gt;\r\n                                &lt;failoverdomainnode name=\"172.16.1.222\" priority=\"1\"\/&gt;\r\n                                &lt;failoverdomainnode name=\"172.16.1.223\" priority=\"2\"\/&gt;\r\n                        &lt;\/failoverdomain&gt;\r\n                &lt;\/failoverdomains&gt;\r\n                &lt;resources&gt;\r\n                        &lt;fs device=\"\/dev\/mapper\/tecminttest_lv_vol01\" fstype=\"ext3\" mountpoint=\"\/x01\" name=\"my_fs\"\/&gt;\r\n                &lt;\/resources&gt;\r\n                &lt;service autostart=\"1\" domain=\"testdomain\" name=\"my_web\" recovery=\"relocate\"\/&gt;\r\n                &lt;fs ref=\"my_fs\"\/&gt;\r\n       &lt;\/rm&gt;\r\n&lt;\/cluster&gt;\r\n<\/pre>\n<p>Hope you\u2019ll enjoyed the whole series of clustering lessons.<\/p>\n<h1 class=\"post-title\"><strong>How to Configure and Maintain High Availability\/Clustering in Linux (adding nginx):<\/strong><\/h1>\n<p><strong>High Availability<\/strong>\u00a0(<strong>HA<\/strong>) simply refers to a quality of a system to operate continuously without failure for a long period of time. HA solutions can be implemented using hardware and\/or software, and one of the common solutions to implementing HA is clustering.<\/p>\n<p>In computing, a cluster is made up of two or more computers (commonly known as\u00a0<strong>nodes<\/strong>\u00a0or\u00a0<strong>members<\/strong>) that work together to perform a task. In such a setup, only one node provides the service with the secondary node(s) taking over if it fails.<\/p>\n<p>Clusters fall into four major types:<\/p>\n<ul>\n<li><strong>Storage<\/strong>: provide a consistent file system image across servers in a cluster, allowing the servers to simultaneously read and write to a single shared file system.<\/li>\n<li><strong>High Availability<\/strong>: eliminate single points of failure and by failing over services from one cluster node to another in case a node goes becomes inoperative.<\/li>\n<li><strong>Load Balancing<\/strong>: dispatch network service requests to multiple cluster nodes to balance the request load among the cluster nodes.<\/li>\n<li><strong>High Performance<\/strong>: carry out parallel or concurrent processing, thus helping to improve performance of applications.<\/li>\n<\/ul>\n<p>Another widely used solution to providing\u00a0<strong>HA<\/strong>\u00a0is replication (specifically data replications). Replication is the process by which one or more (secondary) databases can be kept in sync with a single primary (or master) database.<\/p>\n<p>To setup a cluster, we need at least two servers. For the purpose of this guide, we will use two Linux servers:<\/p>\n<ul>\n<li>Node1: 192.168.10.10<\/li>\n<li>Node2: 192.168.10.11<\/li>\n<\/ul>\n<p>In this article, we will demonstrate the basics of how to deploy, configure and maintain high availability\/clustering in Ubuntu 16.04\/18.04 and CentOS 7. We will demonstrate how to add Nginx HTTP service to the cluster.<\/p>\n<h3>Configuring Local DNS Settings on Each Server<\/h3>\n<p>In order for the two servers to communicate to each other, we need to configure the appropriate local DNS settings in the\u00a0<strong>\/etc\/hosts<\/strong>\u00a0file on both servers.<\/p>\n<p>Open and edit the file using your\u00a0<a href=\"https:\/\/www.tecmint.com\/linux-command-line-editors\/\" target=\"_blank\" rel=\"noopener\">favorite command line editor<\/a>.<\/p>\n<pre>$ sudo vim \/etc\/hosts  \r\n<\/pre>\n<p>Add the following entries with actual IP addresses of your servers.<\/p>\n<pre>192.168.10.10\tnode1.example.com\r\n192.168.10.11 \tnode2.example.com\r\n<\/pre>\n<p>Save the changes and close the file.<\/p>\n<h3>Installing Nginx Web Server<\/h3>\n<p>Now install Nginx web server using the following commands.<\/p>\n<pre>$ sudo apt install nginx  [On Ubuntu]\r\n$ sudo yum install epel-release &amp;&amp; sudo yum install nginx [On CentOS 7]\r\n<\/pre>\n<p>Once the installation is complete, start the Nginx service for now and enable it to auto-start at boot time, then check if it\u2019s up and running using the systemctl command.<br \/>\nOn Ubuntu, the service should be started automatically immediately after package pre-configuration is complete, you can simply enable it.<\/p>\n<pre>$ sudo systemctl enable nginx\r\n$ sudo systemctl start nginx\r\n$ sudo systemctl status nginx\r\n<\/pre>\n<p>After starting the Nginx service, we need to create custom webpages for identifying and testing operations on both servers. We will modify the contents of the default Nginx index page as shown.<\/p>\n<pre>$ echo \"This is the default page for node1.example.com\" | sudo tee \/usr\/share\/nginx\/html\/index.html \t#VPS1\r\n$ echo \"This is the default page for node2.example.com\" | sudo tee \/usr\/share\/nginx\/html\/index.html \t#VPS2\r\n<\/pre>\n<h3>Installing and Configuring Corosync and Pacemaker<\/h3>\n<p>Next, we have to install\u00a0<strong>Pacemaker<\/strong>,\u00a0<strong>Corosync<\/strong>, and\u00a0<strong>Pcs<\/strong>\u00a0on each node as follows.<\/p>\n<pre>$ sudo apt install corosync pacemaker pcs\t#Ubuntu \r\n$ sudo yum install corosync pacemaker pcs\t#CentOS \r\n<\/pre>\n<p>Once the installation is complete, make sure that\u00a0<strong>pcs<\/strong>\u00a0daemon is running on both servers.<\/p>\n<pre>$ sudo systemctl enable pcsd\r\n$ sudo systemctl start pcsd\r\n$ sudo systemctl status pcsd\r\n<\/pre>\n<h4>Creating the Cluster<\/h4>\n<p>During the installation, a system user called\u00a0<strong>\u201chacluster\u201d<\/strong>\u00a0is created. So we need to set up the authentication needed for\u00a0<strong>pcs<\/strong>. Let\u2019s start by creating a new password for the\u00a0<strong>\u201chacluster\u201d<\/strong>\u00a0user, we need to use the same password on all servers:<\/p>\n<pre>$ sudo passwd hacluster\r\n<\/pre>\n<div id=\"attachment_31409\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/Create-Cluster-User-Password.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31409\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/Create-Cluster-User-Password.png\" alt=\"Create Cluster User Password\" width=\"662\" height=\"116\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Create Cluster User Password<\/p>\n<\/div>\n<p>Next, on one of the servers (Node1), run the following command to set up the authentication needed for\u00a0<strong>pcs<\/strong>.<\/p>\n<pre>$ sudo pcs cluster auth node1.example.com node2.example.com -u hacluster -p password_here --force\r\n<\/pre>\n<div id=\"attachment_31410\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/setup-needed-authenticate-for-pcs.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31410\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/setup-needed-authenticate-for-pcs.png\" sizes=\"auto, (max-width: 782px) 100vw, 782px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/setup-needed-authenticate-for-pcs.png 782w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/setup-needed-authenticate-for-pcs-768x95.png 768w\" alt=\"Setup Authentication for PCS\" width=\"782\" height=\"97\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Setup Authentication for PCS<\/p>\n<\/div>\n<p>Now create a cluster and populate it with some nodes (the cluster name cannot exceed 15 characters, in this example, we have used\u00a0<strong>examplecluster<\/strong>) on Node1 server.<\/p>\n<pre>$ sudo pcs cluster setup --name examplecluster node1.example.com node2.example.com \r\n<\/pre>\n<div id=\"attachment_31411\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/create-cluster.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31411\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/create-cluster.png\" sizes=\"auto, (max-width: 822px) 100vw, 822px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/create-cluster.png 822w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/create-cluster-768x392.png 768w\" alt=\"Create Cluster on Node1\" width=\"822\" height=\"420\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Create Cluster on Node1<\/p>\n<\/div>\n<p>Now enable the cluster on boot and start the service.<\/p>\n<pre>$ sudo pcs cluster enable --all\r\n$ sudo pcs cluster start --all\r\n<\/pre>\n<div id=\"attachment_31412\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/enable-and-start-cluster.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31412\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/enable-and-start-cluster.png\" alt=\"Enable and Start the Cluster\" width=\"642\" height=\"173\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Enable and Start the Cluster<\/p>\n<\/div>\n<p>Now check if the cluster service is up and running using the following command.<\/p>\n<pre>$ sudo pcs status\r\nOR\r\n$ sudo crm_mon -1\r\n<\/pre>\n<div id=\"attachment_31413\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/check-cluster-status.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31413\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/check-cluster-status.png\" sizes=\"auto, (max-width: 942px) 100vw, 942px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/check-cluster-status.png 942w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/check-cluster-status-768x389.png 768w\" alt=\"Check Cluster Status\" width=\"942\" height=\"477\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Check Cluster Status<\/p>\n<\/div>\n<p>From the output of the above command, you can see that there is a warning about no\u00a0<strong>STONITH<\/strong>\u00a0devices yet the\u00a0<strong>STONITH<\/strong>\u00a0is still enabled in the cluster. In addition, no cluster resources\/services have been configured.<\/p>\n<h4>Configuring Cluster Options<\/h4>\n<p>The first option is to disable\u00a0<strong>STONITH<\/strong>\u00a0(or\u00a0<strong>Shoot The Other Node In The Head<\/strong>), the fencing implementation on\u00a0<strong>Pacemaker<\/strong>.<\/p>\n<p>This component helps to protect your data from being corrupted by concurrent access. For the purpose of this guide, we will disable it since we have not configured any devices.<\/p>\n<p>To turn off\u00a0<strong>STONITH<\/strong>, run the following command:<\/p>\n<pre>$ sudo pcs property set stonith-enabled=false\r\n<\/pre>\n<p>Next, also ignore the\u00a0<strong>Quorum<\/strong>\u00a0policy by running the following command:<\/p>\n<pre>$ sudo pcs property set no-quorum-policy=ignore\r\n<\/pre>\n<p>After setting the above options, run the following command to see the property list and ensure that the above options,\u00a0<strong>stonith<\/strong>\u00a0and the\u00a0<strong>quorum policy<\/strong>\u00a0are disabled.<\/p>\n<pre>$ sudo pcs property list\r\n<\/pre>\n<div id=\"attachment_31414\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/view-cluster-properties.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31414\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/view-cluster-properties.png\" alt=\"View Cluster Properties\" width=\"572\" height=\"173\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">View Cluster Properties<\/p>\n<\/div>\n<h4>Adding a Resource\/Cluster Service<\/h4>\n<p>In this section, we will look at how to add a cluster resource. We will configure a floating IP which is the IP address that can be instantly moved from one server to another within the same network or data center. In short, a floating IP is a technical common term, used for IPs which are not bound strictly to one single interface.<\/p>\n<p>In this case, it will be used to support failover in a high-availability cluster. Keep in mind that floating IPs aren\u2019t just for failover situations, they have a few other use cases. We need to configure the cluster in such a way that only the active member of the cluster \u201cowns\u201d or responds to the floating IP at any given time.<\/p>\n<p>We will add two cluster resources: the floating IP address resource called \u201c<strong>floating_ip<\/strong>\u201d and a resource for the Nginx web server called \u201c<strong>http_server<\/strong>\u201d.<\/p>\n<p>First start by adding the floating_ip as follows. In this example, our floating IP address is\u00a0<strong>192.168.10.20<\/strong>.<\/p>\n<pre>$ sudo pcs resource create floating_ip ocf:heartbeat:IPaddr2 ip=192.168.10.20 cidr_netmask=24 op monitor interval=60s\r\n<\/pre>\n<p>where:<\/p>\n<ul>\n<li><strong>floating_ip<\/strong>: is the name of the service.<\/li>\n<li><strong>\u201cocf:heartbeat:IPaddr2\u201d<\/strong>: tells Pacemaker which script to use, IPaddr2 in this case, which namespace it is in (pacemaker) and what standard it conforms to ocf.<\/li>\n<li>\u201c<strong>op monitor interval=60s<\/strong>\u201d: instructs Pacemaker to check the health of this service every one minutes by calling the agent\u2019s monitor action.<\/li>\n<\/ul>\n<p>Then add the second resource, named\u00a0<strong>http_server<\/strong>. Here, resource agent of the service is\u00a0<strong>ocf:heartbeat:nginx<\/strong>.<\/p>\n<pre>$ sudo pcs resource create http_server ocf:heartbeat:nginx configfile=\"\/etc\/nginx\/nginx.conf\" op monitor timeout=\"20s\" interval=\"60s\"\r\n<\/pre>\n<p>Once you have added the cluster services, issue the following command to check the status of resources.<\/p>\n<pre>$ sudo pcs status resources\r\n<\/pre>\n<div id=\"attachment_31415\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/check-cluster-resources.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31415\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/check-cluster-resources.png\" alt=\"Check Cluster Resources\" width=\"702\" height=\"78\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Check Cluster Resources<\/p>\n<\/div>\n<p>Looking at the output of the command, the two added resources:\u00a0<strong>\u201cfloating_ip\u201d<\/strong>\u00a0and\u00a0<strong>\u201chttp_server\u201d<\/strong>\u00a0have been listed. The floating_ip service is off because the primary node is in operation.<\/p>\n<p>If you have firewall enabled on your system, you need to allow all traffic to\u00a0<strong>Nginx<\/strong>\u00a0and all high availability services through the firewall for proper communication between nodes:<\/p>\n<pre>-------------- CentOS 7 -------------- \r\n$ sudo firewall-cmd --permanent --add-service=http\r\n$ sudo firewall-cmd --permanent --add-service=high-availability\t\t\r\n$ sudo firewall-cmd --reload\r\n\r\n-------------- Ubuntu -------------- \r\n$ sudo ufw allow http\t\r\n$ sudo ufw allow high-availability\t\t\t\t\t\t\r\n$ sudo ufw reload \r\n<\/pre>\n<h4>Testing High Availability\/Clustering<\/h4>\n<p>The final and important step is to test that our high availability setup works. Open a web browser and navigate to the address\u00a0<strong>192.168.10.20<\/strong>\u00a0you should see the default Nginx page from the\u00a0<strong>node2.example.com<\/strong>\u00a0as shown in the screenshot.<\/p>\n<div id=\"attachment_31416\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/test-cluster-before-failure.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31416\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/test-cluster-before-failure.png\" alt=\"Test Cluster Before Failure\" width=\"761\" height=\"252\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Test Cluster Before Failure<\/p>\n<\/div>\n<p>To simulate a failure, run the following command to stop the cluster on the\u00a0<strong>node2.example.com<\/strong>.<\/p>\n<pre>$ sudo pcs cluster stop http_server\r\n<\/pre>\n<p>Then reload the page at\u00a0<strong>192.168.10.20<\/strong>, you should now access the default Nginx web page from the\u00a0<strong>node1.example.com<\/strong>.<\/p>\n<div id=\"attachment_31417\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/test-cluster-after-failure.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-31417\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/12\/test-cluster-after-failure.png\" alt=\"Test Cluster After Failure\" width=\"763\" height=\"235\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p class=\"wp-caption-text\">Test Cluster After Failure<\/p>\n<\/div>\n<p>Alternatively, you can simulate an error by telling the service to stop directly, without stopping the the cluster on any node, using the following command on one of the nodes:<\/p>\n<pre> \r\n$ sudo crm_resource --resource http_server --force-stop \r\n<\/pre>\n<p>Then you need to run\u00a0<strong>crm_mon<\/strong>\u00a0in interactive mode (the default), within the monitor interval of 2 minutes, you should be able to see the cluster notice that\u00a0<strong>http_server<\/strong>\u00a0failed and move it to another node.<\/p>\n<p>For your cluster services to run efficiently, you may need to set some constraints. You can see the\u00a0<strong>pcs<\/strong>\u00a0man page (man pcs) for a list of all usage commands.<\/p>\n<p>For more information on Corosync and Pacemaker, check out:\u00a0<a href=\"https:\/\/clusterlabs.org\/\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/clusterlabs.org\/<\/a><\/p>\n<h5>Summary<\/h5>\n<p>In this guide, we have shown the basics of how to deploy, configure and maintain high availability\/clustering\/replication in Ubuntu 16.04\/18.04 and CentOS 7. We demonstrated how to add Nginx HTTP service to a cluster. If you have any thoughts to share or questions, use the feedback form below.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/what-is-clustering-and-advantages-disadvantages-of-clustering-in-linux\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi all, this time I decided to share my knowledge about Linux clustering with you as a series of guides titled \u201cLinux Clustering For a Failover Scenario\u201c. What is Clustering in Linux and Advantages\/Disadvantages \u2013 Part 1 Following are the 4-article series about\u00a0Clustering\u00a0in Linux: Part 1:\u00a0Introduction to Linux Clustering and Advantages\/Disadvanges of Clustering Part 2:\u00a0How &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/17\/introduction-to-clusters-in-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Introduction to Clusters in Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-11813","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11813","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=11813"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11813\/revisions"}],"predecessor-version":[{"id":11819,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/11813\/revisions\/11819"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=11813"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=11813"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=11813"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}