{"id":8303,"date":"2022-05-31T11:33:43","date_gmt":"2022-05-31T03:33:43","guid":{"rendered":"https:\/\/nj.transwarp.cn:8180\/?p=8303"},"modified":"2022-05-31T16:31:00","modified_gmt":"2022-05-31T08:31:00","slug":"hdfs-ha%e7%9a%84%e8%84%91%e8%a3%82%e9%97%ae%e9%a2%98%ef%bc%9aipcs-epoch-x-is-less-than-the-last-promised-epoch-x1","status":"publish","type":"post","link":"https:\/\/kbwp.transwarp.cn\/?p=8303","title":{"rendered":"HDFS HA\u7684\u8111\u88c2\u95ee\u9898\uff1aIPC&#8217;s epoch [X] is less than the last promised epoch [X+1]"},"content":{"rendered":"<h3>\u6982\u8981\u63cf\u8ff0<\/h3>\n<hr \/>\n<p>Hadoop2.X\u63d0\u4f9b\u4e86\u5bf9HDFS\u7684\u9ad8\u53ef\u7528\u5b9e\u73b0\uff0c\u5373\u4e24\u53f0Namenode\u505a\u70ed\u5907\uff0c\u4fdd\u6301\u5143\u6570\u636e\u4e00\u81f4\uff0c\u901a\u8fc7ZK\u5b9e\u73b0\u6545\u969c\u8fc1\u79fb\u3002\u4f46\u5728HA\u7684\u5177\u4f53\u5b9e\u73b0\u4e2d\uff0c\u6709\u65f6\u4f1a\u51fa\u73b0\u8111\u88c2\u7684\u95ee\u9898\u3002<\/p>\n<h3>\u8be6\u7ec6\u8bf4\u660e<\/h3>\n<hr \/>\n<h4>\u95ee\u9898\u73b0\u8c61<\/h4>\n<p>Active NameNode\u51fa\u73b0\u5f02\u5e38\uff0c\u4efb\u52a1\u4e2d\u65ad\uff0cNameNode\u65e5\u5fd7\u4e2d\u62a5\u9519\uff1aIPC&#8217;s epoch [X] is less than the last promised epoch [X+1]\uff1b<br \/>\nHDFS\u51fa\u73b0\u77ed\u671f\u7684\u53ccActive\uff0c\u540e\u7eed\u81ea\u52a8\u6062\u590d\u3002<\/p>\n<h4>\u95ee\u9898\u539f\u56e0<\/h4>\n<p>\u8be5\u95ee\u9898\u5c5e\u4e8eHDFS HA\u5bf9\u4e8e\u8111\u88c2\u7684\u5f02\u5e38\u4fdd\u62a4\uff1b<\/p>\n<p>\u8111\u88c2\uff0c\u5373\u5728\u5206\u5e03\u5f0f\u7cfb\u7edf\u4e2d\u51fa\u73b0\u7684\u53cc\u4e3b\u73b0\u8c61\uff0c\u5728\u5b9e\u9645\u4e2d\uff0cNameNode \u53ef\u80fd\u4f1a\u51fa\u73b0\u8fd9\u79cd\u60c5\u51b5\uff0cNameNode \u5728\u5783\u573e\u56de\u6536\uff08GC\uff09\u6216\u7f51\u7edc\u901a\u4fe1\u5f02\u5e38\u7684\u60c5\u51b5\u4e0b\uff0c\u53ef\u80fd\u4f1a\u5728\u957f\u65f6\u95f4\u5185\u6574\u4e2a\u7cfb\u7edf\u65e0\u54cd\u5e94\uff0c\u56e0\u6b64\uff0c\u4e5f\u5c31\u65e0\u6cd5\u5411 ZK \u5199\u5165\u5fc3\u8df3\u4fe1\u606f\uff0c\u8fd9\u6837\u7684\u8bdd\u53ef\u80fd\u4f1a\u5bfc\u81f4\u4e34\u65f6\u8282\u70b9\u6389\u7ebf\uff0c\u5907 NameNode \u4f1a\u5207\u6362\u5230 Active \u72b6\u6001\uff0c\u8fd9\u79cd\u60c5\u51b5\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u96c6\u7fa4\u540c\u65f6\u6709\u4e24\u4e2a Active NameNode\uff0c\u51fa\u73b0\u51b2\u7a81\uff0c\u4e14\u65e0\u6cd5\u4fdd\u8bc1\u6570\u636e\u7684\u4e00\u81f4\u6027\u3002<\/p>\n<p>\u5177\u4f53\u4fe1\u606f\u4e5f\u53ef\u4ee5\u53c2\u8003<a href=\"https:\/\/hadoop.apache.org\/docs\/r2.7.1\/hadoop-project-dist\/hadoop-hdfs\/HDFSHighAvailabilityWithQJM.html\" title=\"hadoop\u5b98\u65b9\u6587\u6863\">hadoop\u5b98\u65b9\u6587\u6863<\/a>\u3002<\/p>\n<p>ZKFC\u65e5\u5fd7\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-shell\">2022-05-25 18:23:21,822 WARN org.apache.hadoop.ha.HealthMonitor: Transport-level exception trying to monitor health of NameNode at tg-namenode01\/10.33.25.8:8020: java.net.ConnectException:Connection refused Call From tg-namenode01\/10.33.25.8 to tg-namenode01\/10.33.25.8:8020 failed on connection exception: java.net.ConnectException:Connection refused; For more details see: http:\/\/wiki.apache.org\/hadoop\/SocketTimeout\n2022-05-25 18:25:12,825 WARN org.apache.hadoop.ha.FailoverController: Unable to gracefully make NameNode at tg-namenode02\/10.33.25.9:8020 standby (unable to connect)\njava.io.IOException: Failed on local exception:java.io.IOException: java.net.SocketTimeoutException: 5000 millis timeout while waiting for channel to be ready for read. ch : java.nio.channels.SocketChannel[connected local=\/10.33.25.8:53810 remote=namenode02\/10.33.25.9:8020]; For more details see:  http:\/\/wiki.apache.org\/hadoop\/SocketTimeout<\/code><\/pre>\n<p>Namenode\u62a5\u9519\uff1aIPC&#8217;s epoch [X] is less than the last promised epoch [X+1]\uff0c\u5219\u662f\u56e0\u4e3a\uff1a<\/p>\n<p>1\u3001ZKFC\u5bf9NameNode1(Active)\u8fdb\u884c\u5065\u5eb7\u68c0\u67e5\uff0c\u56e0\u4e3a\u957f\u65f6\u95f4\u76d1\u63a7\u4e0d\u5230NN1\u7684\u56de\u590d\uff0c\u8ba4\u4e3a\u8be5NameNode1\u4e0d\u5065\u5eb7\uff0c\u4f46\u662fActive NameNode\u53c8\u6ca1\u6709\u6302\uff08\u56e0\u4e3azkfc\u4e0eNameNode1\u8fde\u63a5\u5f02\u5e38\uff0c\u4e0d\u80fd\u5c06\u5176shutdown\uff09\uff1b<\/p>\n<p>2\u3001ZKFC\u7136\u540e\u53bb\u9009\u53d6StandbyNameNode\u4e3aActive\uff0c\u540c\u65f6\u4f1a\u66f4\u65b0JN\u4e2d\u7684epoch\u4f7f\u5176+1\uff1b<\/p>\n<p>3\u3001\u539f\u6765\u7684Active NameNode\u538b\u529b\u7f13\u89e3\u4e86\uff0c\u53d1\u73b0\u81ea\u5df1\u4e0d\u662f\u4e3b\u8282\u70b9\uff0c\u518d\u6b21\u53bb\u64cd\u4f5cJournalNode\u7684editlog\u65f6\u53d1\u73b0\u81ea\u5df1\u7684epoch\u6bd4JN\u7684epoch\u5c0f1\uff0c\u968f\u5373\u62a5\u9519\uff1b<\/p>\n<p>Namenode\u65e5\u5fd7\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-shell\">2022-05-25 18:20:57,666 WARN org.apache.hadoop.hdfs.qjournal.client.QuorumJournalManager: Remote jounal 10.33.25.9:8485 failed to write txns 2464561626-2464561626. Will try to write to this JN again after the next log roll.\norg.apache.hadoop.ipc.RemoteException(java.io.IOException): IPC's epoch 29 is less than the last promised epoch 30<\/code><\/pre>\n<h4>\u89e3\u51b3\u65b9\u6848<\/h4>\n<p>\u5173\u4e8e\u8fd9\u4e2a\u95ee\u9898\uff0cHDFS\u81ea\u5e26\u7684\u89e3\u51b3\u65b9\u6848\u662f<strong>\u9694\u79bb\uff08Fencing\uff09<\/strong>\uff0c\u4e3b\u8981\u662f\u5728\u4ee5\u4e0b\u4e09\u5904\u91c7\u7528\u9694\u79bb\u63aa\u65bd\uff1a<\/p>\n<p>1\u3001\u5171\u4eab\u5b58\u50a8\u9694\u79bb\uff1a\u540c\u4e00\u65f6\u95f4\u53ea\u5141\u8bb8\u4e00\u4e2aNamenode\u5411JournalNodes\u5199\u5165editlog\u6570\u636e\u3002<\/p>\n<p>2\u3001\u5ba2\u6237\u7aef\u9694\u79bb\uff1a\u540c\u4e00\u65f6\u95f4\u53ea\u5141\u8bb8\u4e00\u4e2aNamenode\u54cd\u5e94\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\u3002 <\/p>\n<p>3\u3001Datanode\u9694\u79bb\uff1a\u540c\u4e00\u65f6\u95f4\u53ea\u5141\u8bb8\u4e00\u4e2aNamenode\u5411Datanode\u4e0b\u53d1\u540d\u5b57\u8282\u70b9\u6307\u4ee4\uff0c\u4f8b\u5982\u5220\u9664\u3001\u590d\u5236\u6570\u636e\u5757\u6307\u4ee4\u7b49\u7b49\u3002<\/p>\n<p><strong>\u5728\u8fdb\u884c fencing \u7684\u65f6\u5019\uff0c\u4f1a\u6267\u884c\u4ee5\u4e0b\u7684\u64cd\u4f5c\uff1a<\/strong><\/p>\n<p>1\u3001\u9996\u5148\u5c1d\u8bd5\u8c03\u7528\u8fd9\u4e2a\u65e7 Active NameNode \u7684 HAServiceProtocol RPC \u63a5\u53e3\u7684 transitionToStandby \u65b9\u6cd5\uff0c\u770b\u80fd\u4e0d\u80fd\u628a\u5b83\u8f6c\u6362\u4e3a Standby \u72b6\u6001\uff1b<\/p>\n<p>2\u3001\u5982\u679c transitionToStandby \u65b9\u6cd5\u8c03\u7528\u5931\u8d25\uff0c\u90a3\u4e48\u5c31\u6267\u884c Hadoop \u914d\u7f6e\u6587\u4ef6\u4e4b\u4e2d\u9884\u5b9a\u4e49\u7684\u9694\u79bb\u63aa\u65bd\u3002<\/p>\n<p><strong>Hadoop \u76ee\u524d\u4e3b\u8981\u63d0\u4f9b\u4e24\u79cd\u9694\u79bb\u63aa\u65bd\uff1a<\/strong><\/p>\n<p><strong>sshfence\uff1a<\/strong>\u901a\u8fc7 SSH \u767b\u5f55\u5230\u76ee\u6807\u673a\u5668\u4e0a\uff0c\u6267\u884c\u547d\u4ee4 fuser \u5c06\u5bf9\u5e94\u7684\u8fdb\u7a0b\u6740\u6b7b\uff1b<\/p>\n<p><strong>shellfence\uff1a<\/strong>\u6267\u884c\u4e00\u4e2a\u7528\u6237\u81ea\u5b9a\u4e49\u7684 shell \u811a\u672c\u6765\u5c06\u5bf9\u5e94\u7684\u8fdb\u7a0b\u9694\u79bb\u3002<\/p>\n<p>\u53ea\u6709\u5728\u6210\u529f\u5730\u6267\u884c\u5b8c\u6210 fencing \u4e4b\u540e\uff0c\u9009\u4e3b\u6210\u529f\u7684 ActiveStandbyElector \u624d\u4f1a\u56de\u8c03 ZKFailoverController \u7684 becomeActive \u65b9\u6cd5\u5c06\u5bf9\u5e94\u7684 NameNode \u8f6c\u6362\u4e3a Active \u72b6\u6001\uff0c\u5f00\u59cb\u5bf9\u5916\u63d0\u4f9b\u670d\u52a1\u3002<\/p>\n<p><strong>\u76ee\u524dTDH\u4e2d\u91c7\u7528\u7684\u662fshellfence\u673a\u5236\uff0c\u5373\u6267\u884cshell \u811a\u672c\u6765\u5c06\u5bf9\u5e94\u7684\u8fdb\u7a0b\u9694\u79bb\u3002<\/strong><\/p>\n<p>\u8fd9\u91cc\u7684shell\u811a\u672c\u5b9a\u4e49\u5728core-site.xml\u4e2d\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/nj.transwarp.cn:8180\/wp-content\/uploads\/2022\/05\/image-1653967853612.png\" alt=\"file\" \/><\/p>\n<p>\u5728ZKFC\u65e5\u5fd7\u4e2d\u6211\u4eec\u53ef\u4ee5\u770b\u5230fencing\u7684\u8fc7\u7a0b\uff1a<\/p>\n<pre><code class=\"language-shell\">2022-05-25 19:02:19,936 INFO org.apache.hadoop.ha.NodeFencer: ====== Beginning Service Fencing Process\u2026 ======\n2022-05-25 19:02:19,936 INFO org.apache.hadoop.ha.Nodefencer: Trying method 1\/1: org.apache.hadoop.ha.ShellComnandFencer(\/bin\/true)\n2022-05-25 19:02:10.939 INFO org.apache.hadoop.ha.ShellCommandFencer: Launched fencing command \u2018\/bin\/true\u2019 with pid 149\n2022-05-25 19:02:19,946 INFO org.apache.hadoop.ha.Nodefencer: ====== Fencing Successful by method org.apache.hadoop.ha.ShellComnandFencer(\/bin\/true) ======\n2022-05-25 19:02:10.947 INFO org.apache.hadoop.ha.ActiveStandbyElector: Writing Znode \/hdfs1-ha\/nameservice1\/ActiveBreadCrumb to indicate that the local node is the most recent active..\n2022-05-25 19:02:10.949 INFO org.apache.hadoop.ha.ZKFailoverController: Trying to make Namenode at tg-namenode1\/10.33.25.8:8020 active\u2026 \n2022-05-25 19:02:28,844 INFO org.apache.hadoop.ha.ZKFailoverController: Successfullytransitioned NameNode at tg-namenode1\/10.33.25.8:8020 to active state<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/nj.transwarp.cn:8180\/wp-content\/uploads\/2022\/05\/image-1653962811074.png\" alt=\"file\" \/><\/p>\n<h4>\u540e\u7eed\u6392\u67e5\u601d\u8def\u53ca\u4f18\u5316<\/h4>\n<p>\u8111\u88c2\u53d1\u751f\u901a\u5e38\u662f\u56e0\u4e3a\u7f51\u7edc\u5ef6\u8fdf\u3001\u901a\u4fe1\u6545\u969c\u3001\u6216Namenode\u53d1\u751fFGC\u7b49\u3002\u6240\u4ee5\u5728\u51fa\u73b0\u6b64\u7c7b\u95ee\u9898\u65f6\uff0c\u53ef\u4ee5\u6309\u7167\u5982\u4e0b\u601d\u8def\u6392\u67e5\uff1a<\/p>\n<p>1\u3001  \u68c0\u67e5\u7f51\u7edc\u901a\u4fe1\uff0c\u5982\u8282\u70b9\u95f4\u901a\u4fe1\u662f\u5426\u6b63\u5e38\uff0c\u7aef\u53e3\u662f\u5426\u5f00\u901a\uff0c\u662f\u5426\u6709\u4e22\u5305\uff0cSELINUX\u548c\u9632\u706b\u5899\u662f\u5426\u5173\u95ed\u7b49\uff1b<\/p>\n<p>2\u3001  \u68c0\u67e5Namenode\u662f\u5426\u6709CPU\u6216\u5185\u5b58\u4e0d\u8db3\u7684\u60c5\u51b5\uff0c\u5bfc\u81f4rpc\u8d85\u65f6\uff1b<\/p>\n<p>3\u3001  \u68c0\u67e5Namenode\u662f\u5426\u538b\u529b\u8fc7\u5927\uff0c\u89e6\u53d1\u4e86FGC\uff08\u6bd4\u5982\u5c0f\u6587\u4ef6\u8fc7\u591a\u5bfc\u81f4NN\u5185\u5b58\u5360\u7528\u8fc7\u591a\uff1f\uff09\uff1b<\/p>\n<p>4\u3001  \u57fa\u4e8eZKFC\u5728\u6536\u5230active Namenode\u7aef\u6545\u969c\u901a\u77e5\u65f6\uff0c\u5bf9\u4e8estandby Namenode\u7684\u72b6\u6001\u5207\u6362\u5b58\u5728\u8d85\u65f6\u65f6\u95f4\uff0c HealthMonitor\u90fd\u4f1a\u5b9a\u671f\u7684\u68c0\u67e5NameNode\u662f\u5426\u5065\u5eb7\uff0c\u5f53\u96c6\u7fa4\u53d8\u5927\u7684\u65f6\u5019\uff0c\u6211\u4eec\u53ef\u4ee5\u9002\u5f53\u7684\u8bbe\u7f6e\u8fd9\u4e2a\u76d1\u63a7\u7684\u8d85\u65f6\u65f6\u95f4\uff0c\u8ba9ZKFC\u7684HealthMonitor\u6ca1\u90a3\u4e48\u201c\u654f\u611f\u201d\u3002<br \/>\n\u6d89\u53ca\u5230\u7684\u53c2\u6570\u5982\u4e0b\uff08\u5b9a\u4e49\u5728core-site.xml\u914d\u7f6e\u6587\u4ef6\u4e2d\uff09\uff1a<\/p>\n<p>HA\u529f\u80fd\u7684\u5065\u5eb7\u76d1\u63a7\u95f4\u9694\u65f6\u95f4\uff0c\u9ed8\u8ba41000ms<br \/>\nha.health-monitor.check-interval.ms = 2000<\/p>\n<p>HA\u529f\u80fd\u5065\u5eb7\u76d1\u63a7\u7684\u8d85\u65f6\u65f6\u95f4\uff0c\u9ed8\u8ba445000\u6beb\u79d2<br \/>\nha.health-monitor.rpc-timeout.ms = 180000<\/p>\n<p>\u5f0a\u7aef\uff1a\u4f1a\u5e26\u6765\u5207\u6362\u8fc7\u7a0b\u65f6\u95f4\u589e\u957f\uff0cInceptor\u7b49\u4f9d\u8d56\u5e94\u7528\u65e0\u54cd\u5e94\u751a\u81f3\u4efb\u52a1\u5931\u8d25\u7684\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981\u63cf\u8ff0 Hadoop2.X\u63d0\u4f9b\u4e86\u5bf9HDFS\u7684\u9ad8\u53ef\u7528\u5b9e\u73b0\uff0c\u5373\u4e24\u53f0Namenode\u505a\u70ed\u5907\uff0c\u4fdd\u6301\u5143\u6570\u636e\u4e00\u81f4\uff0c\u901a\u8fc7Z ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/kbwp.transwarp.cn\/?p=8303\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":105,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[45,43,1],"tags":[],"class_list":["post-8303","post","type-post","status-publish","format-standard","hentry","category-crash","category-service_abnormal","category-uncategorized"],"acf":[],"_links":{"self":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/8303","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/users\/105"}],"replies":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8303"}],"version-history":[{"count":2,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/8303\/revisions"}],"predecessor-version":[{"id":8332,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/8303\/revisions\/8332"}],"wp:attachment":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}