{"id":4737,"date":"2016-04-26T15:39:26","date_gmt":"2016-04-26T07:39:26","guid":{"rendered":"https:\/\/www.hmouse.tk\/?p=4737"},"modified":"2016-05-20T13:57:12","modified_gmt":"2016-05-20T05:57:12","slug":"hadoop%e9%83%a8%e7%bd%b2%e6%89%8b%e5%86%8c","status":"publish","type":"post","link":"https:\/\/www.hmouse.cn\/?p=4737","title":{"rendered":"hadoop 2.7.2 \u90e8\u7f72\u624b\u518c\uff08\u4e00\uff09"},"content":{"rendered":"<p>\u53c2\u8003url\uff1a<a href=\"http:\/\/blog.chinaunix.net\/uid-20682147-id-5520795.html\">http:\/\/blog.chinaunix.net\/uid-20682147-id-5520795.html<\/a><\/p>\n<p><a title=\"http:\/\/www.powerxing.com\/install-hadoop-in-centos\/\" href=\"http:\/\/www.powerxing.com\/install-hadoop-in-centos\/\">http:\/\/www.powerxing.com\/install-hadoop-in-centos\/<\/a>\u00a0\u00a0\u00a0\u00a0 \uff08mapreduce\u6d4b\u8bd5\u6bd4\u8f83\u8be6\u7ec6\uff09<br \/>\n\u673a\u5668\u5217\u8868<br \/>\n10.45.53.143\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop1.i.zhihuishu.com<br \/>\n10.47.109.190\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop2.i.zhihuishu.com<br \/>\n10.24.31.188\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop3.i.zhihuishu.com<br \/>\n10.168.227.144\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop4.i.zhihuishu.com<br \/>\n10.168.248.3\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop5.i.zhihuishu.com<br \/>\nNameNode<br \/>\nhadoop1.i.zhihuishu.com\u00a0\u00a0 hadoop2.i.zhihuishu.com<br \/>\nJournalNode<br \/>\nhadoop1.i.zhihuishu.com\u00a0 hadoop2.i.zhihuishu.com\u00a0 hadoop3.i.zhihuishu.com<br \/>\nDataNode<br \/>\nhadoop3.i.zhihuishu.com\u00a0 hadoop4.i.zhihuishu.com\u00a0 hadoop5.i.zhihuishu.com<br \/>\nZooKeeper<br \/>\nhadoop1.i.zhihuishu.com\u00a0 hadoop2.i.zhihuishu.com\u00a0 hadoop3.i.zhihuishu.com<br \/>\n\u76ee\u5f55\u89c4\u8303\uff1a<br \/>\nHadoop<br \/>\n\/data\/hadoop\/hadoop<br \/>\nzookeeper<br \/>\n\/data\/hadoop\/zookeeper<br \/>\nJDK<br \/>\nJAVA_HOME=\/usr\/local\/jdk1.8.0_45<\/p>\n<p>\u524d\u671f\u51c6\u5907\uff1a<br \/>\n10.45.53.143\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop1.i.zhihuishu.com\u00a0\u00a0\u00a0 rizhi143<br \/>\n10.47.109.190\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop2.i.zhihuishu.com\u00a0\u00a0\u00a0 rizhi190<br \/>\n10.24.31.188\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop3.i.zhihuishu.com\u00a0\u00a0\u00a0 rizhi188<br \/>\n10.25.2.16\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop4.i.zhihuishu.com\u00a0\u00a0\u00a0 rizhi16<br \/>\n10.168.248.3\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop5.i.zhihuishu.com\u00a0\u00a0\u00a0 rizhi3<br \/>\nhost\u5b9a\u5411\uff0c\u8bb0\u5f97\u8981\u628a hostname \u4e5f\u8981\u5b9a\u5411\uff0c\u56e0\u4e3a\u5f88\u591a\u662f\u901a\u8fc7hostname\u901a\u8baf\u7684\u3002<\/p>\n<p>ssh\u8ba4\u8bc1<br \/>\ncd ~\/.ssh\/<br \/>\nssh-keygen -t rsa<br \/>\ncat id_rsa.pub &gt;&gt; authorized_keys<br \/>\nchmod 600 .\/authorized_keys<br \/>\n\u8bb0\u5f97name1 name2\u00a0 \u6709\u5168\u90e8\u7684\u63a7\u5236ssh\u8ba4\u8bc1\u00a0 dataname \u53ea\u8981\u6709\u4e92\u76f8\u7684\u8ba4\u8bc1\u5373\u53ef<\/p>\n<p>\u6587\u4ef6\u540c\u6b65<br \/>\nmkdir -p \/data\/hadoop<br \/>\ncd \/data\/hadoop\/<br \/>\ntar -zxvf hadoop.tar.gz<\/p>\n<p>\u6dfb\u52a0 \/etc\/profile<br \/>\nexport HADOOP_HOME=\/data\/hadoop\/hadoop<br \/>\nexport HADOOP_CONF_DIR=$HADOOP_HOME\/etc\/hadoop<\/p>\n<p>\u6dfb\u52a0slave<br \/>\nvi etc\/hadoop\/slaves<br \/>\nhadoop3.i.zhihuishu.com<br \/>\nhadoop4.i.zhihuishu.com<br \/>\nhadoop5.i.zhihuishu.com<br \/>\n~<br \/>\n\u914d\u7f6e\u6587\u4ef6\u521d\u59cb\u5316<br \/>\ncd \/data\/hadoop\/hadoop<br \/>\ncp share\/doc\/hadoop\/hadoop-project-dist\/hadoop-common\/core-default.xml etc\/hadoop\/core-site.xml<br \/>\ncp share\/doc\/hadoop\/hadoop-project-dist\/hadoop-hdfs\/hdfs-default.xml etc\/hadoop\/hdfs-site.xml<br \/>\ncp share\/doc\/hadoop\/hadoop-yarn\/hadoop-yarn-common\/yarn-default.xml etc\/hadoop\/yarn-site.xml<br \/>\ncp share\/doc\/hadoop\/hadoop-mapreduce-client\/hadoop-mapreduce-client-core\/mapred-default.xml etc\/hadoop\/mapred-site.xml<\/p>\n<p>cd \/data\/hadoop\/hadoop\/etc\/hadoop<br \/>\nwget -O hdfs-site.xml\u00a0 wget <a href=\"http:\/\/222.66.154.110\/install\/hadoop\/hdfs-site.xml\">http:\/\/222.66.154.110\/install\/hadoop\/hdfs-site.xml<\/a><br \/>\nwget -O core-site.xml\u00a0 wget <a href=\"http:\/\/222.66.154.110\/install\/hadoop\/core-site.xml\">http:\/\/222.66.154.110\/install\/hadoop\/core-site.xml<\/a><br \/>\nwget -O yarn-site.xml\u00a0 wget <a href=\"http:\/\/222.66.154.110\/install\/hadoop\/yarn-site.xml\">http:\/\/222.66.154.110\/install\/hadoop\/yarn-site.xml<\/a><br \/>\nwget -O mapred-site.xml\u00a0 wget <a href=\"http:\/\/222.66.154.110\/install\/hadoop\/mapred-site.xml\">http:\/\/222.66.154.110\/install\/hadoop\/mapred-site.xml<\/a><\/p>\n<p>mkdir -p \/data\/hadoop\/hadoop\/tmp<br \/>\nmkdir -p \/data\/hadoop\/hadoop\/tmp\/dfs\/name<\/p>\n<p>&nbsp;<\/p>\n<p>\u914d\u7f6e\u6587\u4ef6\u5728\u9644\u4ef6\uff0c\u53ef\u4ee5\u53c2\u8003\u9644\u4ef6\u3002<\/p>\n<p><a href=\"https:\/\/www.hmouse.cn\/?attachment_id=4742\" rel=\"attachment wp-att-4742\">hadoop-xml<\/a><\/p>\n<p>QJM\u7684\u914d\u7f6e\u53c2\u7167\u7684\u5b98\u65b9\u6587\u6863\uff1a<\/p>\n<p><a href=\"http:\/\/hadoop.apache.org\/docs\/stable\/hadoop-project-dist\/hadoop-hdfs\/HDFSHighAvailabilityWithQJM.html\">http:\/\/hadoop.apache.org\/docs\/stable\/hadoop-project-dist\/hadoop-hdfs\/HDFSHighAvailabilityWithQJM.html<\/a>\u3002<\/p>\n<h4>hdfs-site.xml\u8be6\u7ec6\u914d\u7f6e\u53ef\u53c2\u8003\uff1a<\/h4>\n<p><a href=\"http:\/\/hadoop.apache.org\/docs\/current\/hadoop-project-dist\/hadoop-hdfs\/hdfs-default.xml\">http:\/\/hadoop.apache.org\/docs\/current\/hadoop-project-dist\/hadoop-hdfs\/hdfs-default.xml<\/a>\u3002<\/p>\n<p>yarn.nodemanager.hostname\u5982\u679c\u914d\u7f6e\u6210\u5177\u4f53\u7684IP\uff0c\u598210.12.154.79\uff0c\u5219\u4f1a\u5bfc\u81f4\u6bcf\u4e2aNodeManager\u7684\u914d\u7f6e\u4e0d\u540c\u3002\u8be6\u7ec6\u914d\u7f6e\u53ef\u53c2\u8003\uff1a<\/p>\n<p><a href=\"http:\/\/hadoop.apache.org\/docs\/current\/hadoop-yarn\/hadoop-yarn-common\/yarn-default.xml\">http:\/\/hadoop.apache.org\/docs\/current\/hadoop-yarn\/hadoop-yarn-common\/yarn-default.xml<\/a>\u3002<\/p>\n<p>Yarn HA\u7684\u914d\u7f6e\u53ef\u4ee5\u53c2\u8003\uff1a<\/p>\n<p><a href=\"https:\/\/hadoop.apache.org\/docs\/current\/hadoop-yarn\/hadoop-yarn-site\/ResourceManagerHA.html\">https:\/\/hadoop.apache.org\/docs\/current\/hadoop-yarn\/hadoop-yarn-site\/ResourceManagerHA.html<\/a>\u3002<\/p>\n<p>\u9047\u5230\u7684\u95ee\u9898\uff1a<\/p>\n<p><span style=\"color: #ff0000;\">1\uff1aNamenode2\u00a0 \u505aHA\u542f\u52a8\u9519\u4e86\uff0c\u8001\u662f\u62a5\u65e0\u6cd5\u6ce8\u518cnn2\u3002<\/span><\/p>\n<p><span style=\"color: #ff0000;\">2\uff1aproxy\u6ca1\u6709\u914d\u7f6e\uff0c\u9020\u6210\u4e86\u6ca1\u529e\u6cd5\u8bbf\u95eezhscluster\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h3>9. \u542f\u52a8\u987a\u5e8f<\/h3>\n<p>Zookeeper -&gt; JournalNode -&gt; \u683c\u5f0f\u5316NameNode -&gt; \u521d\u59cb\u5316JournalNode<\/p>\n<p>-&gt; \u521b\u5efa\u547d\u540d\u7a7a\u95f4\uff08zkfc\uff09 -&gt; NameNode -&gt; DataNode -&gt; ResourceManager -&gt; NodeManager\u3002<\/p>\n<p>\u4f46\u8bf7\u6ce8\u610f\u9996\u6b21\u542f\u52a8NameNode\u4e4b\u524d\uff0c\u5f97\u5148\u505aformat\uff0c\u4e5f\u8bf7\u6ce8\u610f\u5907NameNode\u7684\u542f\u52a8\u65b9\u6cd5\u3002<\/p>\n<h3><a name=\"_Toc32392\"><\/a>10. \u542f\u52a8HDFS<\/h3>\n<p>\u5728\u542f\u52a8HDFS\u4e4b\u524d\uff0c\u9700\u8981\u5148\u5b8c\u6210\u5bf9NameNode\u7684\u683c\u5f0f\u5316\u3002<\/p>\n<h4><a name=\"_Toc309\"><\/a>10.1. \u521b\u5efa\u597d\u76ee\u5f55<\/h4>\n<p>mkdir -p \/data\/hadoop\/hadoop-2.7.2\/tmp\/dfs\/name<\/p>\n<h4><a name=\"_Toc6320\"><\/a>10.2. \u542f\u52a8\u597dzookeeper<\/h4>\n<p>.\/zkServer.sh start<\/p>\n<p>\u6ce8\u610f\u5728\u542f\u52a8\u5176\u5b83\u4e4b\u524d\u5148\u542f\u52a8zookeeper\u3002<\/p>\n<h4><a name=\"_Toc20270\"><\/a>10.3. \u521b\u5efa\u547d\u540d\u7a7a\u95f4<\/h4>\n<p>\u5728\u5176\u4e2d\u4e00\u4e2anamenode\u4e0a\u6267\u884c\uff1a<\/p>\n<p>.\/hdfs zkfc -formatZK<\/p>\n<p>\u6ce8\u610f\uff0c\u8fd9\u4e00\u6b65\u8981\u5728\u521d\u59cb\u5316\u547d\u540d\u7a7a\u95f4\u4e4b\u540e\u6267\u884c\u3002<\/p>\n<h4><a name=\"_Toc25237\"><\/a>10.4. \u542f\u52a8\u6240\u6709JournalNode<\/h4>\n<p>NameNode\u5c06\u5143\u6570\u636e\u64cd\u4f5c\u65e5\u5fd7\u8bb0\u5f55\u5728JournalNode\u4e0a\uff0c\u4e3b\u5907NameNode\u901a\u8fc7\u8bb0\u5f55\u5728JouralNode\u4e0a\u7684\u65e5\u5fd7\u5b8c\u6210\u5143\u6570\u636e\u540c\u6b65\u3002<\/p>\n<p>\u5728\u6240\u6709JournalNode\u4e0a\u6267\u884c\uff08\u6ce8\u610f\u662f\u4e24\u4e2a\u53c2\u6570\uff0c\u5728\u201chdfs namenode -format\u201d\u4e4b\u540e\u505a\u8fd9\u4e00\u6b65\uff09\uff1a<\/p>\n<p>.\/hadoop-daemon.sh start journalnode<\/p>\n<p>\u6ce8\u610f\uff0c\u5728\u6267\u884c\u201chdfs namenode -format\u201d\u4e4b\u524d\uff0c\u5fc5\u987b\u5148\u542f\u52a8\u597dJournalNode\uff0c\u800cformat\u53c8\u5fc5\u987b\u5728\u542f\u52a8namenode\u4e4b\u524d\u3002<\/p>\n<h4><a name=\"_Toc15020\"><\/a>10.5. \u521d\u59cb\u5316JournalNode<\/h4>\n<p>\u5982\u679c\u662f\u975eHA\u8f6cHA\u624d\u9700\u8981\u8fd9\u4e00\u6b65\uff0c\u5728\u5176\u4e2d\u4e00\u4e2aJournalNode\u4e0a\u6267\u884c\uff1a<\/p>\n<p>.\/hdfs namenode -initializeSharedEdits<\/p>\n<p>\u6b64\u547d\u4ee4\u9ed8\u8ba4\u662f\u4ea4\u4e92\u5f0f\u7684\uff0c\u52a0\u4e0a\u53c2\u6570-force\u8f6c\u6210\u975e\u4ea4\u4e92\u5f0f\u3002<\/p>\n<p>\u5728\u6240\u6709JournalNode\u521b\u5efa\u5982\u4e0b\u76ee\u5f55\uff1a<\/p>\n<p>mkdir -p \/data\/hadoop\/hadoop\/journal\/mycluster\/current<\/p>\n<h4><a name=\"_Toc5807\"><\/a>10.6. \u683c\u5f0f\u5316NameNode<\/h4>\n<p>\u6ce8\u610f\u53ea\u6709\u65b0\u7684\uff0c\u624d\u9700\u8981\u505a\u8fd9\u4e00\u6b65\uff0c\u800c\u4e14\u53ea\u9700\u8981\u5728\u4e3bNameNode\u4e0a\u6267\u884c\u3002<\/p>\n<p>1) \u8fdb\u5165$HADOOP_HOME\/bin\u76ee\u5f55<\/p>\n<p>2) \u8fdb\u884c\u683c\u5f0f\u5316\uff1a.\/hdfs namenode -format<\/p>\n<p>\u5982\u679c\u5b8c\u6210\u6709\uff0c\u8f93\u51fa\u5305\u542b\u201cINFO util.ExitUtil: Exiting with status 0\u201d\uff0c\u5219\u8868\u793a\u683c\u5f0f\u5316\u6210\u529f\u3002<\/p>\n<p>\u5728\u8fdb\u884c\u683c\u5f0f\u5316\u65f6\uff0c\u5982\u679c\u6ca1\u6709\u5728\/etc\/hosts\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4e3b\u673a\u540d\u548cIP\u7684\u6620\u5c04\uff1a\u201c172.25.40.171\u00a0\u00a0 VM-40-171-sles10-64\u201d\uff0c\u5219\u4f1a\u62a5\u5982\u4e0b\u6240\u793a\u9519\u8bef\uff1a<\/p>\n<p>14\/04\/17 03:44:09 WARN net.DNS: Unable to determine local hostname -falling back to &#8220;localhost&#8221;<\/p>\n<p>java.net.UnknownHostException: VM-40-171-sles10-64: VM-40-171-sles10-64: unknown error<\/p>\n<p>at java.net.InetAddress.getLocalHost(InetAddress.java:1484)<\/p>\n<p>at org.apache.hadoop.net.DNS.resolveLocalHostname(DNS.java:264)<\/p>\n<p>at org.apache.hadoop.net.DNS.(DNS.java:57)<\/p>\n<p>at org.apache.hadoop.hdfs.server.namenode.NNStorage.newBlockPoolID(NNStorage.java:945)<\/p>\n<p>at org.apache.hadoop.hdfs.server.namenode.NNStorage.newNamespaceInfo(NNStorage.java:573)<\/p>\n<p>at org.apache.hadoop.hdfs.server.namenode.FSImage.format(FSImage.java:144)<\/p>\n<p>at org.apache.hadoop.hdfs.server.namenode.NameNode.format(NameNode.java:845)<\/p>\n<p>at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1256)<\/p>\n<p>at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1370)<\/p>\n<p>Caused by: java.net.UnknownHostException: VM-40-171-sles10-64: unknown error<\/p>\n<p>at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)<\/p>\n<p>at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:907)<\/p>\n<p>at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1302)<\/p>\n<p>at java.net.InetAddress.getLocalHost(InetAddress.java:1479)<\/p>\n<p>&#8230; 8 more<\/p>\n<h4><a name=\"_Toc17469\"><\/a>10.7. \u542f\u52a8\u4e3bNameNode<\/h4>\n<p>1) \u8fdb\u5165$HADOOP_HOME\/sbin\u76ee\u5f55<\/p>\n<p>2) \u542f\u52a8\u4e3bNameNode\uff1a<\/p>\n<p>.\/hadoop-daemon.sh start namenode<\/p>\n<p>\u542f\u52a8\u65f6\uff0c\u9047\u5230\u5982\u4e0b\u6240\u793a\u7684\u9519\u8bef\uff0c\u5219\u8868\u793aNameNode\u4e0d\u80fd\u514d\u5bc6\u7801\u767b\u5f55\u81ea\u5df1\u3002\u5982\u679c\u4e4b\u524d\u4f7f\u7528IP\u53ef\u4ee5\u514d\u5bc6\u7801\u767b\u5f55\u81ea\u5df1\uff0c\u5219\u539f\u56e0\u4e00\u822c\u662f\u56e0\u4e3a\u6ca1\u6709\u4f7f\u7528\u4e3b\u673a\u540d\u767b\u5f55\u8fc7\u81ea\u5df1\uff0c\u56e0\u6b64\u89e3\u51b3\u529e\u6cd5\u662f\u4f7f\u7528\u4e3b\u673a\u540dSSH\u4e00\u4e0b\uff0c\u6bd4\u5982\uff1assh hadoop@VM_40_171_sles10_64\uff0c\u7136\u540e\u518d\u542f\u52a8\u3002<\/p>\n<p>Starting namenodes on [VM_40_171_sles10_64]<\/p>\n<p>VM_40_171_sles10_64: Host key not found from database.<\/p>\n<p>VM_40_171_sles10_64: Key fingerprint:<\/p>\n<p>VM_40_171_sles10_64: xofiz-zilip-tokar-rupyb-tufer-tahyc-sibah-kyvuf-palik-hazyt-duxux<\/p>\n<p>VM_40_171_sles10_64: You can get a public key&#8217;s fingerprint by running<\/p>\n<p>VM_40_171_sles10_64: % ssh-keygen -F publickey.pub<\/p>\n<p>VM_40_171_sles10_64: on the keyfile.<\/p>\n<p>VM_40_171_sles10_64: warning: tcgetattr failed in ssh_rl_set_tty_modes_for_fd: fd 1: Invalid argument<\/p>\n<h4><a name=\"_Toc27524\"><\/a>10.8. \u542f\u52a8\u5907NameNode<\/h4>\n<p>1) .\/hdfs namenode -bootstrapStandby<\/p>\n<p>2) .\/hadoop-daemon.sh start namenode<\/p>\n<p>\u5982\u679c\u6ca1\u6709\u6267\u884c\u7b2c1\u6b65\uff0c\u76f4\u63a5\u542f\u52a8\u4f1a\u9047\u5230\u5982\u4e0b\u9519\u8bef\uff1a<\/p>\n<p>No valid image files found<\/p>\n<p>\u6216\u8005\u5728\u8be5NameNode\u65e5\u5fd7\u4f1a\u53d1\u73b0\u5982\u4e0b\u9519\u8bef\uff1a<\/p>\n<p>2016-04-08 14:08:39,745 WARN org.apache.hadoop.hdfs.server.namenode.FSNamesystem: Encountered exception loading fsimage<\/p>\n<p>java.io.IOException: NameNode is not formatted.<\/p>\n<h4><a name=\"_Toc18382\"><\/a>10.9. \u542f\u52a8\u4e3b\u5907\u5207\u6362\u8fdb\u7a0b<\/h4>\n<p>\u5728\u6240\u6709NameNode\u4e0a\u542f\u52a8\u4e3b\u5907\u5207\u6362\u8fdb\u7a0b\uff1a<\/p>\n<p>.\/hadoop-daemon.sh start zkfc<\/p>\n<p>\u53ea\u6709\u542f\u52a8\u4e86DFSZKFailoverController\u8fdb\u7a0b\uff0cHDFS\u624d\u80fd\u81ea\u52a8\u5207\u6362\u4e3b\u5907\u3002<\/p>\n<p>\u6ce8\uff1azkfc\u662fzookeeper failover controller\u7684\u7f29\u5199\u3002<\/p>\n<h4><a name=\"_Toc22206\"><\/a>10.10. \u542f\u52a8\u6240\u6709DataNode<\/h4>\n<p>\u5728\u5404\u4e2aDataNode\u4e0a\u5206\u522b\u6267\u884c\uff1a<\/p>\n<p>.\/hadoop-daemon.sh start datanode<\/p>\n<p>\u5982\u679c\u6709\u53d1\u73b0DataNode\u8fdb\u7a0b\u5e76\u6ca1\u6709\u8d77\u6765\uff0c\u53ef\u4ee5\u8bd5\u8bd5\u5220\u9664logs\u76ee\u5f55\u4e0b\u7684DataNode\u65e5\u5fd7\uff0c\u518d\u5f97\u542f\u770b\u770b\u3002<\/p>\n<h4><a name=\"_Toc12278\"><\/a>10.11. \u68c0\u67e5\u542f\u52a8\u662f\u5426\u6210\u529f<\/h4>\n<p>1) \u4f7f\u7528JDK\u63d0\u4f9b\u7684jps\u547d\u4ee4\uff0c\u67e5\u770b\u76f8\u5e94\u7684\u8fdb\u7a0b\u662f\u5426\u5df2\u542f\u52a8<\/p>\n<p>2) \u68c0\u67e5$HADOOP_HOME\/logs\u76ee\u5f55\u4e0b\u7684log\u548cout\u6587\u4ef6\uff0c\u770b\u770b\u662f\u5426\u6709\u5f02\u5e38\u4fe1\u606f\u3002<\/p>\n<p>\u542f\u52a8\u540enn1\u548cnn2\u90fd\u5904\u4e8e\u5907\u673a\u72b6\u6001\uff0c\u5c06nn1\u5207\u6362\u4e3a\u4e3b\u673a\uff1a<\/p>\n<p>.\/hdfs haadmin -transitionToActive nn1<\/p>\n<h5><a name=\"_Toc32232\"><\/a>10.11.1. DataNode<\/h5>\n<p>\u6267\u884cjps\u547d\u4ee4\uff08\u6ce8\uff1ajps\u662fjdk\u4e2d\u7684\u4e00\u4e2a\u547d\u4ee4\uff0c\u4e0d\u662fjre\u4e2d\u7684\u547d\u4ee4\uff09\uff0c\u53ef\u770b\u5230DataNode\u8fdb\u7a0b\uff1a<\/p>\n<p>$ jps<\/p>\n<p>18669 DataNode<\/p>\n<p>24542 Jps<\/p>\n<h5><a name=\"_Toc1075\"><\/a>10.11.2. NameNode<\/h5>\n<p>\u6267\u884cjps\u547d\u4ee4\uff0c\u53ef\u770b\u5230NameNode\u8fdb\u7a0b\uff1a<\/p>\n<p>$ jps<\/p>\n<p>18669 NameNode<\/p>\n<p>24542 Jps<\/p>\n<h4><a name=\"_Toc27166\"><\/a>10.12. \u6267\u884cHDFS\u547d\u4ee4<\/h4>\n<p>\u6267\u884cHDFS\u547d\u4ee4\uff0c\u4ee5\u8fdb\u4e00\u6b65\u68c0\u9a8c\u662f\u5426\u5df2\u7ecf\u5b89\u88c5\u6210\u529f\u548c\u914d\u7f6e\u597d\u3002\u5173\u4e8eHDFS\u547d\u4ee4\u7684\u7528\u6cd5\uff0c\u76f4\u63a5\u8fd0\u884c\u547d\u4ee4hdfs\u6216hdfs dfs\uff0c\u5373\u53ef\u770b\u5230\u76f8\u5173\u7684\u7528\u6cd5\u8bf4\u660e\u3002<\/p>\n<h5><a name=\"_Toc12898\"><\/a>10.12.1. \u67e5\u770bDataNode\u662f\u5426\u6b63\u5e38\u542f\u52a8<\/h5>\n<p>hdfs dfsadmin -report<\/p>\n<p>\u6ce8\u610f\u5982\u679ccore-site.xml\u4e2d\u7684\u914d\u7f6e\u9879fs.default.name\u7684\u503c\u4e3afile:\/\/\/\uff0c\u5219\u4f1a\u62a5\uff1a<\/p>\n<p>report: FileSystem file:\/\/\/ is not an HDFS file system<\/p>\n<p>Usage: hdfs dfsadmin [-report] [-live] [-dead] [-decommissioning]<\/p>\n<p>\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ea\u9700\u8981\u5c06fs.default.name\u7684\u503c\u8bbe\u7f6e\u4e3a\u548cfs.defaultFS\u76f8\u540c\u7684\u503c\u3002<\/p>\n<h5><a name=\"_Toc32312\"><\/a>10.12.2. \u67e5\u770bNameNode\u7684\u4e3b\u5907\u72b6\u6001<\/h5>\n<p>\u5982\u67e5\u770bNameNode1\u548cNameNode2\u5206\u522b\u662f\u4e3b\u8fd8\u662f\u5907\uff1a<\/p>\n<p>$ hdfs haadmin -getServiceState nm1<\/p>\n<p>standby<\/p>\n<p>$ hdfs haadmin -getServiceState nm2<\/p>\n<p>active<\/p>\n<h5><a name=\"_Toc13507\"><\/a>10.12.3. hdfs dfs ls<\/h5>\n<p>\u201chdfs dfs -ls\u201d\u5e26\u4e00\u4e2a\u53c2\u6570\uff0c\u5982\u679c\u53c2\u6570\u4ee5\u201chdfs:\/\/URI\u201d\u6253\u5934\u8868\u793a\u8bbf\u95eeHDFS\uff0c\u5426\u5219\u76f8\u5f53\u4e8els\u3002\u5176\u4e2dURI\u4e3aNameNode\u7684IP\u6216\u4e3b\u673a\u540d\uff0c\u53ef\u4ee5\u5305\u542b\u7aef\u53e3\u53f7\uff0c\u5373hdfs-site.xml\u4e2d\u201cdfs.namenode.rpc-address\u201d\u6307\u5b9a\u7684\u503c\u3002<\/p>\n<p>\u201chdfs dfs -ls\u201d\u8981\u6c42\u9ed8\u8ba4\u7aef\u53e3\u4e3a8020\uff0c\u5982\u679c\u914d\u7f6e\u62109000\uff0c\u5219\u9700\u8981\u6307\u5b9a\u7aef\u53e3\u53f7\uff0c\u5426\u5219\u4e0d\u7528\u6307\u5b9a\u7aef\u53e3\uff0c\u8fd9\u4e00\u70b9\u7c7b\u4f3c\u4e8e\u6d4f\u89c8\u5668\u8bbf\u95ee\u4e00\u4e2aURL\u3002\u793a\u4f8b\uff1a<\/p>\n<p>&gt; hdfs dfs -ls hdfs:\/\/172.25.40.171:9001\/<\/p>\n<p>9001\u540e\u9762\u7684\u659c\u6760\/\u662f\u548c\u5fc5\u987b\u7684\uff0c\u5426\u5219\u88ab\u5f53\u4f5c\u6587\u4ef6\u3002\u5982\u679c\u4e0d\u6307\u5b9a\u7aef\u53e3\u53f79001\uff0c\u5219\u4f7f\u7528\u9ed8\u8ba4\u76848020\uff0c\u201c172.25.40.171:9001\u201d\u7531hdfs-site.xml\u4e2d\u201cdfs.namenode.rpc-address\u201d\u6307\u5b9a\u3002<\/p>\n<p>\u4e0d\u96be\u770b\u51fa\u201chdfs dfs -ls\u201d\u53ef\u4ee5\u64cd\u4f5c\u4e0d\u540c\u7684HDFS\u96c6\u7fa4\uff0c\u53ea\u9700\u8981\u6307\u5b9a\u4e0d\u540c\u7684URI\u3002<\/p>\n<p>\u6587\u4ef6\u4e0a\u4f20\u540e\uff0c\u88ab\u5b58\u50a8\u5728DataNode\u7684data\u76ee\u5f55\u4e0b\uff08\u7531DataNode\u7684hdfs-site.xml\u4e2d\u7684\u5c5e\u6027\u201cdfs.datanode.data.dir\u201d\u6307\u5b9a\uff09\uff0c\u5982\uff1a<\/p>\n<p>$HADOOP_HOME\/data\/current\/BP-139798373-172.25.40.171-1397735615751\/current\/finalized\/blk_1073741825<\/p>\n<p>\u6587\u4ef6\u540d\u4e2d\u7684\u201cblk\u201d\u662fblock\uff0c\u5373\u5757\u7684\u610f\u601d\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0bblk_1073741825\u5373\u4e3a\u6587\u4ef6\u7684\u4e00\u4e2a\u5b8c\u6574\u5757\uff0cHadoop\u672a\u5bf9\u5b83\u8fdb\u989d\u5916\u5904\u7406\u3002<\/p>\n<h5><a name=\"_Toc27436\"><\/a>10.12.4. hdfs dfs -put<\/h5>\n<p>\u4e0a\u4f20\u6587\u4ef6\u547d\u4ee4\uff0c\u793a\u4f8b\uff1a<\/p>\n<p>&gt; hdfs dfs -put \/etc\/SuSE-release hdfs:\/\/172.25.40.171:9001\/<\/p>\n<h5><a name=\"_Toc320\"><\/a>10.12.5. hdfs dfs -rm<\/h5>\n<p>\u5220\u9664\u6587\u4ef6\u547d\u4ee4\uff0c\u793a\u4f8b\uff1a<\/p>\n<p>&gt; hdfs dfs -rm hdfs:\/\/172.25.40.171:9001\/SuSE-release<\/p>\n<p>Deleted hdfs:\/\/172.25.40.171:9001\/SuSE-release<\/p>\n<h5><a name=\"_Toc31944\"><\/a>10.12.6. \u65b0NameNode\u5982\u4f55\u52a0\u5165\uff1f<\/h5>\n<p>\u5f53\u6709NameNode\u673a\u5668\u635f\u574f\u65f6\uff0c\u5fc5\u7136\u5b58\u5728\u65b0NameNode\u6765\u66ff\u4ee3\u3002\u628a\u914d\u7f6e\u4fee\u6539\u6210\u6307\u5411\u65b0NameNode\uff0c\u7136\u540e\u4ee5\u5907\u673a\u5f62\u5f0f\u542f\u52a8\u65b0NameNode\uff0c\u8fd9\u6837\u65b0\u7684NameNode\u5373\u52a0\u5165\u5230Cluster\u4e2d\uff1a<\/p>\n<p>1) .\/hdfs namenode -bootstrapStandby<\/p>\n<p>2) .\/hadoop-daemon.sh start namenode<\/p>\n<h5><a name=\"_Toc21462\"><\/a>10.12.7. HDFS\u53ea\u5141\u8bb8\u6709\u4e00\u4e3b\u4e00\u5907\u4e24\u4e2aNameNode<\/h5>\n<p>\u5982\u679c\u8bd5\u56fe\u914d\u7f6e\u4e09\u4e2aNameNode\uff0c\u5982\uff1a<\/p>\n<p>dfs.ha.namenodes.test<\/p>\n<p>nm1,nm2,nm3<\/p>\n<p>The prefix for a given nameservice, contains a comma-separated<\/p>\n<p>list of namenodes for a given nameservice (eg EXAMPLENAMESERVICE).<\/p>\n<p>\u5219\u8fd0\u884c\u201chdfs namenode -bootstrapStandby\u201d\u65f6\u4f1a\u62a5\u5982\u4e0b\u9519\u8bef\uff0c\u8868\u793a\u5728\u540c\u4e00NameSpace\u5185\u4e0d\u80fd\u8d85\u8fc72\u4e2aNameNode\uff1a<\/p>\n<p>16\/04\/11 09:51:57 ERROR namenode.NameNode: Failed to start namenode.<\/p>\n<p>java.io.IOException: java.lang.IllegalArgumentException: Expected exactly 2 NameNodes in namespace &#8216;test&#8217;. Instead, got only 3 (NN ids were &#8216;nm1&#8242;,&#8217;nm2&#8242;,&#8217;nm3&#8217;<\/p>\n<p>at org.apache.hadoop.hdfs.server.namenode.ha.BootstrapStandby.run(BootstrapStandby.java:425)<\/p>\n<p>at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1454)<\/p>\n<p>at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1554)<\/p>\n<p>Caused by: java.lang.IllegalArgumentException: Expected exactly 2 NameNodes in namespace &#8216;test&#8217;. Instead, got only 3 (NN ids were &#8216;nm1&#8242;,&#8217;nm2&#8242;,&#8217;nm3&#8217;<\/p>\n<p>at com.google.common.base.Preconditions.checkArgument(Preconditions.java:115)<\/p>\n<h5><a name=\"_Toc10478\"><\/a>10.12.8. \u5b58\u50a8\u5747\u8861start-balancer.sh<\/h5>\n<p>\u793a\u4f8b\uff1astart-balancer.sh \u2013t 10%<\/p>\n<p>10%\u8868\u793a\u673a\u5668\u4e0e\u673a\u5668\u4e4b\u95f4\u78c1\u76d8\u4f7f\u7528\u7387\u504f\u5dee\u5c0f\u4e8e10%\u65f6\u8ba4\u4e3a\u5747\u8861\uff0c\u5426\u5219\u505a\u5747\u8861\u642c\u52a8\u3002\u201cstart-balancer.sh\u201d\u8c03\u7528\u201chdfs start balancer\u201d\u6765\u505a\u5747\u8861\uff0c\u53ef\u4ee5\u8c03\u7528stop-balancer.sh\u505c\u6b62\u5747\u8861\u3002<\/p>\n<p>\u5747\u8861\u8fc7\u7a0b\u975e\u5e38\u6162\uff0c\u4f46\u662f\u5747\u8861\u8fc7\u7a0b\u4e2d\uff0c\u4ecd\u80fd\u591f\u6b63\u5e38\u8bbf\u95eeHDFS\uff0c\u5305\u62ec\u5f80HDFS\u4e0a\u4f20\u6587\u4ef6\u3002<\/p>\n<p>[VM2016@hadoop-030 \/data4\/hadoop\/sbin]$ hdfs balancer # \u53ef\u4ee5\u6539\u4e3a\u8c03\u7528start-balancer.sh<\/p>\n<p>16\/04\/08 14:26:55 INFO balancer.Balancer: namenodes\u00a0 = [hdfs:\/\/test] \/\/ test\u4e3aHDFS\u7684cluster\u540d<\/p>\n<p>16\/04\/08 14:26:55 INFO balancer.Balancer: parameters = Balancer.Parameters[BalancingPolicy.Node, threshold=10.0, max idle iteration = 5, number of nodes to be excluded = 0, number of nodes to be included = 0]<\/p>\n<p>Time Stamp\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Iteration#\u00a0 Bytes Already Moved\u00a0 Bytes Left To Move\u00a0 Bytes Being Moved<\/p>\n<p>16\/04\/08 14:26:56 INFO net.NetworkTopology: Adding a new node: \/default-rack\/192.168.1.231:50010<\/p>\n<p>16\/04\/08 14:26:56 INFO net.NetworkTopology: Adding a new node: \/default-rack\/192.168.1.229:50010<\/p>\n<p>16\/04\/08 14:26:56 INFO net.NetworkTopology: Adding a new node: \/default-rack\/192.168.1.213:50010<\/p>\n<p>16\/04\/08 14:26:56 INFO net.NetworkTopology: Adding a new node: \/default-rack\/192.168.1.208:50010<\/p>\n<p>16\/04\/08 14:26:56 INFO net.NetworkTopology: Adding a new node: \/default-rack\/192.168.1.232:50010<\/p>\n<p>16\/04\/08 14:26:56 INFO net.NetworkTopology: Adding a new node: \/default-rack\/192.168.1.207:50010<\/p>\n<p>16\/04\/08 14:26:56 INFO balancer.Balancer: 5 over-utilized: [192.168.1.231:50010:DISK, 192.168.1.229:50010:DISK, 192.168.1.213:50010:DISK, 192.168.1.208:50010:DISK, 192.168.1.232:50010:DISK]<\/p>\n<p>16\/04\/08 14:26:56 INFO balancer.Balancer: 1 underutilized\uff08\u672a\u5145\u5206\u5229\u7528\u7684\uff09: [192.168.1.207:50010:DISK] # \u6570\u636e\u5c06\u79fb\u5411\u8be5\u8282\u70b9<\/p>\n<p>16\/04\/08 14:26:56 INFO balancer.Balancer: Need to move 816.01 GB to make the cluster balanced. # \u9700\u8981\u79fb\u52a8816.01G\u6570\u636e\u8fbe\u5230\u5e73\u8861<\/p>\n<p>16\/04\/08 14:26:56 INFO balancer.Balancer: Decided to move 10 GB bytes from 192.168.1.231:50010:DISK to 192.168.1.207:50010:DISK # \u4ece192.168.1.231\u79fb\u52a810G\u6570\u636e\u5230192.168.1.207<\/p>\n<p>16\/04\/08 14:26:56 INFO balancer.Balancer: Will move 10 GB in this iteration<\/p>\n<p>16\/04\/08 14:32:58 INFO balancer.Dispatcher: Successfully moved blk_1073749366_8542 with size=77829046 from 192.168.1.231:50010:DISK to 192.168.1.207:50010:DISK through 192.168.1.213:50010<\/p>\n<p>16\/04\/08 14:32:59 INFO balancer.Dispatcher: Successfully moved blk_1073749386_8562 with size=77829046 from 192.168.1.231:50010:DISK to 192.168.1.207:50010:DISK through 192.168.1.231:50010<\/p>\n<p>16\/04\/08 14:33:34 INFO balancer.Dispatcher: Successfully moved blk_1073749378_8554 with size=77829046 from 192.168.1.231:50010:DISK to 192.168.1.207:50010:DISK through 192.168.1.231:50010<\/p>\n<p>16\/04\/08 14:34:38 INFO balancer.Dispatcher: Successfully moved blk_1073749371_8547 with size=134217728 from 192.168.1.231:50010:DISK to 192.168.1.207:50010:DISK through 192.168.1.213:50010<\/p>\n<p>16\/04\/08 14:34:54 INFO balancer.Dispatcher: Successfully moved blk_1073749395_8571 with size=134217728 from 192.168.1.231:50010:DISK to 192.168.1.207:50010:DISK through 192.168.1.231:50010<\/p>\n<p>Apr 8, 2016 2:35:01 PM\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 478.67 MB\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 816.01 GB\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 10 GB<\/p>\n<p>16\/04\/08 14:35:10 INFO net.NetworkTopology: Adding a new node: \/default-rack\/192.168.1.213:50010<\/p>\n<p>16\/04\/08 14:35:10 INFO net.NetworkTopology: Adding a new node: \/default-rack\/192.168.1.229:50010<\/p>\n<p>16\/04\/08 14:35:10 INFO net.NetworkTopology: Adding a new node: \/default-rack\/192.168.1.232:50010<\/p>\n<p>16\/04\/08 14:35:10 INFO net.NetworkTopology: Adding a new node: \/default-rack\/192.168.1.231:50010<\/p>\n<p>16\/04\/08 14:35:10 INFO net.NetworkTopology: Adding a new node: \/default-rack\/192.168.1.208:50010<\/p>\n<p>16\/04\/08 14:35:10 INFO net.NetworkTopology: Adding a new node: \/default-rack\/192.168.1.207:50010<\/p>\n<p>16\/04\/08 14:35:10 INFO balancer.Balancer: 5 over-utilized: [192.168.1.213:50010:DISK, 192.168.1.229:50010:DISK, 192.168.1.232:50010:DISK, 192.168.1.231:50010:DISK, 192.168.1.208:50010:DISK]<\/p>\n<p>16\/04\/08 14:35:10 INFO balancer.Balancer: 1 underutilized\uff08\u672a\u5145\u5206\u5229\u7528\u7684\uff09: [192.168.1.207:50010:DISK]<\/p>\n<p>16\/04\/08 14:35:10 INFO balancer.Balancer: Need to move 815.45 GB to make the cluster balanced.<\/p>\n<p>16\/04\/08 14:35:10 INFO balancer.Balancer: Decided to move 10 GB bytes from 192.168.1.213:50010:DISK to 192.168.1.207:50010:DISK<\/p>\n<p>16\/04\/08 14:35:10 INFO balancer.Balancer: Will move 10 GB in this iteration<\/p>\n<p>16\/04\/08 14:41:18 INFO balancer.Dispatcher: Successfully moved blk_1073760371_19547 with size=77829046 from 192.168.1.213:50010:DISK to 192.168.1.207:50010:DISK through 192.168.1.213:50010<\/p>\n<p>16\/04\/08 14:41:19 INFO balancer.Dispatcher: Successfully moved blk_1073760385_19561 with size=77829046 from 192.168.1.213:50010:DISK to 192.168.1.207:50010:DISK through 192.168.1.213:50010<\/p>\n<p>16\/04\/08 14:41:22 INFO balancer.Dispatcher: Successfully moved blk_1073760393_19569 with size=77829046 from 192.168.1.213:50010:DISK to 192.168.1.207:50010:DISK through 192.168.1.213:50010<\/p>\n<p>16\/04\/08 14:41:23 INFO balancer.Dispatcher: Successfully moved blk_1073760363_19539 with size=77829046 from 192.168.1.213:50010:DISK to 192.168.1.207:50010:DISK through 192.168.1.213:50010<\/p>\n<h5><a name=\"_Toc13643\"><\/a>10.12.9. \u65b0\u589eJournalNode<\/h5>\n<p>\u627e\u4e00\u53f0\u5df2\u6709JournalNode\u8282\u70b9\uff0c\u4fee\u6539\u5b83\u7684hdfs-site.xml\uff0c\u5c06\u65b0\u589e\u7684Journal\u5305\u542b\u8fdb\u6765\uff0c\u5982\u5728<\/p>\n<p>qjournal:\/\/hadoop-030:8485;hadoop-031:8485;hadoop-032:8485\/test<\/p>\n<p>\u7684\u57fa\u7840\u4e0a\u65b0\u589ehadoop-033\u548chadoop-034\u4e24\u4e2aJournalNode\uff1a<\/p>\n<p>qjournal:\/\/hadoop-030:8485;hadoop-031:8485;hadoop-032:8485;hadoop-033:8485;hadoop-034:8485\/test<\/p>\n<p>\u7136\u540e\u5c06\u5b89\u88c5\u76ee\u5f55\u548c\u6570\u636e\u76ee\u5f55\uff08hdfs-site.xml\u4e2d\u7684dfs.journalnode.edits.dir\u6307\u5b9a\u7684\u76ee\u5f55\uff09\u90fd\u590d\u5236\u5230\u65b0\u7684\u8282\u70b9\u3002<\/p>\n<p>\u5982\u679c\u4e0d\u590d\u5236JournalNode\u7684\u6570\u636e\u76ee\u5f55\uff0c\u5219\u65b0\u8282\u70b9\u4e0a\u7684JournalNode\u4f1a\u62a5\u9519\u201cJournal Storage Directory \/data\/journal\/test not formatted\u201d\uff0c\u5c06\u6765\u7684\u7248\u672c\u53ef\u80fd\u4f1a\u5b9e\u73b0\u81ea\u52a8\u540c\u6b65\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u5c31\u53ef\u4ee5\u5728\u65b0\u8282\u70b9\u4e0a\u542f\u52a8\u597dJournalNode\uff08\u4e0d\u9700\u8981\u505a\u4ec0\u4e48\u521d\u59cb\u5316\uff09\uff0c\u5e76\u91cd\u542f\u4e0bNameNode\u3002\u6ce8\u610f\u89c2\u5bdfJournalNode\u65e5\u5fd7\uff0c\u67e5\u770b\u662f\u5426\u542f\u52a8\u6210\u529f\uff0c\u5f53\u65e5\u5fd7\u663e\u793a\u4e3a\u4ee5\u4e0b\u8fd9\u6837\u7684INFO\u7ea7\u522b\u65e5\u5fd7\u5219\u8868\u793a\u542f\u52a8\u6210\u529f\uff1a<\/p>\n<p>2016-04-26 10:31:11,160 INFO org.apache.hadoop.hdfs.server.namenode.FileJournalManager: Finalizing edits file \/data\/journal\/test\/current\/edits_inprogress_0000000000000194269 -&gt; \/data\/journal\/test\/current\/edits_0000000000000194269-0000000000000194270<\/p>\n<h3><a name=\"_Toc24055\"><\/a>11. \u542f\u52a8YARN<\/h3>\n<h4><a name=\"_Toc26778\"><\/a>11.1. \u542f\u52a8YARN<\/h4>\n<p>1) \u8fdb\u5165$HADOOP_HOME\/sbin\u76ee\u5f55<\/p>\n<p>2) \u5728\u4e3b\u5907\u4e24\u53f0\u90fd\u6267\u884c\uff1astart-yarn.sh\uff0c\u5373\u5f00\u59cb\u542f\u52a8YARN<\/p>\n<p>\u82e5\u542f\u52a8\u6210\u529f\uff0c\u5219\u5728Master\u8282\u70b9\u6267\u884cjps\uff0c\u53ef\u4ee5\u770b\u5230ResourceManager\uff1a<\/p>\n<p>&gt; jps<\/p>\n<p>24689 NameNode<\/p>\n<p>30156 Jps<\/p>\n<p>28861 ResourceManager<\/p>\n<p>\u5728Slaves\u8282\u70b9\u6267\u884cjps\uff0c\u53ef\u4ee5\u770b\u5230NodeManager\uff1a<\/p>\n<p>$ jps<\/p>\n<p>14019 NodeManager<\/p>\n<p>23257 DataNode<\/p>\n<p>15115 Jps<\/p>\n<p>\u5982\u679c\u53ea\u9700\u8981\u5355\u72ec\u542f\u52a8\u6307\u5b9a\u8282\u70b9\u4e0a\u7684ResourceManager\uff0c\u8fd9\u6837\uff1a<\/p>\n<p>.\/yarn-daemon.sh start resourcemanager<\/p>\n<p>\u5bf9\u4e8eNodeManager\uff0c\u5219\u662f\u8fd9\u6837\uff1a<\/p>\n<p>.\/yarn-daemon.sh start nodemanager<\/p>\n<h4><a name=\"_Toc12524\"><\/a>11.2. \u6267\u884cYARN\u547d\u4ee4<\/h4>\n<h5><a name=\"_Toc31931\"><\/a>11.2.1. yarn node -list<\/h5>\n<p>\u5217\u4e3eYARN\u96c6\u7fa4\u4e2d\u7684\u6240\u6709NodeManager\uff0c\u5982\uff08\u6ce8\u610f\u53c2\u6570\u95f4\u7684\u7a7a\u683c\uff0c\u76f4\u63a5\u6267\u884cyarn\u53ef\u4ee5\u770b\u5230\u4f7f\u7528\u5e2e\u52a9\uff09\uff1a<\/p>\n<p>&gt; yarn node -list<\/p>\n<p>Total Nodes:3<\/p>\n<p>Node-Id\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Node-State Node-Http-Address\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Number-of-Running-Containers<\/p>\n<p>localhost:45980\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RUNNING\u00a0\u00a0\u00a0 localhost:8042\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0<\/p>\n<p>localhost:47551\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RUNNING\u00a0\u00a0\u00a0 localhost:8042\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0<\/p>\n<p>localhost:58394\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RUNNING\u00a0\u00a0\u00a0 localhost:8042\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0<\/p>\n<h5><a name=\"_Toc21162\"><\/a>11.2.2. yarn node -status<\/h5>\n<p>\u67e5\u770b\u6307\u5b9aNodeManager\u7684\u72b6\u6001\uff0c\u5982\uff1a<\/p>\n<p>&gt; yarn node -status localhost:47551<\/p>\n<p>Node Report :<\/p>\n<p>Node-Id : localhost:47551<\/p>\n<p>Rack : \/default-rack<\/p>\n<p>Node-State : RUNNING<\/p>\n<p>Node-Http-Address : localhost:8042<\/p>\n<p>Last-Health-Update : \u661f\u671f\u4e94 18\/\u56db\u6708\/14 01:45:41:555GMT<\/p>\n<p>Health-Report :<\/p>\n<p>Containers : 0<\/p>\n<p>Memory-Used : 0MB<\/p>\n<p>Memory-Capacity : 8192MB<\/p>\n<p>CPU-Used : 0 vcores<\/p>\n<p>CPU-Capacity : 8 vcores<\/p>\n<h5><a name=\"_Toc28084\"><\/a>11.2.3. yarn rmadmin -getServiceState rm1<\/h5>\n<p>\u67e5\u770brm1\u7684\u4e3b\u5907\u72b6\u6001\uff0c\u5373\u67e5\u770b\u5b83\u662f\u4e3b\uff08active\uff09\u8fd8\u662f\u5907\uff08standby\uff09\u3002<\/p>\n<h5><a name=\"_Toc11073\"><\/a>11.2.4. yarn rmadmin -transitionToStandby rm1<\/h5>\n<p>\u5c06rm1\u4ece\u4e3b\u5207\u4e3a\u5907\u3002<\/p>\n<p>\u66f4\u591a\u7684yarn\u547d\u4ee4\u53ef\u4ee5\u53c2\u8003\uff1a<\/p>\n<p><a href=\"https:\/\/hadoop.apache.org\/docs\/current\/hadoop-yarn\/hadoop-yarn-site\/YarnCommands.html\">https:\/\/hadoop.apache.org\/docs\/current\/hadoop-yarn\/hadoop-yarn-site\/YarnCommands.html<\/a>\u3002<\/p>\n<h3><a name=\"_Toc22286\"><\/a>12. \u8fd0\u884cMapReduce\u7a0b\u5e8f<\/h3>\n<p>\u5728\u5b89\u88c5\u76ee\u5f55\u7684share\/hadoop\/mapreduce\u5b50\u76ee\u5f55\u4e0b\uff0c\u6709\u73b0\u5b58\u7684\u793a\u4f8b\u7a0b\u5e8f\uff1a<\/p>\n<p>hadoop@VM-40-171-sles10-64:~\/hadoop&gt; ls share\/hadoop\/mapreduce<\/p>\n<p>hadoop-mapreduce-client-app-2.7.2.jar\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop-mapreduce-client-jobclient-2.7.2-tests.jar<\/p>\n<p>hadoop-mapreduce-client-common-2.7.2.jar\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop-mapreduce-client-shuffle-2.7.2.jar<\/p>\n<p>hadoop-mapreduce-client-core-2.7.2.jar\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop-mapreduce-examples-2.7.2.jar<\/p>\n<p>hadoop-mapreduce-client-hs-2.7.2.jar\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 lib<\/p>\n<p>hadoop-mapreduce-client-hs-plugins-2.7.2.jar\u00a0 lib-examples<\/p>\n<p>hadoop-mapreduce-client-jobclient-2.7.2.jar\u00a0\u00a0 sources<\/p>\n<p>\u8dd1\u4e00\u4e2a\u793a\u4f8b\u7a0b\u5e8f\u8bd5\u8bd5\uff1a<\/p>\n<p>hdfs dfs -put \/etc\/hosts\u00a0 hdfs:\/\/test\/in\/<\/p>\n<p>hadoop jar .\/share\/hadoop\/mapreduce\/hadoop-mapreduce-examples-2.7.2.jar wordcount hdfs:\/\/test\/in\/ hdfs:\/\/test\/out\/<\/p>\n<p>\u8fd0\u884c\u8fc7\u7a0b\u4e2d\uff0c\u4f7f\u7528java\u7684jps\u547d\u4ee4\uff0c\u53ef\u4ee5\u770b\u5230yarn\u542f\u52a8\u4e86\u540d\u4e3aYarnChild\u7684\u8fdb\u7a0b\u3002<\/p>\n<p>wordcount\u8fd0\u884c\u5b8c\u6210\u540e\uff0c\u7ed3\u679c\u4f1a\u4fdd\u5b58\u5728out\u76ee\u5f55\u4e0b\uff0c\u4fdd\u5b58\u7ed3\u679c\u7684\u6587\u4ef6\u540d\u7c7b\u4f3c\u4e8e\u201cpart-r-00000\u201d\u3002\u53e6\u5916\uff0c\u8dd1\u8fd9\u4e2a\u793a\u4f8b\u7a0b\u5e8f\u6709\u4e24\u4e2a\u9700\u6c42\u6ce8\u610f\u7684\u70b9\uff1a<\/p>\n<p>1) in\u76ee\u5f55\u4e0b\u8981\u6709\u6587\u672c\u6587\u4ef6\uff0c\u6216in\u5373\u4e3a\u88ab\u7edf\u8ba1\u7684\u6587\u672c\u6587\u4ef6\uff0c\u53ef\u4ee5\u4e3aHDFS\u4e0a\u7684\u6587\u4ef6\u6216\u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4e3a\u672c\u5730\u6587\u4ef6\u6216\u76ee\u5f55<\/p>\n<p>2) out\u76ee\u5f55\u4e0d\u80fd\u5b58\u5728\uff0c\u7a0b\u5e8f\u4f1a\u81ea\u52a8\u53bb\u521b\u5efa\u5b83\uff0c\u5982\u679c\u5df2\u7ecf\u5b58\u5728\u5219\u4f1a\u62a5\u9519\u3002<\/p>\n<p>\u5305hadoop-mapreduce-examples-2.7.2.jar\u4e2d\u542b\u6709\u591a\u4e2a\u793a\u4f8b\u7a0b\u5e8f\uff0c\u4e0d\u5e26\u53c2\u6570\u8fd0\u884c\uff0c\u5373\u53ef\u770b\u5230\u7528\u6cd5\uff1a<\/p>\n<p>&gt; hadoop jar .\/share\/hadoop\/mapreduce\/hadoop-mapreduce-examples-2.7.2.jar wordcount<\/p>\n<p>Usage: wordcount<\/p>\n<p>&gt; hadoop jar .\/share\/hadoop\/mapreduce\/hadoop-mapreduce-examples-2.7.2.jar<\/p>\n<p>An example program must be given as the first argument.<\/p>\n<p>Valid program names are:<\/p>\n<p>aggregatewordcount: An Aggregate based map\/reduce program that counts the words in the input files.<\/p>\n<p>aggregatewordhist: An Aggregate based map\/reduce program that computes the histogram of the words in the input files.<\/p>\n<p>bbp: A map\/reduce program that uses Bailey-Borwein-Plouffe to compute exact digits of Pi.<\/p>\n<p>dbcount: An example job that count the pageview counts from a database.<\/p>\n<p>distbbp: A map\/reduce program that uses a BBP-type formula to compute exact bits of Pi.<\/p>\n<p>grep: A map\/reduce program that counts the matches of a regex in the input.<\/p>\n<p>join: A job that effects a join over sorted, equally partitioned datasets<\/p>\n<p>multifilewc: A job that counts words from several files.<\/p>\n<p>pentomino: A map\/reduce tile laying program to find solutions to pentomino problems.<\/p>\n<p>pi: A map\/reduce program that estimates Pi using a quasi-Monte Carlo method.<\/p>\n<p>randomtextwriter: A map\/reduce program that writes 10GB of random textual data per node.<\/p>\n<p>randomwriter: A map\/reduce program that writes 10GB of random data per node.<\/p>\n<p>secondarysort: An example defining a secondary sort to the reduce.<\/p>\n<p>sort: A map\/reduce program that sorts the data written by the random writer.<\/p>\n<p>sudoku: A sudoku solver.<\/p>\n<p>teragen: Generate data for the terasort<\/p>\n<p>terasort: Run the terasort<\/p>\n<p>teravalidate: Checking results of terasort<\/p>\n<p>wordcount: A map\/reduce program that counts the words in the input files.<\/p>\n<p>wordmean: A map\/reduce program that counts the average length of the words in the input files.<\/p>\n<p>wordmedian: A map\/reduce program that counts the median length of the words in the input files.<\/p>\n<p>wordstandarddeviation: A map\/reduce program that counts the standard deviation of the length of the words in the input files.<\/p>\n<p>\u4fee\u6539\u65e5\u5fd7\u7ea7\u522b\u4e3aDEBBUG\uff0c\u5e76\u6253\u5c4f\uff1a<\/p>\n<p>export HADOOP_ROOT_LOGGER=DEBUG,console<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u53c2\u8003url\uff1a<a href=\"http:\/\/blog.chinaunix.net\/uid-20682147-id-5520795.html\">http:\/\/blog.chinaunix.net\/uid-20682147-id-5520795.html<\/a><\/p>\n<p><a title=\"http:\/\/www.powerxing.com\/install-hadoop-in-centos\/\" href=\"http:\/\/www.powerxing.com\/install-hadoop-in-centos\/\">http:\/\/www.powerxing.com\/install-hadoop-in-centos\/<\/a>\u00a0\u00a0\u00a0\u00a0 \uff08mapreduce\u6d4b\u8bd5\u6bd4\u8f83\u8be6\u7ec6\uff09<br \/>\n\u673a\u5668\u5217\u8868<br \/>\n10.45.53.143\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop1.i.zhihuishu.com<br \/>\n10.47.109.190\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop2.i.zhihuishu.com<br \/>\n10.24.31.188\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop3.i.zhihuishu.com<br \/>\n10.168.227.144\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop4.i.zhihuishu.com<br \/>\n10.168.248.3\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop5.i.zhihuishu.com<br \/>\nNameNode<br \/>\nhadoop1.i.zhihuishu.com\u00a0\u00a0 hadoop2.i.zhihuishu.com<br \/>\nJournalNode<br \/>\nhadoop1.i.zhihuishu.com\u00a0 hadoop2.i.zhihuishu.com\u00a0 hadoop3.i.zhihuishu.com<br \/>\nDataNode<br \/>\nhadoop3.i.zhihuishu.com\u00a0 hadoop4.i.zhihuishu.com\u00a0 hadoop5.i.zhihuishu.com<br \/>\nZooKeeper<br \/>\nhadoop1.i.zhihuishu.com\u00a0 hadoop2.i.zhihuishu.com\u00a0 hadoop3.i.zhihuishu.com<br \/>\n\u76ee\u5f55\u89c4\u8303\uff1a<br \/>\nHadoop<br \/>\n\/data\/hadoop\/hadoop<br \/>\nzookeeper<br \/>\n\/data\/hadoop\/zookeeper<br \/>\nJDK<br \/>\nJAVA_HOME=\/usr\/local\/jdk1.8.0_45<\/p>\n<p>\u524d\u671f\u51c6\u5907\uff1a<br \/>\n10.45.53.143\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop1.i.zhihuishu.com\u00a0\u00a0\u00a0 rizhi143<br \/>\n10.47.109.190\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop2.i.zhihuishu.com\u00a0\u00a0\u00a0 rizhi190<br \/>\n10.24.31.188\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop3.i.zhihuishu.com\u00a0\u00a0\u00a0 rizhi188<br \/>\n10.25.2.16\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop4.i.zhihuishu.com\u00a0\u00a0\u00a0 rizhi16<br \/>\n10.168.248.3\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop5.i.zhihuishu.com\u00a0\u00a0\u00a0 rizhi3<br \/>\nhost\u5b9a\u5411\uff0c\u8bb0\u5f97\u8981\u628a hostname \u4e5f\u8981\u5b9a\u5411\uff0c\u56e0\u4e3a\u5f88\u591a\u662f\u901a\u8fc7hostname\u901a\u8baf\u7684\u3002<\/p>\n<p>ssh\u8ba4\u8bc1<br \/>\ncd ~\/.ssh\/<br \/>\nssh-keygen -t rsa<br \/>\ncat id_rsa.pub &gt;&gt; authorized_keys<br \/>\nchmod 600 .\/authorized_keys<br \/>\n\u8bb0\u5f97name1 name2\u00a0 \u6709\u5168\u90e8\u7684\u63a7\u5236ssh\u8ba4\u8bc1\u00a0 dataname \u53ea\u8981\u6709\u4e92\u76f8\u7684\u8ba4\u8bc1\u5373\u53ef<\/p>\n<p>\u6587\u4ef6\u540c\u6b65<br \/>\nmkdir -p \/data\/hadoop<br \/>\ncd \/data\/hadoop\/<br \/>\ntar -zxvf hadoop.tar.gz<\/p>\n<p>\u6dfb\u52a0 \/etc\/profile<br \/>\nexport HADOOP_HOME=\/data\/hadoop\/hadoop<br \/>\nexport HADOOP_CONF_DIR=$HADOOP_HOME\/etc\/hadoop<\/p>\n<p>\u6dfb\u52a0slave<br \/>\nvi etc\/hadoop\/slaves<br \/>\nhadoop3.i.zhihuishu.com<br \/>\nhadoop4.i.zhihuishu.com<br \/>\nhadoop5.i.zhihuishu.com<br \/>\n~<br \/>\n\u914d\u7f6e\u6587\u4ef6\u521d\u59cb\u5316<br \/>\ncd \/data\/hadoop\/hadoop<br \/>\ncp share\/doc\/hadoop\/hadoop-project-dist\/hadoop-common\/core-default.xml etc\/hadoop\/core-site.xml<br \/>\ncp share\/doc\/hadoop\/hadoop-project-dist\/hadoop-hdfs\/hdfs-default.xml etc\/hadoop\/hdfs-site.xml<br \/>\ncp share\/doc\/hadoop\/hadoop-yarn\/hadoop-yarn-common\/yarn-default.xml etc\/hadoop\/yarn-site.xml<br \/>\ncp share\/doc\/hadoop\/hadoop-mapreduce-client\/hadoop-mapreduce-client-core\/mapred-default.xml etc\/hadoop\/mapred-site.xml<\/p>\n<p>cd \/data\/hadoop\/hadoop\/etc\/hadoop<br \/>\nwget -O hdfs-site.xml\u00a0 wget <a href=\"http:\/\/222.66.154.110\/install\/hadoop\/hdfs-site.xml\">http:\/\/222.66.154.110\/install\/hadoop\/hdfs-site.xml<\/a><br \/>\nwget -O core-site.xml\u00a0 wget <a href=\"http:\/\/222.66.154.110\/install\/hadoop\/core-site.xml\">http:\/\/222.66.154.110\/install\/hadoop\/core-site.xml<\/a><br \/>\nwget -O yarn-site.xml\u00a0 wget <a href=\"http:\/\/222.66.154.110\/install\/hadoop\/yarn-site.xml\">http:\/\/222.66.154.110\/install\/hadoop\/yarn-site.xml<\/a><br \/>\nwget -O mapred-site.xml\u00a0 wget <a href=\"http:\/\/222.66.154.110\/install\/hadoop\/mapred-site.xml\">http:\/\/222.66.154.110\/install\/hadoop\/mapred-site.xml<\/a><\/p>\n<p>mkdir -p \/data\/hadoop\/hadoop\/tmp<br \/>\nmkdir -p \/data\/hadoop\/hadoop\/tmp\/dfs\/name<\/p>\n<p>&nbsp;<\/p>\n<p>\u914d\u7f6e\u6587\u4ef6\u5728\u9644\u4ef6\uff0c\u53ef\u4ee5\u53c2\u8003\u9644\u4ef6\u3002<\/p>\n<p><a href=\"https:\/\/www.hmouse.cn\/?attachment_id=4742\" rel=\"attachment wp-att-4742\">hadoop-xml<\/a><\/p>\n<p>QJM\u7684\u914d\u7f6e\u53c2\u7167\u7684\u5b98\u65b9\u6587\u6863\uff1a<\/p>\n<p><a href=\"http:\/\/hadoop.apache.org\/docs\/stable\/hadoop-project-dist\/hadoop-hdfs\/HDFSHighAvailabilityWithQJM.html\">http:\/\/hadoop.apache.org\/docs\/stable\/hadoop-project-dist\/hadoop-hdfs\/HDFSHighAvailabilityWithQJM.html<\/a>\u3002<\/p>\n<h4>hdfs-site.xml\u8be6\u7ec6\u914d\u7f6e\u53ef\u53c2\u8003\uff1a<\/h4>\n<p><a href=\"http:\/\/hadoop.apache.org\/docs\/current\/hadoop-project-dist\/hadoop-hdfs\/hdfs-default.xml\">http:\/\/hadoop.apache.org\/docs\/current\/hadoop-project-dist\/hadoop-hdfs\/hdfs-default.xml<\/a>\u3002<\/p>\n<p>yarn.nodemanager.hostname\u5982\u679c\u914d\u7f6e\u6210\u5177\u4f53\u7684IP\uff0c\u598210.12.154.79\uff0c\u5219\u4f1a\u5bfc\u81f4\u6bcf\u4e2aNodeManager\u7684\u914d\u7f6e\u4e0d\u540c\u3002\u8be6\u7ec6\u914d\u7f6e\u53ef\u53c2\u8003\uff1a<\/p>\n<p><a href=\"http:\/\/hadoop.apache.org\/docs\/current\/hadoop-yarn\/hadoop-yarn-common\/yarn-default.xml\">http:\/\/hadoop.apache.org\/docs\/current\/hadoop-yarn\/hadoop-yarn-common\/yarn-default.xml<\/a>\u3002<\/p>\n<p>Yarn HA\u7684\u914d\u7f6e\u53ef\u4ee5\u53c2\u8003\uff1a<\/p>\n<p><a href=\"https:\/\/hadoop.apache.org\/docs\/current\/hadoop-yarn\/hadoop-yarn-site\/ResourceManagerHA.html\">https:\/\/hadoop.apache.org\/docs\/current\/hadoop-yarn\/hadoop-yarn-site\/ResourceManagerHA.html<\/a>\u3002<\/p>\n<p>\u9047\u5230\u7684\u95ee\u9898\uff1a<\/p>\n<p><span style=\"color: #ff0000;\">1\uff1aNamenode2\u00a0 \u505aHA\u542f\u52a8\u9519\u4e86\uff0c\u8001\u662f\u62a5\u65e0\u6cd5\u6ce8\u518cnn2\u3002<\/span><\/p>\n<p><span style=\"color: #ff0000;\">2\uff1aproxy\u6ca1\u6709\u914d\u7f6e\uff0c\u9020\u6210\u4e86\u6ca1\u529e\u6cd5\u8bbf\u95eezhscluster\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h3>9. \u542f\u52a8\u987a\u5e8f<\/h3>\n<p>Zookeeper -&gt; JournalNode -&gt; \u683c\u5f0f\u5316NameNode -&gt; \u521d\u59cb\u5316JournalNode<\/p>\n<p>-&gt; \u521b\u5efa\u547d\u540d\u7a7a\u95f4\uff08zkfc\uff09 -&gt; NameNode -&gt; DataNode -&gt; ResourceManager -&gt; NodeManager\u3002<\/p>\n<p>\u4f46\u8bf7\u6ce8\u610f\u9996\u6b21\u542f\u52a8NameNode\u4e4b\u524d\uff0c\u5f97\u5148\u505aformat\uff0c\u4e5f\u8bf7\u6ce8\u610f\u5907NameNode\u7684\u542f\u52a8\u65b9\u6cd5\u3002<\/p>\n<h3><a name=\"_Toc32392\"><\/a>10. \u542f\u52a8HDFS<\/h3>\n<p>\u5728\u542f\u52a8HDFS\u4e4b\u524d\uff0c\u9700\u8981\u5148\u5b8c\u6210\u5bf9NameNode\u7684\u683c\u5f0f\u5316\u3002<\/p>\n<h4><a name=\"_Toc309\"><\/a>10.1. \u521b\u5efa\u597d\u76ee\u5f55<\/h4>\n<p>mkdir -p \/data\/hadoop\/hadoop-2.7.2\/tmp\/dfs\/name<\/p>\n<h4><a name=\"_Toc6320\"><\/a>10.2. \u542f\u52a8\u597dzookeeper<\/h4>\n<p>.\/zkServer.sh start<\/p>\n<p>\u6ce8\u610f\u5728\u542f\u52a8\u5176\u5b83\u4e4b\u524d\u5148\u542f\u52a8zookeeper\u3002<\/p>\n<h4><a name=\"_Toc20270\"><\/a>10.3. \u521b\u5efa\u547d\u540d\u7a7a\u95f4<\/h4>\n<p>\u5728\u5176\u4e2d\u4e00\u4e2anamenode\u4e0a\u6267\u884c\uff1a<\/p>\n<p>.\/hdfs zkfc -formatZK<\/p>\n<p>\u6ce8\u610f\uff0c\u8fd9\u4e00\u6b65\u8981\u5728\u521d\u59cb\u5316\u547d\u540d\u7a7a\u95f4\u4e4b\u540e\u6267\u884c\u3002<\/p>\n<h4><a name=\"_Toc25237\"><\/a>10.4. \u542f\u52a8\u6240\u6709JournalNode<\/h4>\n<p>NameNode\u5c06\u5143\u6570\u636e\u64cd\u4f5c\u65e5\u5fd7\u8bb0\u5f55\u5728JournalNode\u4e0a\uff0c\u4e3b\u5907NameNode\u901a\u8fc7\u8bb0\u5f55\u5728JouralNode\u4e0a\u7684\u65e5\u5fd7\u5b8c\u6210\u5143\u6570\u636e\u540c\u6b65\u3002<\/p>\n<p>\u5728\u6240\u6709JournalNode\u4e0a\u6267\u884c\uff08\u6ce8\u610f\u662f\u4e24\u4e2a\u53c2\u6570\uff0c\u5728\u201chdfs namenode -format\u201d\u4e4b\u540e\u505a\u8fd9\u4e00\u6b65\uff09\uff1a<\/p>\n<p>.\/hadoop-daemon.sh start journalnode<\/p>\n<p>\u6ce8\u610f\uff0c\u5728\u6267\u884c\u201chdfs namenode -format\u201d\u4e4b\u524d\uff0c\u5fc5\u987b\u5148\u542f\u52a8\u597dJournalNode\uff0c\u800cformat\u53c8\u5fc5\u987b\u5728\u542f\u52a8namenode\u4e4b\u524d\u3002<\/p>\n<h4><a name=\"_Toc15020\"><\/a>10.5. \u521d\u59cb\u5316JournalNode<\/h4>\n<p>\u5982\u679c\u662f\u975eHA\u8f6cHA\u624d\u9700\u8981\u8fd9\u4e00\u6b65\uff0c\u5728\u5176\u4e2d\u4e00\u4e2aJournalNode\u4e0a\u6267\u884c\uff1a<\/p>\n<p>.\/hdfs namenode -initializeSharedEdits<\/p>\n<p>\u6b64\u547d\u4ee4\u9ed8\u8ba4\u662f\u4ea4\u4e92\u5f0f\u7684\uff0c\u52a0\u4e0a\u53c2\u6570-force\u8f6c\u6210\u975e\u4ea4\u4e92\u5f0f\u3002<\/p>\n<p>\u5728\u6240\u6709JournalNode\u521b\u5efa\u5982\u4e0b\u76ee\u5f55\uff1a<\/p>\n<p>mkdir -p \/data\/hadoop\/hadoop\/journal\/mycluster\/current<\/p>\n<h4><a name=\"_Toc5807\"><\/a>10.6. \u683c\u5f0f\u5316NameNode<\/h4>\n<p>\u6ce8\u610f\u53ea\u6709\u65b0\u7684\uff0c\u624d\u9700\u8981\u505a\u8fd9\u4e00\u6b65\uff0c\u800c\u4e14\u53ea\u9700\u8981\u5728\u4e3bNameNode\u4e0a\u6267\u884c\u3002<\/p>\n<p>1) \u8fdb\u5165$HADOOP_HOME\/bin\u76ee\u5f55<\/p>\n<p>2) \u8fdb\u884c\u683c\u5f0f\u5316\uff1a.\/hdfs namenode -format<\/p>\n<p>\u5982\u679c\u5b8c\u6210\u6709\uff0c\u8f93\u51fa\u5305\u542b\u201cINFO util.ExitUtil: Exiting with status 0\u201d\uff0c\u5219\u8868\u793a\u683c\u5f0f\u5316\u6210\u529f\u3002<\/p>\n<p>\u5728\u8fdb\u884c\u683c\u5f0f\u5316\u65f6\uff0c\u5982\u679c\u6ca1\u6709\u5728\/etc\/hosts\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4e3b\u673a\u540d\u548cIP\u7684\u6620\u5c04\uff1a\u201c172.25.40.171\u00a0\u00a0 VM-40-171-sles10-64\u201d\uff0c\u5219\u4f1a\u62a5\u5982\u4e0b\u6240\u793a\u9519\u8bef\uff1a<\/p>\n<p>14\/04\/17 03:44:09 WARN net.DNS: Unable to determine local hostname -falling back to &#8220;localhost&#8221;<\/p>\n<p>java.net.UnknownHostException: VM-40-171-sles10-64: VM-40-171-sles10-64: unknown error<\/p>\n<p>at java.net.InetAddress.getLocalHost(InetAddress.java:1484)<\/p>\n<p>at org.apache.hadoop.net.DNS.resolveLocalHostname(DNS.java:264)<\/p>\n<p>at org.apache.hadoop.net.DNS.(DNS.java:57)<\/p>\n<p>at org.apache.hadoop.hdfs.server.namenode.NNStorage.newBlockPoolID(NNStorage.java:945)<\/p>\n<p>at org.apache.hadoop.hdfs.server.namenode.NNStorage.newNamespaceInfo(NNStorage.java:573)<\/p>\n<p>at org.apache.hadoop.hdfs.server.namenode.FSImage.format(FSImage.java:144)<\/p>\n<p>at org.apache.hadoop.hdfs.server.namenode.NameNode.format(NameNode.java:845)<\/p>\n<p>at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1256)<\/p>\n<p>at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1370)<\/p>\n<p>Caused by: java.net.UnknownHostException: VM-40-171-sles10-64: unknown error<\/p>\n<p>at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)<\/p>\n<p>at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:907)<\/p>\n<p>at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1302)<\/p>\n<p>at java.net.InetAddress.getLocalHost(InetAddress.java:1479)<\/p>\n<p>&#8230; 8 more<\/p>\n<h4><a name=\"_Toc17469\"><\/a>10.7. \u542f\u52a8\u4e3bNameNode<\/h4>\n<p>1) \u8fdb\u5165$HADOOP_HOME\/sbin\u76ee\u5f55<\/p>\n<p>2) \u542f\u52a8\u4e3bNameNode\uff1a<\/p>\n<p>.\/hadoop-daemon.sh start namenode<\/p>\n<p>\u542f\u52a8\u65f6\uff0c\u9047\u5230\u5982\u4e0b\u6240\u793a\u7684\u9519\u8bef\uff0c\u5219\u8868\u793aNameNode\u4e0d\u80fd\u514d\u5bc6\u7801\u767b\u5f55\u81ea\u5df1\u3002\u5982\u679c\u4e4b\u524d\u4f7f\u7528IP\u53ef\u4ee5\u514d\u5bc6\u7801\u767b\u5f55\u81ea\u5df1\uff0c\u5219\u539f\u56e0\u4e00\u822c\u662f\u56e0\u4e3a\u6ca1\u6709\u4f7f\u7528\u4e3b\u673a\u540d\u767b\u5f55\u8fc7\u81ea\u5df1\uff0c\u56e0\u6b64\u89e3\u51b3\u529e\u6cd5\u662f\u4f7f\u7528\u4e3b\u673a\u540dSSH\u4e00\u4e0b\uff0c\u6bd4\u5982\uff1assh hadoop@VM_40_171_sles10_64\uff0c\u7136\u540e\u518d\u542f\u52a8\u3002<\/p>\n<p>Starting namenodes on [VM_40_171_sles10_64]<\/p>\n<p>VM_40_171_sles10_64: Host key not found from database.<\/p>\n<p>VM_40_171_sles10_64: Key fingerprint:<\/p>\n<p>VM_40_171_sles10_64: xofiz-zilip-tokar-rupyb-tufer-tahyc-sibah-kyvuf-palik-hazyt-duxux<\/p>\n<p>VM_40_171_sles10_64: You can get a public key&#8217;s fingerprint by running<\/p>\n<p>VM_40_171_sles10_64: % ssh-keygen -F publickey.pub<\/p>\n<p>VM_40_171_sles10_64: on the keyfile.<\/p>\n<p>VM_40_171_sles10_64: warning: tcgetattr failed in ssh_rl_set_tty_modes_for_fd: fd 1: Invalid argument<\/p>\n<h4><a name=\"_Toc27524\"><\/a>10.8. \u542f\u52a8\u5907NameNode<\/h4>\n<p>1) .\/hdfs namenode -bootstrapStandby<\/p>\n<p>2) .\/hadoop-daemon.sh start namenode<\/p>\n<p>\u5982\u679c\u6ca1\u6709\u6267\u884c\u7b2c1\u6b65\uff0c\u76f4\u63a5\u542f\u52a8\u4f1a\u9047\u5230\u5982\u4e0b\u9519\u8bef\uff1a<\/p>\n<p>No valid image files found<\/p>\n<p>\u6216\u8005\u5728\u8be5NameNode\u65e5\u5fd7\u4f1a\u53d1\u73b0\u5982\u4e0b\u9519\u8bef\uff1a<\/p>\n<p>2016-04-08 14:08:39,745 WARN org.apache.hadoop.hdfs.server.namenode.FSNamesystem: Encountered exception loading fsimage<\/p>\n<p>java.io.IOException: NameNode is not formatted.<\/p>\n<h4><a name=\"_Toc18382\"><\/a>10.9. \u542f\u52a8\u4e3b\u5907\u5207\u6362\u8fdb\u7a0b<\/h4>\n<p>\u5728\u6240\u6709NameNode\u4e0a\u542f\u52a8\u4e3b\u5907\u5207\u6362\u8fdb\u7a0b\uff1a<\/p>\n<p>.\/hadoop-daemon.sh start zkfc<\/p>\n<p>\u53ea\u6709\u542f\u52a8\u4e86DFSZKFailoverController\u8fdb\u7a0b\uff0cHDFS\u624d\u80fd\u81ea\u52a8\u5207\u6362\u4e3b\u5907\u3002<\/p>\n<p>\u6ce8\uff1azkfc\u662fzookeeper failover controller\u7684\u7f29\u5199\u3002<\/p>\n<h4><a name=\"_Toc22206\"><\/a>10.10. \u542f\u52a8\u6240\u6709DataNode<\/h4>\n<p>\u5728\u5404\u4e2aDataNode\u4e0a\u5206\u522b\u6267\u884c\uff1a<\/p>\n<p>.\/hadoop-daemon.sh start datanode<\/p>\n<p>\u5982\u679c\u6709\u53d1\u73b0DataNode\u8fdb\u7a0b\u5e76\u6ca1\u6709\u8d77\u6765\uff0c\u53ef\u4ee5\u8bd5\u8bd5\u5220\u9664logs\u76ee\u5f55\u4e0b\u7684DataNode\u65e5\u5fd7\uff0c\u518d\u5f97\u542f\u770b\u770b\u3002<\/p>\n<h4><a name=\"_Toc12278\"><\/a>10.11. \u68c0\u67e5\u542f\u52a8\u662f\u5426\u6210\u529f<\/h4>\n<p>1) \u4f7f\u7528JDK\u63d0\u4f9b\u7684jps\u547d\u4ee4\uff0c\u67e5\u770b\u76f8\u5e94\u7684\u8fdb\u7a0b\u662f\u5426\u5df2\u542f\u52a8<\/p>\n<p>2) \u68c0\u67e5$HADOOP_HOME\/logs\u76ee\u5f55\u4e0b\u7684log\u548cout\u6587\u4ef6\uff0c\u770b\u770b\u662f\u5426\u6709\u5f02\u5e38\u4fe1\u606f\u3002<\/p>\n<p>\u542f\u52a8\u540enn1\u548cnn2\u90fd\u5904\u4e8e\u5907\u673a\u72b6\u6001\uff0c\u5c06nn1\u5207\u6362\u4e3a\u4e3b\u673a\uff1a<\/p>\n<p>.\/hdfs haadmin -transitionToActive nn1<\/p>\n<h5><a name=\"_Toc32232\"><\/a>10.11.1. DataNode<\/h5>\n<p>\u6267\u884cjps\u547d\u4ee4\uff08\u6ce8\uff1ajps\u662fjdk\u4e2d\u7684\u4e00\u4e2a\u547d\u4ee4\uff0c\u4e0d\u662fjre\u4e2d\u7684\u547d\u4ee4\uff09\uff0c\u53ef\u770b\u5230DataNode\u8fdb\u7a0b\uff1a<\/p>\n<p>$ jps<\/p>\n<p>18669 DataNode<\/p>\n<p>24542 Jps<\/p>\n<h5><a name=\"_Toc1075\"><\/a>10.11.2. NameNode<\/h5>\n<p>\u6267\u884cjps\u547d\u4ee4\uff0c\u53ef\u770b\u5230NameNode\u8fdb\u7a0b\uff1a<\/p>\n<p>$ jps<\/p>\n<p>18669 NameNode<\/p>\n<p>24542 Jps<\/p>\n<h4><a name=\"_Toc27166\"><\/a>10.12. \u6267\u884cHDFS\u547d\u4ee4<\/h4>\n<p>\u6267\u884cHDFS\u547d\u4ee4\uff0c\u4ee5\u8fdb\u4e00\u6b65\u68c0\u9a8c\u662f\u5426\u5df2\u7ecf\u5b89\u88c5\u6210\u529f\u548c\u914d\u7f6e\u597d\u3002\u5173\u4e8eHDFS\u547d\u4ee4\u7684\u7528\u6cd5\uff0c\u76f4\u63a5\u8fd0\u884c\u547d\u4ee4hdfs\u6216hdfs dfs\uff0c\u5373\u53ef\u770b\u5230\u76f8\u5173\u7684\u7528\u6cd5\u8bf4\u660e\u3002<\/p>\n<h5><a name=\"_Toc12898\"><\/a>10.12.1. \u67e5\u770bDataNode\u662f\u5426\u6b63\u5e38\u542f\u52a8<\/h5>\n<p>hdfs dfsadmin -report<\/p>\n<p>\u6ce8\u610f\u5982\u679ccore-site.xml\u4e2d\u7684\u914d\u7f6e\u9879fs.default.name\u7684\u503c\u4e3afile:\/\/\/\uff0c\u5219\u4f1a\u62a5\uff1a<\/p>\n<p>report: FileSystem file:\/\/\/ is not an HDFS file system<\/p>\n<p>Usage: hdfs dfsadmin [-report] [-live] [-dead] [-decommissioning]<\/p>\n<p>\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ea\u9700\u8981\u5c06fs.default.name\u7684\u503c\u8bbe\u7f6e\u4e3a\u548cfs.defaultFS\u76f8\u540c\u7684\u503c\u3002<\/p>\n<h5><a name=\"_Toc32312\"><\/a>10.12.2. \u67e5\u770bNameNode\u7684\u4e3b\u5907\u72b6\u6001<\/h5>\n<p>\u5982\u67e5\u770bNameNode1\u548cNameNode2\u5206\u522b\u662f\u4e3b\u8fd8\u662f\u5907\uff1a<\/p>\n<p>$ hdfs haadmin -getServiceState nm1<\/p>\n<p>standby<\/p>\n<p>$ hdfs haadmin -getServiceState nm2<\/p>\n<p>active<\/p>\n<h5><a name=\"_Toc13507\"><\/a>10.12.3. hdfs dfs ls<\/h5>\n<p>\u201chdfs dfs -ls\u201d\u5e26\u4e00\u4e2a\u53c2\u6570\uff0c\u5982\u679c\u53c2\u6570\u4ee5\u201chdfs:\/\/URI\u201d\u6253\u5934\u8868\u793a\u8bbf\u95eeHDFS\uff0c\u5426\u5219\u76f8\u5f53\u4e8els\u3002\u5176\u4e2dURI\u4e3aNameNode\u7684IP\u6216\u4e3b\u673a\u540d\uff0c\u53ef\u4ee5\u5305\u542b\u7aef\u53e3\u53f7\uff0c\u5373hdfs-site.xml\u4e2d\u201cdfs.namenode.rpc-address\u201d\u6307\u5b9a\u7684\u503c\u3002<\/p>\n<p>\u201chdfs dfs -ls\u201d\u8981\u6c42\u9ed8\u8ba4\u7aef\u53e3\u4e3a8020\uff0c\u5982\u679c\u914d\u7f6e\u62109000\uff0c\u5219\u9700\u8981\u6307\u5b9a\u7aef\u53e3\u53f7\uff0c\u5426\u5219\u4e0d\u7528\u6307\u5b9a\u7aef\u53e3\uff0c\u8fd9\u4e00\u70b9\u7c7b\u4f3c\u4e8e\u6d4f\u89c8\u5668\u8bbf\u95ee\u4e00\u4e2aURL\u3002\u793a\u4f8b\uff1a<\/p>\n<p>&gt; hdfs dfs -ls hdfs:\/\/172.25.40.171:9001\/<\/p>\n<p>9001\u540e\u9762\u7684\u659c\u6760\/\u662f\u548c\u5fc5\u987b\u7684\uff0c\u5426\u5219\u88ab\u5f53\u4f5c\u6587\u4ef6\u3002\u5982\u679c\u4e0d\u6307\u5b9a\u7aef\u53e3\u53f79001\uff0c\u5219\u4f7f\u7528\u9ed8\u8ba4\u76848020\uff0c\u201c172.25.40.171:9001\u201d\u7531hdfs-site.xml\u4e2d\u201cdfs.namenode.rpc-address\u201d\u6307\u5b9a\u3002<\/p>\n<p>\u4e0d\u96be\u770b\u51fa\u201chdfs dfs -ls\u201d\u53ef\u4ee5\u64cd\u4f5c\u4e0d\u540c\u7684HDFS\u96c6\u7fa4\uff0c\u53ea\u9700\u8981\u6307\u5b9a\u4e0d\u540c\u7684URI\u3002<\/p>\n<p>\u6587\u4ef6\u4e0a\u4f20\u540e\uff0c\u88ab\u5b58\u50a8\u5728DataNode\u7684data\u76ee\u5f55\u4e0b\uff08\u7531DataNode\u7684hdfs-site.xml\u4e2d\u7684\u5c5e\u6027\u201cdfs.datanode.data.dir\u201d\u6307\u5b9a\uff09\uff0c\u5982\uff1a<\/p>\n<p>$HADOOP_HOME\/data\/current\/BP-139798373-172.25.40.171-1397735615751\/current\/finalized\/blk_1073741825<\/p>\n<p>\u6587\u4ef6\u540d\u4e2d\u7684\u201cblk\u201d\u662fblock\uff0c\u5373\u5757\u7684\u610f\u601d\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0bblk_1073741825\u5373\u4e3a\u6587\u4ef6\u7684\u4e00\u4e2a\u5b8c\u6574\u5757\uff0cHadoop\u672a\u5bf9\u5b83\u8fdb\u989d\u5916\u5904\u7406\u3002<\/p>\n<h5><a name=\"_Toc27436\"><\/a>10.12.4. hdfs dfs -put<\/h5>\n<p>\u4e0a\u4f20\u6587\u4ef6\u547d\u4ee4\uff0c\u793a\u4f8b\uff1a<\/p>\n<p>&gt; hdfs dfs -put \/etc\/SuSE-release hdfs:\/\/172.25.40.171:9001\/<\/p>\n<h5><a name=\"_Toc320\"><\/a>10.12.5. hdfs dfs -rm<\/h5>\n<p>\u5220\u9664\u6587\u4ef6\u547d\u4ee4\uff0c\u793a\u4f8b\uff1a<\/p>\n<p>&gt; hdfs dfs -rm hdfs:\/\/172.25.40.171:9001\/SuSE-release<\/p>\n<p>Deleted hdfs:\/\/172.25.40.171:9001\/SuSE-release<\/p>\n<h5><a name=\"_Toc31944\"><\/a>10.12.6. \u65b0NameNode\u5982\u4f55\u52a0\u5165\uff1f<\/h5>\n<p>\u5f53\u6709NameNode\u673a\u5668\u635f\u574f\u65f6\uff0c\u5fc5\u7136\u5b58\u5728\u65b0NameNode\u6765\u66ff\u4ee3\u3002\u628a\u914d\u7f6e\u4fee\u6539\u6210\u6307\u5411\u65b0NameNode\uff0c\u7136\u540e\u4ee5\u5907\u673a\u5f62\u5f0f\u542f\u52a8\u65b0NameNode\uff0c\u8fd9\u6837\u65b0\u7684NameNode\u5373\u52a0\u5165\u5230Cluster\u4e2d\uff1a<\/p>\n<p>1) .\/hdfs namenode -bootstrapStandby<\/p>\n<p>2) .\/hadoop-daemon.sh start namenode<\/p>\n<h5><a name=\"_Toc21462\"><\/a>10.12.7. HDFS\u53ea\u5141\u8bb8\u6709\u4e00\u4e3b\u4e00\u5907\u4e24\u4e2aNameNode<\/h5>\n<p>\u5982\u679c\u8bd5\u56fe\u914d\u7f6e\u4e09\u4e2aNameNode\uff0c\u5982\uff1a<\/p>\n<p>dfs.ha.namenodes.test<\/p>\n<p>nm1,nm2,nm3<\/p>\n<p>The prefix for a given nameservice, contains a comma-separated<\/p>\n<p>list of namenodes for a given nameservice (eg EXAMPLENAMESERVICE).<\/p>\n<p>\u5219\u8fd0\u884c\u201chdfs namenode -bootstrapStandby\u201d\u65f6\u4f1a\u62a5\u5982\u4e0b\u9519\u8bef\uff0c\u8868\u793a\u5728\u540c\u4e00NameSpace\u5185\u4e0d\u80fd\u8d85\u8fc72\u4e2aNameNode\uff1a<\/p>\n<p>16\/04\/11 09:51:57 ERROR namenode.NameNode: Failed to start namenode.<\/p>\n<p>java.io.IOException: java.lang.IllegalArgumentException: Expected exactly 2 NameNodes in namespace &#8216;test&#8217;. Instead, got only 3 (NN ids were &#8216;nm1&#8242;,&#8217;nm2&#8242;,&#8217;nm3&#8217;<\/p>\n<p>at org.apache.hadoop.hdfs.server.namenode.ha.BootstrapStandby.run(BootstrapStandby.java:425)<\/p>\n<p>at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1454)<\/p>\n<p>at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1554)<\/p>\n<p>Caused by: java.lang.IllegalArgumentException: Expected exactly 2 NameNodes in namespace &#8216;test&#8217;. Instead, got only 3 (NN ids were &#8216;nm1&#8242;,&#8217;nm2&#8242;,&#8217;nm3&#8217;<\/p>\n<p>at com.google.common.base.Preconditions.checkArgument(Preconditions.java:115)<\/p>\n<h5><a name=\"_Toc10478\"><\/a>10.12.8. \u5b58\u50a8\u5747\u8861start-balancer.sh<\/h5>\n<p>\u793a\u4f8b\uff1astart-balancer.sh \u2013t 10%<\/p>\n<p>10%\u8868\u793a\u673a\u5668\u4e0e\u673a\u5668\u4e4b\u95f4\u78c1\u76d8\u4f7f\u7528\u7387\u504f\u5dee\u5c0f\u4e8e10%\u65f6\u8ba4\u4e3a\u5747\u8861\uff0c\u5426\u5219\u505a\u5747\u8861\u642c\u52a8\u3002\u201cstart-balancer.sh\u201d\u8c03\u7528\u201chdfs start balancer\u201d\u6765\u505a\u5747\u8861\uff0c\u53ef\u4ee5\u8c03\u7528stop-balancer.sh\u505c\u6b62\u5747\u8861\u3002<\/p>\n<p>\u5747\u8861\u8fc7\u7a0b\u975e\u5e38\u6162\uff0c\u4f46\u662f\u5747\u8861\u8fc7\u7a0b\u4e2d\uff0c\u4ecd\u80fd\u591f\u6b63\u5e38\u8bbf\u95eeHDFS\uff0c\u5305\u62ec\u5f80HDFS\u4e0a\u4f20\u6587\u4ef6\u3002<\/p>\n<p>[VM2016@hadoop-030 \/data4\/hadoop\/sbin]$ hdfs balancer # \u53ef\u4ee5\u6539\u4e3a\u8c03\u7528start-balancer.sh<\/p>\n<p>16\/04\/08 14:26:55 INFO balancer.Balancer: namenodes\u00a0 = [hdfs:\/\/test] \/\/ test\u4e3aHDFS\u7684cluster\u540d<\/p>\n<p>16\/04\/08 14:26:55 INFO balancer.Balancer: parameters = Balancer.Parameters[BalancingPolicy.Node, threshold=10.0, max idle iteration = 5, number of nodes to be excluded = 0, number of nodes to be included = 0]<\/p>\n<p>Time Stamp\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Iteration#\u00a0 Bytes Already Moved\u00a0 Bytes Left To Move\u00a0 Bytes Being Moved<\/p>\n<p>16\/04\/08 14:26:56 INFO net.NetworkTopology: Adding a new node: \/default-rack\/192.168.1.231:50010<\/p>\n<p>16\/04\/08 14:26:56 INFO net.NetworkTopology: Adding a new node: \/default-rack\/192.168.1.229:50010<\/p>\n<p>16\/04\/08 14:26:56 INFO net.NetworkTopology: Adding a new node: \/default-rack\/192.168.1.213:50010<\/p>\n<p>16\/04\/08 14:26:56 INFO net.NetworkTopology: Adding a new node: \/default-rack\/192.168.1.208:50010<\/p>\n<p>16\/04\/08 14:26:56 INFO net.NetworkTopology: Adding a new node: \/default-rack\/192.168.1.232:50010<\/p>\n<p>16\/04\/08 14:26:56 INFO net.NetworkTopology: Adding a new node: \/default-rack\/192.168.1.207:50010<\/p>\n<p>16\/04\/08 14:26:56 INFO balancer.Balancer: 5 over-utilized: [192.168.1.231:50010:DISK, 192.168.1.229:50010:DISK, 192.168.1.213:50010:DISK, 192.168.1.208:50010:DISK, 192.168.1.232:50010:DISK]<\/p>\n<p>16\/04\/08 14:26:56 INFO balancer.Balancer: 1 underutilized\uff08\u672a\u5145\u5206\u5229\u7528\u7684\uff09: [192.168.1.207:50010:DISK] # \u6570\u636e\u5c06\u79fb\u5411\u8be5\u8282\u70b9<\/p>\n<p>16\/04\/08 14:26:56 INFO balancer.Balancer: Need to move 816.01 GB to make the cluster balanced. # \u9700\u8981\u79fb\u52a8816.01G\u6570\u636e\u8fbe\u5230\u5e73\u8861<\/p>\n<p>16\/04\/08 14:26:56 INFO balancer.Balancer: Decided to move 10 GB bytes from 192.168.1.231:50010:DISK to 192.168.1.207:50010:DISK # \u4ece192.168.1.231\u79fb\u52a810G\u6570\u636e\u5230192.168.1.207<\/p>\n<p>16\/04\/08 14:26:56 INFO balancer.Balancer: Will move 10 GB in this iteration<\/p>\n<p>16\/04\/08 14:32:58 INFO balancer.Dispatcher: Successfully moved blk_1073749366_8542 with size=77829046 from 192.168.1.231:50010:DISK to 192.168.1.207:50010:DISK through 192.168.1.213:50010<\/p>\n<p>16\/04\/08 14:32:59 INFO balancer.Dispatcher: Successfully moved blk_1073749386_8562 with size=77829046 from 192.168.1.231:50010:DISK to 192.168.1.207:50010:DISK through 192.168.1.231:50010<\/p>\n<p>16\/04\/08 14:33:34 INFO balancer.Dispatcher: Successfully moved blk_1073749378_8554 with size=77829046 from 192.168.1.231:50010:DISK to 192.168.1.207:50010:DISK through 192.168.1.231:50010<\/p>\n<p>16\/04\/08 14:34:38 INFO balancer.Dispatcher: Successfully moved blk_1073749371_8547 with size=134217728 from 192.168.1.231:50010:DISK to 192.168.1.207:50010:DISK through 192.168.1.213:50010<\/p>\n<p>16\/04\/08 14:34:54 INFO balancer.Dispatcher: Successfully moved blk_1073749395_8571 with size=134217728 from 192.168.1.231:50010:DISK to 192.168.1.207:50010:DISK through 192.168.1.231:50010<\/p>\n<p>Apr 8, 2016 2:35:01 PM\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 478.67 MB\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 816.01 GB\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 10 GB<\/p>\n<p>16\/04\/08 14:35:10 INFO net.NetworkTopology: Adding a new node: \/default-rack\/192.168.1.213:50010<\/p>\n<p>16\/04\/08 14:35:10 INFO net.NetworkTopology: Adding a new node: \/default-rack\/192.168.1.229:50010<\/p>\n<p>16\/04\/08 14:35:10 INFO net.NetworkTopology: Adding a new node: \/default-rack\/192.168.1.232:50010<\/p>\n<p>16\/04\/08 14:35:10 INFO net.NetworkTopology: Adding a new node: \/default-rack\/192.168.1.231:50010<\/p>\n<p>16\/04\/08 14:35:10 INFO net.NetworkTopology: Adding a new node: \/default-rack\/192.168.1.208:50010<\/p>\n<p>16\/04\/08 14:35:10 INFO net.NetworkTopology: Adding a new node: \/default-rack\/192.168.1.207:50010<\/p>\n<p>16\/04\/08 14:35:10 INFO balancer.Balancer: 5 over-utilized: [192.168.1.213:50010:DISK, 192.168.1.229:50010:DISK, 192.168.1.232:50010:DISK, 192.168.1.231:50010:DISK, 192.168.1.208:50010:DISK]<\/p>\n<p>16\/04\/08 14:35:10 INFO balancer.Balancer: 1 underutilized\uff08\u672a\u5145\u5206\u5229\u7528\u7684\uff09: [192.168.1.207:50010:DISK]<\/p>\n<p>16\/04\/08 14:35:10 INFO balancer.Balancer: Need to move 815.45 GB to make the cluster balanced.<\/p>\n<p>16\/04\/08 14:35:10 INFO balancer.Balancer: Decided to move 10 GB bytes from 192.168.1.213:50010:DISK to 192.168.1.207:50010:DISK<\/p>\n<p>16\/04\/08 14:35:10 INFO balancer.Balancer: Will move 10 GB in this iteration<\/p>\n<p>16\/04\/08 14:41:18 INFO balancer.Dispatcher: Successfully moved blk_1073760371_19547 with size=77829046 from 192.168.1.213:50010:DISK to 192.168.1.207:50010:DISK through 192.168.1.213:50010<\/p>\n<p>16\/04\/08 14:41:19 INFO balancer.Dispatcher: Successfully moved blk_1073760385_19561 with size=77829046 from 192.168.1.213:50010:DISK to 192.168.1.207:50010:DISK through 192.168.1.213:50010<\/p>\n<p>16\/04\/08 14:41:22 INFO balancer.Dispatcher: Successfully moved blk_1073760393_19569 with size=77829046 from 192.168.1.213:50010:DISK to 192.168.1.207:50010:DISK through 192.168.1.213:50010<\/p>\n<p>16\/04\/08 14:41:23 INFO balancer.Dispatcher: Successfully moved blk_1073760363_19539 with size=77829046 from 192.168.1.213:50010:DISK to 192.168.1.207:50010:DISK through 192.168.1.213:50010<\/p>\n<h5><a name=\"_Toc13643\"><\/a>10.12.9. \u65b0\u589eJournalNode<\/h5>\n<p>\u627e\u4e00\u53f0\u5df2\u6709JournalNode\u8282\u70b9\uff0c\u4fee\u6539\u5b83\u7684hdfs-site.xml\uff0c\u5c06\u65b0\u589e\u7684Journal\u5305\u542b\u8fdb\u6765\uff0c\u5982\u5728<\/p>\n<p>qjournal:\/\/hadoop-030:8485;hadoop-031:8485;hadoop-032:8485\/test<\/p>\n<p>\u7684\u57fa\u7840\u4e0a\u65b0\u589ehadoop-033\u548chadoop-034\u4e24\u4e2aJournalNode\uff1a<\/p>\n<p>qjournal:\/\/hadoop-030:8485;hadoop-031:8485;hadoop-032:8485;hadoop-033:8485;hadoop-034:8485\/test<\/p>\n<p>\u7136\u540e\u5c06\u5b89\u88c5\u76ee\u5f55\u548c\u6570\u636e\u76ee\u5f55\uff08hdfs-site.xml\u4e2d\u7684dfs.journalnode.edits.dir\u6307\u5b9a\u7684\u76ee\u5f55\uff09\u90fd\u590d\u5236\u5230\u65b0\u7684\u8282\u70b9\u3002<\/p>\n<p>\u5982\u679c\u4e0d\u590d\u5236JournalNode\u7684\u6570\u636e\u76ee\u5f55\uff0c\u5219\u65b0\u8282\u70b9\u4e0a\u7684JournalNode\u4f1a\u62a5\u9519\u201cJournal Storage Directory \/data\/journal\/test not formatted\u201d\uff0c\u5c06\u6765\u7684\u7248\u672c\u53ef\u80fd\u4f1a\u5b9e\u73b0\u81ea\u52a8\u540c\u6b65\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u5c31\u53ef\u4ee5\u5728\u65b0\u8282\u70b9\u4e0a\u542f\u52a8\u597dJournalNode\uff08\u4e0d\u9700\u8981\u505a\u4ec0\u4e48\u521d\u59cb\u5316\uff09\uff0c\u5e76\u91cd\u542f\u4e0bNameNode\u3002\u6ce8\u610f\u89c2\u5bdfJournalNode\u65e5\u5fd7\uff0c\u67e5\u770b\u662f\u5426\u542f\u52a8\u6210\u529f\uff0c\u5f53\u65e5\u5fd7\u663e\u793a\u4e3a\u4ee5\u4e0b\u8fd9\u6837\u7684INFO\u7ea7\u522b\u65e5\u5fd7\u5219\u8868\u793a\u542f\u52a8\u6210\u529f\uff1a<\/p>\n<p>2016-04-26 10:31:11,160 INFO org.apache.hadoop.hdfs.server.namenode.FileJournalManager: Finalizing edits file \/data\/journal\/test\/current\/edits_inprogress_0000000000000194269 -&gt; \/data\/journal\/test\/current\/edits_0000000000000194269-0000000000000194270<\/p>\n<h3><a name=\"_Toc24055\"><\/a>11. \u542f\u52a8YARN<\/h3>\n<h4><a name=\"_Toc26778\"><\/a>11.1. \u542f\u52a8YARN<\/h4>\n<p>1) \u8fdb\u5165$HADOOP_HOME\/sbin\u76ee\u5f55<\/p>\n<p>2) \u5728\u4e3b\u5907\u4e24\u53f0\u90fd\u6267\u884c\uff1astart-yarn.sh\uff0c\u5373\u5f00\u59cb\u542f\u52a8YARN<\/p>\n<p>\u82e5\u542f\u52a8\u6210\u529f\uff0c\u5219\u5728Master\u8282\u70b9\u6267\u884cjps\uff0c\u53ef\u4ee5\u770b\u5230ResourceManager\uff1a<\/p>\n<p>&gt; jps<\/p>\n<p>24689 NameNode<\/p>\n<p>30156 Jps<\/p>\n<p>28861 ResourceManager<\/p>\n<p>\u5728Slaves\u8282\u70b9\u6267\u884cjps\uff0c\u53ef\u4ee5\u770b\u5230NodeManager\uff1a<\/p>\n<p>$ jps<\/p>\n<p>14019 NodeManager<\/p>\n<p>23257 DataNode<\/p>\n<p>15115 Jps<\/p>\n<p>\u5982\u679c\u53ea\u9700\u8981\u5355\u72ec\u542f\u52a8\u6307\u5b9a\u8282\u70b9\u4e0a\u7684ResourceManager\uff0c\u8fd9\u6837\uff1a<\/p>\n<p>.\/yarn-daemon.sh start resourcemanager<\/p>\n<p>\u5bf9\u4e8eNodeManager\uff0c\u5219\u662f\u8fd9\u6837\uff1a<\/p>\n<p>.\/yarn-daemon.sh start nodemanager<\/p>\n<h4><a name=\"_Toc12524\"><\/a>11.2. \u6267\u884cYARN\u547d\u4ee4<\/h4>\n<h5><a name=\"_Toc31931\"><\/a>11.2.1. yarn node -list<\/h5>\n<p>\u5217\u4e3eYARN\u96c6\u7fa4\u4e2d\u7684\u6240\u6709NodeManager\uff0c\u5982\uff08\u6ce8\u610f\u53c2\u6570\u95f4\u7684\u7a7a\u683c\uff0c\u76f4\u63a5\u6267\u884cyarn\u53ef\u4ee5\u770b\u5230\u4f7f\u7528\u5e2e\u52a9\uff09\uff1a<\/p>\n<p>&gt; yarn node -list<\/p>\n<p>Total Nodes:3<\/p>\n<p>Node-Id\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Node-State Node-Http-Address\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Number-of-Running-Containers<\/p>\n<p>localhost:45980\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RUNNING\u00a0\u00a0\u00a0 localhost:8042\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0<\/p>\n<p>localhost:47551\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RUNNING\u00a0\u00a0\u00a0 localhost:8042\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0<\/p>\n<p>localhost:58394\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RUNNING\u00a0\u00a0\u00a0 localhost:8042\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0<\/p>\n<h5><a name=\"_Toc21162\"><\/a>11.2.2. yarn node -status<\/h5>\n<p>\u67e5\u770b\u6307\u5b9aNodeManager\u7684\u72b6\u6001\uff0c\u5982\uff1a<\/p>\n<p>&gt; yarn node -status localhost:47551<\/p>\n<p>Node Report :<\/p>\n<p>Node-Id : localhost:47551<\/p>\n<p>Rack : \/default-rack<\/p>\n<p>Node-State : RUNNING<\/p>\n<p>Node-Http-Address : localhost:8042<\/p>\n<p>Last-Health-Update : \u661f\u671f\u4e94 18\/\u56db\u6708\/14 01:45:41:555GMT<\/p>\n<p>Health-Report :<\/p>\n<p>Containers : 0<\/p>\n<p>Memory-Used : 0MB<\/p>\n<p>Memory-Capacity : 8192MB<\/p>\n<p>CPU-Used : 0 vcores<\/p>\n<p>CPU-Capacity : 8 vcores<\/p>\n<h5><a name=\"_Toc28084\"><\/a>11.2.3. yarn rmadmin -getServiceState rm1<\/h5>\n<p>\u67e5\u770brm1\u7684\u4e3b\u5907\u72b6\u6001\uff0c\u5373\u67e5\u770b\u5b83\u662f\u4e3b\uff08active\uff09\u8fd8\u662f\u5907\uff08standby\uff09\u3002<\/p>\n<h5><a name=\"_Toc11073\"><\/a>11.2.4. yarn rmadmin -transitionToStandby rm1<\/h5>\n<p>\u5c06rm1\u4ece\u4e3b\u5207\u4e3a\u5907\u3002<\/p>\n<p>\u66f4\u591a\u7684yarn\u547d\u4ee4\u53ef\u4ee5\u53c2\u8003\uff1a<\/p>\n<p><a href=\"https:\/\/hadoop.apache.org\/docs\/current\/hadoop-yarn\/hadoop-yarn-site\/YarnCommands.html\">https:\/\/hadoop.apache.org\/docs\/current\/hadoop-yarn\/hadoop-yarn-site\/YarnCommands.html<\/a>\u3002<\/p>\n<h3><a name=\"_Toc22286\"><\/a>12. \u8fd0\u884cMapReduce\u7a0b\u5e8f<\/h3>\n<p>\u5728\u5b89\u88c5\u76ee\u5f55\u7684share\/hadoop\/mapreduce\u5b50\u76ee\u5f55\u4e0b\uff0c\u6709\u73b0\u5b58\u7684\u793a\u4f8b\u7a0b\u5e8f\uff1a<\/p>\n<p>hadoop@VM-40-171-sles10-64:~\/hadoop&gt; ls share\/hadoop\/mapreduce<\/p>\n<p>hadoop-mapreduce-client-app-2.7.2.jar\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop-mapreduce-client-jobclient-2.7.2-tests.jar<\/p>\n<p>hadoop-mapreduce-client-common-2.7.2.jar\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop-mapreduce-client-shuffle-2.7.2.jar<\/p>\n<p>hadoop-mapreduce-client-core-2.7.2.jar\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hadoop-mapreduce-examples-2.7.2.jar<\/p>\n<p>hadoop-mapreduce-client-hs-2.7.2.jar\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 lib<\/p>\n<p>hadoop-mapreduce-client-hs-plugins-2.7.2.jar\u00a0 lib-examples<\/p>\n<p>hadoop-mapreduce-client-jobclient-2.7.2.jar\u00a0\u00a0 sources<\/p>\n<p>\u8dd1\u4e00\u4e2a\u793a\u4f8b\u7a0b\u5e8f\u8bd5\u8bd5\uff1a<\/p>\n<p>hdfs dfs -put \/etc\/hosts\u00a0 hdfs:\/\/test\/in\/<\/p>\n<p>hadoop jar .\/share\/hadoop\/mapreduce\/hadoop-mapreduce-examples-2.7.2.jar wordcount hdfs:\/\/test\/in\/ hdfs:\/\/test\/out\/<\/p>\n<p>\u8fd0\u884c\u8fc7\u7a0b\u4e2d\uff0c\u4f7f\u7528java\u7684jps\u547d\u4ee4\uff0c\u53ef\u4ee5\u770b\u5230yarn\u542f\u52a8\u4e86\u540d\u4e3aYarnChild\u7684\u8fdb\u7a0b\u3002<\/p>\n<p>wordcount\u8fd0\u884c\u5b8c\u6210\u540e\uff0c\u7ed3\u679c\u4f1a\u4fdd\u5b58\u5728out\u76ee\u5f55\u4e0b\uff0c\u4fdd\u5b58\u7ed3\u679c\u7684\u6587\u4ef6\u540d\u7c7b\u4f3c\u4e8e\u201cpart-r-00000\u201d\u3002\u53e6\u5916\uff0c\u8dd1\u8fd9\u4e2a\u793a\u4f8b\u7a0b\u5e8f\u6709\u4e24\u4e2a\u9700\u6c42\u6ce8\u610f\u7684\u70b9\uff1a<\/p>\n<p>1) in\u76ee\u5f55\u4e0b\u8981\u6709\u6587\u672c\u6587\u4ef6\uff0c\u6216in\u5373\u4e3a\u88ab\u7edf\u8ba1\u7684\u6587\u672c\u6587\u4ef6\uff0c\u53ef\u4ee5\u4e3aHDFS\u4e0a\u7684\u6587\u4ef6\u6216\u76ee\u5f55\uff0c\u4e5f\u53ef\u4ee5\u4e3a\u672c\u5730\u6587\u4ef6\u6216\u76ee\u5f55<\/p>\n<p>2) out\u76ee\u5f55\u4e0d\u80fd\u5b58\u5728\uff0c\u7a0b\u5e8f\u4f1a\u81ea\u52a8\u53bb\u521b\u5efa\u5b83\uff0c\u5982\u679c\u5df2\u7ecf\u5b58\u5728\u5219\u4f1a\u62a5\u9519\u3002<\/p>\n<p>\u5305hadoop-mapreduce-examples-2.7.2.jar\u4e2d\u542b\u6709\u591a\u4e2a\u793a\u4f8b\u7a0b\u5e8f\uff0c\u4e0d\u5e26\u53c2\u6570\u8fd0\u884c\uff0c\u5373\u53ef\u770b\u5230\u7528\u6cd5\uff1a<\/p>\n<p>&gt; hadoop jar .\/share\/hadoop\/mapreduce\/hadoop-mapreduce-examples-2.7.2.jar wordcount<\/p>\n<p>Usage: wordcount<\/p>\n<p>&gt; hadoop jar .\/share\/hadoop\/mapreduce\/hadoop-mapreduce-examples-2.7.2.jar<\/p>\n<p>An example program must be given as the first argument.<\/p>\n<p>Valid program names are:<\/p>\n<p>aggregatewordcount: An Aggregate based map\/reduce program that counts the words in the input files.<\/p>\n<p>aggregatewordhist: An Aggregate based map\/reduce program that computes the histogram of the words in the input files.<\/p>\n<p>bbp: A map\/reduce program that uses Bailey-Borwein-Plouffe to compute exact digits of Pi.<\/p>\n<p>dbcount: An example job that count the pageview counts from a database.<\/p>\n<p>distbbp: A map\/reduce program that uses a BBP-type formula to compute exact bits of Pi.<\/p>\n<p>grep: A map\/reduce program that counts the matches of a regex in the input.<\/p>\n<p>join: A job that effects a join over sorted, equally partitioned datasets<\/p>\n<p>multifilewc: A job that counts words from several files.<\/p>\n<p>pentomino: A map\/reduce tile laying program to find solutions to pentomino problems.<\/p>\n<p>pi: A map\/reduce program that estimates Pi using a quasi-Monte Carlo method.<\/p>\n<p>randomtextwriter: A map\/reduce program that writes 10GB of random textual data per node.<\/p>\n<p>randomwriter: A map\/reduce program that writes 10GB of random data per node.<\/p>\n<p>secondarysort: An example defining a secondary sort to the reduce.<\/p>\n<p>sort: A map\/reduce program that sorts the data written by the random writer.<\/p>\n<p>sudoku: A sudoku solver.<\/p>\n<p>teragen: Generate data for the terasort<\/p>\n<p>terasort: Run the terasort<\/p>\n<p>teravalidate: Checking results of terasort<\/p>\n<p>wordcount: A map\/reduce program that counts the words in the input files.<\/p>\n<p>wordmean: A map\/reduce program that counts the average length of the words in the input files.<\/p>\n<p>wordmedian: A map\/reduce program that counts the median length of the words in the input files.<\/p>\n<p>wordstandarddeviation: A map\/reduce program that counts the standard deviation of the length of the words in the input files.<\/p>\n<p>\u4fee\u6539\u65e5\u5fd7\u7ea7\u522b\u4e3aDEBBUG\uff0c\u5e76\u6253\u5c4f\uff1a<\/p>\n<p>export HADOOP_ROOT_LOGGER=DEBUG,console<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[191],"class_list":["post-4737","post","type-post","status-publish","format-standard","hentry","category-5","tag-hadoop","category-5-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts\/4737","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4737"}],"version-history":[{"count":7,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts\/4737\/revisions"}],"predecessor-version":[{"id":4746,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=\/wp\/v2\/posts\/4737\/revisions\/4746"}],"wp:attachment":[{"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4737"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4737"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hmouse.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4737"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}