{"id":75726,"date":"2020-03-28T07:42:08","date_gmt":"2020-03-28T05:42:08","guid":{"rendered":"https:\/\/prohoster.info\/blog\/administrirovanie\/klaster-iz-dvuh-uzlov-dyavol-v-detalyah"},"modified":"2020-03-28T07:42:08","modified_gmt":"2020-03-28T05:42:08","slug":"klaster-iz-dvuh-uzlov-dyavol-v-detalyah","status":"publish","type":"post","link":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/klaster-iz-dvuh-uzlov-dyavol-v-detalyah","title":{"rendered":"A two-node cluster - the devil is in the details","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p>Hello, Habr! I present to your attention the translation of the article. <noindex><a rel=\"nofollow\" href=\"http:\/\/blog.clusterlabs.org\/blog\/2018\/two-node-problems\">\u00abTwo Nodes \u2014 The Devil is in the Details\u00bb<\/a><\/noindex> by Andrew Beekhof.<\/p>\n<p>Many people prefer clusters consisting of two nodes because they seem conceptually simpler and are also 33% cheaper than their three-node counterparts. While it is entirely possible to build a good cluster with two nodes, in most cases, due to unconsidered scenarios, such a configuration will create many non-obvious problems.<br \/>\n<noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><br \/>\nThe first step in creating any high-availability system is to identify and attempt to eliminate single points of failure, often abbreviated as <i>SPoF<\/i> (single point of failure).<\/p>\n<p>It is worth noting that it is impossible to eliminate all potential downtime risks in any system. This stems, at least in part, from the fact that typical risk mitigation involves introducing some redundancy, which increases system complexity and creates new points of failure. Thus, we initially make compromises and focus on events related to individual points of failure rather than on chains of related and, consequently, increasingly improbable events.<\/p>\n<p>Given the compromises, we not only look for SPoF but also balance risks and consequences, resulting in the conclusion that what is critical may differ for each deployment.<\/p>\n<blockquote><p>Not everyone needs alternate power suppliers with independent power lines. Although paranoia paid off at least for one client when their monitoring identified a faulty transformer. The client called to warn the utility company until the faulty transformer exploded.<\/p><\/blockquote>\n<p>\nA natural starting point is to have more than one node in the system. However, before the system can move services to the surviving node after a failure, generally, it must be ensured that the services being migrated are not active elsewhere.<\/p>\n<p>A two-node cluster has no shortcomings if, in the event of a failure, both nodes serve the same static website. However, everything changes if both sides independently manage a shared job queue or provide uncoordinated write access to a replicated database or shared file system.<\/p>\n<p>Therefore, to prevent data corruption due to a node failure, we rely on what is called <i>fencing<\/i> (fencing).<\/p>\n<h2>The principle of fencing<\/h2>\n<p>\nThe basis of the fencing principle lies in the question: can a competing node cause data corruption? If data corruption is a likely scenario, a good solution would be to isolate the node from both incoming requests and persistent storage. The most common approach to fencing is to disable the faulty nodes.<\/p>\n<p>There are two categories of fencing methods that I will refer to as <i>direct<\/i> and <i>indirect<\/i>, but they can equally be termed <i>active<\/i> and <i>passive<\/i>. Direct methods involve actions from the surviving peer nodes, such as interacting with the IPMI (Intelligent Platform Management Interface) device or iLO (server management mechanism in the absence of physical access), while indirect methods rely on the failed node to somehow recognize that it is in an unhealthy state (or at least prevents other members from recovering) and signal <noindex><a rel=\"nofollow\" href=\"https:\/\/en.wikipedia.org\/wiki\/Watchdog_timer\">hardware watchdog<\/a><\/noindex> the necessity to shut down the failed node.<\/p>\n<p>Quorum helps in using both direct and indirect methods.<\/p>\n<h3>Direct fencing<\/h3>\n<p>\nIn the case of direct fencing, we can use a quorum to prevent fencing races in the event of a network failure.<\/p>\n<p>With the quorum concept, the system has enough information (even without being connected to its partners) for nodes to automatically know whether they should initiate fencing and\/or recovery.<\/p>\n<p>Without a quorum, both sides of the network split reasonably assume that the other side is dead and will strive to fence the other. In the worst case, both sides manage to disconnect the entire cluster. An alternative scenario is a deathmatch, an endless cycle of nodes appearing, not seeing their peers, rebooting them, and initiating recovery only to reboot when their peer follows the same logic.<\/p>\n<p>The problem with quorum is that the most commonly used devices become unavailable due to the very failure events we want to leverage for recovery. Most IPMI and iLO cards are installed on the hosts they control and, by default, use the same network, which leads the target nodes to believe that the other nodes are offline.<\/p>\n<p>Unfortunately, the operational peculiarities of IPMI and iLO devices are rarely considered at the time of purchasing equipment.<\/p>\n<h3>Indirect quorum<\/h3>\n<p>\nQuorum is also important for managing indirect quorums; if done correctly, quorum can allow the surviving nodes to assume that the lost nodes will enter a safe state after a certain period.<\/p>\n<p>In this setup, the hardware watchdog timer is reset every N seconds if a quorum is not lost. If the timer (usually several multiples of N) expires, the device performs an ungraceful power off (not a shutdown).<\/p>\n<p>This approach is very effective, but without a quorum for its management, there is insufficient information within the cluster. It's not easy to distinguish between a network outage and a partner node failure. The reason this matters is that without the ability to distinguish between the two cases, you are forced to choose the same mode of behavior in both scenarios.<\/p>\n<p>The problem with choosing a single mode is that there is no set of actions that maximally increases availability and prevents data loss.<\/p>\n<ul>\n<li>If you choose to assume that the partner node is active but it has actually failed, the cluster will unnecessarily stop services that should have been running to compensate for the loss of services from the failed partner node.<\/li>\n<li>If you choose to assume that the node is down, but it was just a network failure and the remote node is actually functioning, then at best you are signing up for some future manual reconciliation of the resulting datasets.<\/li>\n<\/ul>\n<p>\nRegardless of the heuristic you use, it is trivial to create a failure that either causes both sides to operate or forces the cluster to shut down the surviving nodes. Not utilizing quorum indeed deprives the cluster of one of the most powerful tools in its arsenal.<\/p>\n<p>If there is no other alternative, the best approach would be to sacrifice availability (the author refers here to the CAP theorem). High availability of corrupted data helps no one, and manually cross-referencing different data sets is also no pleasure.<\/p>\n<h2>Quorum<\/h2>\n<p>\nQuorum sounds great, doesn't it?<\/p>\n<p>The only downside is that in order to have it in a cluster with N members, you need to maintain a connection between N \/ 2 + 1 of your nodes. This is impossible in a two-node cluster after one node fails.<\/p>\n<p>Which ultimately brings us to the fundamental issue with two nodes:<br \/>\nquorum doesn't make sense in two-node clusters, and without it, it's impossible to reliably determine the course of action that maximizes availability and prevents data loss.<br \/>\nEven in a two-node system connected by a crossover cable, it's impossible to definitively distinguish between a network partition and the failure of the other node. A disconnection at one end (the likelihood of which is certainly proportional to the distance between nodes) will suffice to undermine any assumption that the channel's operational status equals the health of the partner node.<\/p>\n<h3>Getting a two-node cluster to work<\/h3>\n<p>\nSometimes a client cannot or does not want to purchase a third node, and we have to look for an alternative.<\/p>\n<h4>Option 1 \u2014 Redundant fencing method<\/h4>\n<p>\nThe iLO or IPMI device of a node represents a single point of failure, as, in the event of a failure, the remaining nodes cannot use it to transition the node to a safe state. In a cluster of 3 or more nodes, we can mitigate this with quorum calculation and using a hardware watchdog (the indirect fencing mechanism discussed earlier). In the case of two nodes, we must instead rely on network power switches (power distribution units or PDUs).<\/p>\n<p>After a failure, the survivor first tries to contact the main fencing device (internal iLO or IPMI). If successful, recovery continues as usual. Only in the event of a failure of the iLO\/IPMI device does it reach out to the PDU, and if that call is successful, recovery can proceed.<\/p>\n<p>Make sure to place the PDU on a network separate from the cluster traffic; otherwise, a single network failure will block access to both the devices and hinder service recovery.<\/p>\n<p>Here you might ask \u2013 isn't the PDU device a single point of failure? The answer is yes, it certainly is.<\/p>\n<p>If this risk is significant for you, you are not alone: connect both nodes to two PDUs and configure the cluster software to use both when powering on and off the nodes. Now the cluster remains active if one PDU fails, and a second failure of either another PDU or the IPMI device will be required to block recovery.<\/p>\n<h4>Option 2 \u2013 Adding an Arbiter<\/h4>\n<p>\nIn some scenarios, while technically possible, the method of redundant isolation is politically complex. Many companies prefer to maintain a certain separation between administrators and application owners, and security-conscious network administrators are not always enthusiastic about granting anyone access parameters to the PDU.<\/p>\n<p>In this case, the recommended alternative is to create a neutral third party that can supplement the quorum calculation.<\/p>\n<p>In the event of a failure, a node must be able to see the signal from its partner or the arbiter in order to restore services. The arbiter also includes a disconnection feature if both nodes can see the arbiter but not each other.<\/p>\n<p>This option should be used in conjunction with an indirect isolation method, such as a hardware watchdog timer, set to power down the machine if it loses connection with its partner node and the arbiter. This way, the survivor can reasonably assume that its partner node will be in a safe state after the hardware watchdog timer expires.<\/p>\n<p>The practical difference between an arbiter and a third node is that the arbiter requires far fewer resources to operate and can potentially serve more than one cluster.<\/p>\n<h4>Option 3 \u2013 The Human Factor<\/h4>\n<p>\nThe latest approach is for the surviving nodes to continue performing any services they were already doing, but not to start new ones until either the issue resolves itself (network recovery, node reboot) or someone takes responsibility for manually confirming that the other side is down.<\/p>\n<h4>Bonus Option<\/h4>\n<p>\nDid I already mention that you can add a third node?<\/p>\n<h2>Two Racks<\/h2>\n<p>\nFor the sake of argument, let\u2019s assume I convinced you of the benefits of a third node; we now need to consider the physical location of the nodes. If they are housed (and powered) in the same rack, this also represents a SPoF, one that cannot be resolved by merely adding a second rack.<\/p>\n<p>If that's surprising, think about what happens if the rack with the two nodes fails and how the surviving node will recognize this case versus a network failure.<\/p>\n<p>The short answer: it\u2019s impossible, and we are again dealing with all the issues from the two-node scenario. Either the surviving node:<\/p>\n<ul>\n<li>ignores quorum and improperly attempts to initiate recovery during network disruptions (the potential for fault isolation is a separate story and depends on whether the PDU is involved and whether they share power with one of the racks), or<\/li>\n<li>respects quorum and prematurely shuts itself down when its partner node fails.<\/li>\n<\/ul>\n<p>\nIn any case, two racks are no better than one, and the nodes should either receive independent power sources or be distributed across three (or more, depending on how many nodes you have) racks.<\/p>\n<h3>Two Data Centers<\/h3>\n<p>\nBy this point, readers who are no longer risk-tolerant may be thinking about disaster recovery. What happens when an asteroid hits one data center with our three nodes distributed across three different racks? Obviously, Bad Things, but depending on your needs, adding a second data center may not be enough.<\/p>\n<p>If everything is done correctly, the second data center provides you (which is reasonable) with an up-to-date and consistent copy of your services and their data. However, as with scenarios involving two nodes and two racks, the system lacks sufficient information to ensure maximum availability and prevent damage (or discrepancies in data sets). Even with three nodes (or racks), their distribution across only two data centers leaves the system unable to reliably make the right decision in the event of an (now much more likely) incident that both sides cannot correlate.<\/p>\n<p>This does not mean that a two-data-center solution is never suitable. Companies often want to ensure someone is informed before taking the exceptional step of transitioning to a backup data center. Just keep in mind that if you wish to automate failure, you will either need a third data center for a quorum to make sense (directly or through an arbiter) or you will need to find a way to reliably take down the entire data center.<br \/>\n<br \/>Source: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/494264\/\">habr.com<\/a> <\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438 \u00abTwo Nodes \u2014 The Devil is in the Details\u00bb \u0430\u0432\u0442\u043e\u0440\u0430 Andrew Beekhof. \u041c\u043d\u043e\u0433\u0438\u0435 \u043b\u044e\u0434\u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044e\u0442 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u044b \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0438\u0435 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0443\u0437\u043b\u043e\u0432, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d\u0438 \u043a\u0430\u0436\u0443\u0442\u0441\u044f \u043a\u043e\u043d\u0446\u0435\u043f\u0442\u0443\u0430\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438, \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e \u0435\u0449\u0435 \u0438 \u043d\u0430 33% \u0431\u043e\u043b\u0435\u0435 \u0434\u0435\u0448\u0435\u0432\u044b\u043c\u0438 \u0447\u0435\u043c \u0438\u0445 \u0442\u0440\u0435\u0445-\u0443\u0437\u043b\u043e\u0432\u044b\u0435 \u0441\u043e\u0431\u0440\u0430\u0442\u044c\u044f. \u0425\u043e\u0442\u044f \u0432\u043f\u043e\u043b\u043d\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0443\u0437\u043b\u043e\u0432, [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-75726","post","type-post","status-publish","format-standard","hentry","category-administrirovanie"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.2 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/klaster-iz-dvuh-uzlov-dyavol-v-detalyah\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.2\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47\u041a\u043b\u0430\u0441\u0442\u0435\u0440 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0443\u0437\u043b\u043e\u0432 \u2013 \u0434\u044c\u044f\u0432\u043e\u043b \u0432 \u0434\u0435\u0442\u0430\u043b\u044f\u0445 | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/klaster-iz-dvuh-uzlov-dyavol-v-detalyah\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2020-03-28T05:42:08+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2020-03-28T05:42:08+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47A Two-Node Cluster \u2013 The Devil is in the Details | ProHoster","description":"Hello, Habr!","canonical_url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/klaster-iz-dvuh-uzlov-dyavol-v-detalyah","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"en_US","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47\u041a\u043b\u0430\u0441\u0442\u0435\u0440 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0443\u0437\u043b\u043e\u0432 \u2013 \u0434\u044c\u044f\u0432\u043e\u043b \u0432 \u0434\u0435\u0442\u0430\u043b\u044f\u0445 | ProHoster","og:description":"\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!","og:url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/klaster-iz-dvuh-uzlov-dyavol-v-detalyah","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2020-03-28T05:42:08+00:00","article:modified_time":"2020-03-28T05:42:08+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"75726","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":null,"breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-02-28 17:50:33","updated":"2022-10-03 21:32:17","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/75726","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/comments?post=75726"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/75726\/revisions"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media?parent=75726"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/categories?post=75726"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/tags?post=75726"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}