{"id":1243,"date":"2022-02-24T22:05:21","date_gmt":"2022-02-24T14:05:21","guid":{"rendered":"http:\/\/www.eait.co\/?p=1243"},"modified":"2022-02-26T21:45:24","modified_gmt":"2022-02-26T13:45:24","slug":"zookeeperhadoop%e9%ab%98%e5%8f%af%e7%94%a8%e6%89%8b%e5%8a%a8%e5%88%87%e6%8d%a2","status":"publish","type":"post","link":"https:\/\/notes.coremix.net\/?p=1243","title":{"rendered":"Zookeeper+Hadoop\u9ad8\u53ef\u7528(\u624b\u52a8\u5207\u6362)"},"content":{"rendered":"<p>\u521b\u5efa\u4e00\u4e2aHAtest\u6587\u4ef6\uff0c\u53ef\u4ee5\u5faa\u73af\u521b\u5efa<\/p>\n<p>mkdir -vp \/opt\/module\/HA<\/p>\n<p>\u590d\u5236\u6216\u8005\u89e3\u538b\u4e00\u4e2a\u8fc7\u53bb\uff08\u6b64\u5904\u662f\u4ece\u524d\u9762\u5206\u5e03\u5f0f\u76f4\u63a5\u590d\u5236\uff09\uff1acp -r hadoop2.8.4\u00a0 HA<\/p>\n<p>\u914d\u7f6ejava\u73af\u5883\uff1a\u7565<\/p>\n<p>scp \u5230\u5176\u5b83\u8def\u5f84\uff1ascp -r xxxx bigdata166:`pwd`\u00a0 \u548c167<\/p>\n<p>\u540c\u65f6\u8981\u4e34\u65f6\u6ce8\u91ca\u6389\u539f\u6765\u7684\u73af\u5883\u53d8\u91cf\u7684hadoop\u7684\u8def\u5f84<\/p>\n<p>\u4fee\u6539\u6240\u6709core-site.xml\u6587\u4ef6\uff08\u66ff\u6362\u91cc\u9762\u5185\u5bb9\uff09\uff1a<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;configuration&gt;\r\n&lt;!-- \u628a\u4e24\u4e2aNameNode\uff09\u7684\u5730\u5740\u7ec4\u88c5\u6210\u4e00\u4e2a\u96c6\u7fa4mycluster --&gt;\r\n\t\t&lt;property&gt;\r\n\t\t\t&lt;name&gt;fs.defaultFS&lt;\/name&gt;\r\n\t\t\t&lt;!--\u6b64\u5904\u6539cluster\uff0c\u4e0b\u9762\u6539\u4e0b\u8def\u5f84 --&gt;\r\n        \t&lt;value&gt;hdfs:\/\/mycluster&lt;\/value&gt;\r\n\t\t&lt;\/property&gt;\r\n\r\n\t\t&lt;!-- \u6307\u5b9ahadoop\u8fd0\u884c\u65f6\u4ea7\u751f\u6587\u4ef6\u7684\u5b58\u50a8\u76ee\u5f55 --&gt;\r\n\t\t&lt;property&gt;\r\n\t\t\t&lt;name&gt;hadoop.tmp.dir&lt;\/name&gt;\r\n\t\t\t&lt;value&gt;\/opt\/module\/HA\/hadoop-2.8.4\/data&lt;\/value&gt;\r\n\t\t&lt;\/property&gt;\r\n&lt;\/configuration&gt;\r\n\r\n<\/pre>\n<p>\u4fee\u6539\u6240\u6709hdfs-site.xml<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n\r\n\r\n&lt;configuration&gt;\r\n\t&lt;!-- \u5b8c\u5168\u5206\u5e03\u5f0f\u96c6\u7fa4\u540d\u79f0 --&gt;\r\n\t&lt;property&gt;\r\n\t\t&lt;name&gt;dfs.nameservices&lt;\/name&gt;\r\n\t\t&lt;value&gt;mycluster&lt;\/value&gt;\r\n\t&lt;\/property&gt;\r\n\r\n\t&lt;!-- \u96c6\u7fa4\u4e2dNameNode\u8282\u70b9\u90fd\u6709\u54ea\u4e9b --&gt;\r\n\t&lt;property&gt;\r\n\t\t&lt;name&gt;dfs.ha.namenodes.mycluster&lt;\/name&gt;\r\n\t\t&lt;value&gt;nn1,nn2&lt;\/value&gt;\r\n\t&lt;\/property&gt;\r\n\r\n\t&lt;!-- nn1\u7684RPC\u901a\u4fe1\u5730\u5740 --&gt;\r\n\t&lt;property&gt;\r\n\t\t&lt;name&gt;dfs.namenode.rpc-address.mycluster.nn1&lt;\/name&gt;\r\n\t\t&lt;value&gt;bigdata166:9000&lt;\/value&gt;\r\n\t&lt;\/property&gt;\r\n\r\n\t&lt;!-- nn2\u7684RPC\u901a\u4fe1\u5730\u5740 --&gt;\r\n\t&lt;property&gt;\r\n\t\t&lt;name&gt;dfs.namenode.rpc-address.mycluster.nn2&lt;\/name&gt;\r\n\t\t&lt;value&gt;bigdata167:9000&lt;\/value&gt;\r\n\t&lt;\/property&gt;\r\n\r\n\t&lt;!-- nn1\u7684http\u901a\u4fe1\u5730\u5740 --&gt;\r\n\t&lt;property&gt;\r\n\t\t&lt;name&gt;dfs.namenode.http-address.mycluster.nn1&lt;\/name&gt;\r\n\t\t&lt;value&gt;bigdata166:50070&lt;\/value&gt;\r\n\t&lt;\/property&gt;\r\n\r\n\t&lt;!-- nn2\u7684http\u901a\u4fe1\u5730\u5740 --&gt;\r\n\t&lt;property&gt;\r\n\t\t&lt;name&gt;dfs.namenode.http-address.mycluster.nn2&lt;\/name&gt;\r\n\t\t&lt;value&gt;bigdata167:50070&lt;\/value&gt;\r\n\t&lt;\/property&gt;\r\n\r\n\t&lt;!-- \u6307\u5b9aNameNode\u5143\u6570\u636e\u5728JournalNode\u4e0a\u7684\u5b58\u653e\u4f4d\u7f6e --&gt;\r\n\t&lt;property&gt;\r\n\t\t&lt;name&gt;dfs.namenode.shared.edits.dir&lt;\/name&gt;\r\n\t &lt;value&gt;qjournal:\/\/bigdata166:8485;bigdata167:8485;bigdata168:8485\/mycluster&lt;\/value&gt;\r\n\t&lt;\/property&gt;\r\n\r\n\t&lt;!-- \u914d\u7f6e\u9694\u79bb\u673a\u5236\uff0c\u5373\u540c\u4e00\u65f6\u523b\u53ea\u80fd\u6709\u4e00\u53f0\u670d\u52a1\u5668\u5bf9\u5916\u54cd\u5e94 --&gt;\r\n\t&lt;property&gt;\r\n\t\t&lt;name&gt;dfs.ha.fencing.methods&lt;\/name&gt;\r\n\t\t&lt;value&gt;sshfence&lt;\/value&gt;\r\n\t&lt;\/property&gt;\r\n\r\n\t&lt;!-- \u4f7f\u7528\u9694\u79bb\u673a\u5236\u65f6\u9700\u8981ssh\u65e0\u79d8\u94a5\u767b\u5f55 \u6ce8\u610f\u7528\u6237\u540d--&gt;\r\n\t&lt;property&gt;\r\n\t\t&lt;name&gt;dfs.ha.fencing.ssh.private-key-files&lt;\/name&gt;\r\n\t\t&lt;value&gt;\/root\/.ssh\/id_rsa&lt;\/value&gt;\r\n\t&lt;\/property&gt;\r\n\r\n\t&lt;!-- \u58f0\u660ejournalnode\u670d\u52a1\u5668\u5b58\u50a8\u76ee\u5f55--&gt;\r\n\t&lt;property&gt;\r\n\t\t&lt;name&gt;dfs.journalnode.edits.dir&lt;\/name&gt;\r\n\t\t&lt;value&gt;\/opt\/module\/HA\/hadoop-2.8.4\/data\/jn&lt;\/value&gt;\r\n\t&lt;\/property&gt;\r\n\r\n\t&lt;!-- \u5173\u95ed\u6743\u9650\u68c0\u67e5--&gt;\r\n\t&lt;property&gt;\r\n\t\t&lt;name&gt;dfs.permissions.enable&lt;\/name&gt;\r\n\t\t&lt;value&gt;false&lt;\/value&gt;\r\n\t&lt;\/property&gt;\r\n\r\n\t&lt;!-- \u8bbf\u95ee\u4ee3\u7406\u7c7b\uff1aclient\uff0cmycluster\uff0cactive\u914d\u7f6e\u5931\u8d25\u81ea\u52a8\u5207\u6362\u5b9e\u73b0\u65b9\u5f0f--&gt;\r\n\t&lt;property&gt;\r\n  \t\t&lt;name&gt;dfs.client.failover.proxy.provider.mycluster&lt;\/name&gt;\r\n\t&lt;value&gt;org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider&lt;\/value&gt;\r\n\t&lt;\/property&gt;\r\n        &lt;!--secondary NameNode\u7684\u5730\u5740,\u7aef\u53e3\u53f7\u662f50090--&gt;\r\n        &lt;property&gt;\r\n                &lt;name&gt;dfs.namenode.secondary.http-address&lt;\/name&gt;\r\n                &lt;value&gt;bigdata167:50090&lt;\/value&gt;\r\n        &lt;\/property&gt;\r\n&lt;\/configuration&gt;\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>\u6700\u540e\uff1a\u6ce8\u610f\u542f\u52a8\u987a\u5e8f<\/p>\n<p>Journalnode\u4e3b\u8981\u662f\u7528\u6765\u505a\u6570\u636e\u4e4b\u95f4\u5171\u4eab\u7684\uff08\u4e09\u53f0\u5168\u90e8\u542f\u52a8\uff09\u3002<\/p>\n<p>sbin\/hadoop-daemon.sh start journalnode<\/p>\n<p>2\uff09\u5728[nn1]\u4e0a\uff0c\u5bf9\u5176\u8fdb\u884c\u683c\u5f0f\u5316\uff0c\u5e76\u542f\u52a8\uff1a<\/p>\n<p>bin\/hdfs namenode -format<\/p>\n<p>sbin\/hadoop-daemon.sh start namenode<\/p>\n<p>3\uff09\u5728[nn2]\u4e0a\uff0c\u540c\u6b65nn1\u7684\u5143\u6570\u636e\u4fe1\u606f\uff1a<\/p>\n<p>bin\/hdfs namenode -bootstrapStandby<\/p>\n<p>4\uff09\u542f\u52a8[nn2]\uff1a<\/p>\n<p>sbin\/hadoop-daemon.sh start namenode<\/p>\n<p>5\uff09\u67e5\u770bweb\u9875\u9762\u663e\u793a<\/p>\n<p><a href=\"http:\/\/bigdata166:50070\/\">http:\/\/bigdata166:50070\/<\/a><\/p>\n<p>http:\/\/bigdata167:50070\/<\/p>\n<p>6\uff09\u5728[nn1]\u4e0a\uff0c\u542f\u52a8\u6240\u6709datanode<\/p>\n<p>sbin\/hadoop-daemons.sh start datanode<\/p>\n<p>7\uff09\u67e5\u770b\u662f\u5426Active<\/p>\n<p>bin\/hdfs haadmin -getServiceState nn1<\/p>\n<p>8\uff09\u5c06[nn1]\u5207\u6362\u4e3aActive<\/p>\n<p>\u5207\u6362\u4e3aActive:bin\/hdfs haadmin -transitionToActive nn1<\/p>\n<p>\u5207\u6362\u4e3aStandby:bin\/hdfs haadmin -transitionToStandby nn1<\/p>\n<p>&nbsp;<\/p>\n<p>\u8bb0\u5fc6\uff1asbin\/hadoop-daemon.sh start <strong>journalnode\/namenode\/datanode<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u521b\u5efa\u4e00\u4e2aHAtest\u6587\u4ef6\uff0c\u53ef\u4ee5\u5faa\u73af\u521b\u5efa mkdir -vp \/opt\/module\/HA \u590d\u5236\u6216\u8005\u89e3\u538b\u4e00\u4e2a\u8fc7\u53bb [&hellip;]<\/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-1243","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts\/1243","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1243"}],"version-history":[{"count":5,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts\/1243\/revisions"}],"predecessor-version":[{"id":1272,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts\/1243\/revisions\/1272"}],"wp:attachment":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1243"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1243"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1243"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}