{"id":58101,"date":"2023-07-12T18:14:12","date_gmt":"2023-07-12T10:14:12","guid":{"rendered":"http:\/\/gulass.cn\/?p=58101"},"modified":"2023-07-12T18:14:12","modified_gmt":"2023-07-12T10:14:12","slug":"hadoop-high-available-2","status":"publish","type":"post","link":"https:\/\/gulass.cn\/hadoop-high-available-2.html","title":{"rendered":"Hadoop 2.6.0 HA\u9ad8\u53ef\u7528\u96c6\u7fa4\u914d\u7f6e\u8be6\u89e3\uff08\u4e8c\uff09"},"content":{"rendered":"
Zookeeper\u96c6\u7fa4\u5b89\u88c5<\/strong><\/div>\n

Zookeeper\u662f\u4e00\u4e2a\u5f00\u6e90\u5206\u5e03\u5f0f\u534f\u8c03\u670d\u52a1\uff0c\u5176\u72ec\u7279\u7684Leader-Follower\u96c6\u7fa4\u7ed3\u6784\uff0c\u5f88\u597d\u7684\u89e3\u51b3\u4e86\u5206\u5e03\u5f0f\u5355\u70b9\u95ee\u9898\u3002\u76ee\u524d\u4e3b\u8981\u7528\u4e8e\u8bf8\u5982\uff1a\u7edf\u4e00\u547d\u540d\u670d\u52a1\u3001\u914d\u7f6e\u7ba1\u7406\u3001\u9501\u670d\u52a1\u3001\u96c6\u7fa4\u7ba1\u7406\u7b49\u573a\u666f\u3002\u5927\u6570\u636e\u5e94\u7528\u4e2d\u4e3b\u8981\u4f7f\u7528Zookeeper\u7684\u96c6\u7fa4\u7ba1\u7406\u529f\u80fd\u3002<\/p>\n

\u672c\u96c6\u7fa4\u4f7f\u7528zookeeper-3.4.5-cdh5.7.1\u7248\u672c\u3002\u9996\u5148\u5728Hadoop-slave1\u8282\u70b9\u5b89\u88c5Zookeeper\uff0c\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n

\/\/ \u65b0\u5efa\u76ee\u5f55\r\n\r\n$ mkdir app\/cdh\r\n\r\n\/\/ \u89e3\u538bzookeeper\u5b89\u88c5\u5305\r\n\r\n$ tar -xvf zookeeper-3.4.5-cdh5.7.1.tar.gz -C app\/cdh\/\r\n\r\n\/\/ \u5220\u9664\u5b89\u88c5\u5305\r\n\r\n$ rm -rf zookeeper-3.4.5-cdh5.7.1.tar.gz\r\n\r\n\/\/ \u914d\u7f6e\u7528\u6237\u73af\u5883\u53d8\u91cf\r\n\r\n$ vim .bash_profile\r\n\r\nexport ZOOKEEPER_HOME=\/home\/hadoop\/app\/cdh\/zookeeper-3.4.5-cdh5.7.1\r\n\r\nexport PATH=$PATH:$ZOOKEEPER_HOME\/bin\r\n\r\n\/\/ \u4f7f\u4fee\u6539\u7684\u73af\u5883\u53d8\u91cf\u751f\u6548\r\n\r\n$ source.bash_profile\r\n\r\n\/\/ \u4fee\u6539zookeeper\u7684\u914d\u7f6e\u6587\u4ef6\r\n\r\n$ cd app\/cdh\/zookeeper-3.4.5-cdh5.7.1\/conf\/\r\n\r\n$ cp zoo_sample.cfg zoo.cfg\r\n\r\n$ vim zoo.cfg\r\n\r\n# \u5ba2\u6237\u7aef\u5fc3\u8df3\u65f6\u95f4(\u6beb\u79d2)\r\n\r\ntickTime=2000\r\n\r\n# \u5141\u8bb8\u5fc3\u8df3\u95f4\u9694\u7684\u6700\u5927\u65f6\u95f4\r\n\r\ninitLimit=10\r\n\r\n# \u540c\u6b65\u65f6\u9650\r\n\r\nsyncLimit=5\r\n\r\n# \u6570\u636e\u5b58\u50a8\u76ee\u5f55\r\n\r\ndataDir=\/home\/hadoop\/app\/cdh\/zookeeper-3.4.5-cdh5.7.1\/data\r\n\r\n# \u6570\u636e\u65e5\u5fd7\u5b58\u50a8\u76ee\u5f55\r\n\r\ndataLogDir=\/home\/hadoop\/app\/cdh\/zookeeper-3.4.5-cdh5.7.1\/data\/log\r\n\r\n# \u7aef\u53e3\u53f7\r\n\r\nclientPort=2181\r\n\r\n# \u96c6\u7fa4\u8282\u70b9\u548c\u670d\u52a1\u7aef\u53e3\u914d\u7f6e\r\n\r\nserver.1=hadoop-slave1:2888:3888\r\n\r\nserver.2=hadoop-slave2:2888:3888\r\n\r\nserver.3=hadoop-slave3:2888:3888\r\n\r\n# \u4ee5\u4e0b\u4e3a\u4f18\u5316\u914d\u7f6e\r\n\r\n# \u670d\u52a1\u5668\u6700\u5927\u8fde\u63a5\u6570\uff0c\u9ed8\u8ba4\u4e3a10\uff0c\u6539\u4e3a0\u8868\u793a\u65e0\u9650\u5236\r\n\r\nmaxClientCnxns=0\r\n\r\n# \u5feb\u7167\u6570\r\n\r\nautopurge.snapRetainCount=3\r\n\r\n# \u5feb\u7167\u6e05\u7406\u65f6\u95f4\uff0c\u9ed8\u8ba4\u4e3a0\r\n\r\nautopurge.purgeInterval=1\r\n\r\n\/\/ \u521b\u5efazookeeper\u7684\u6570\u636e\u5b58\u50a8\u76ee\u5f55\u548c\u65e5\u5fd7\u5b58\u50a8\u76ee\u5f55\r\n\r\n$ cd ..\r\n\r\n$ mkdir -p data\/log\r\n\r\n\/\/ \u5728data\u76ee\u5f55\u4e2d\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6myid\uff0c\u8f93\u5165\u5185\u5bb9\u4e3a1\r\n\r\n$ echo \"1\" >> data\/myid\r\n\r\n\/\/ \u4fee\u6539zookeeper\u7684\u65e5\u5fd7\u8f93\u51fa\u8def\u5f84(\u6ce8\u610fCDH\u7248\u4e0e\u539f\u751f\u7248\u914d\u7f6e\u6587\u4ef6\u4e0d\u540c)\r\n\r\n$ vim libexec\/zkEnv.sh\r\n\r\nif [ \"x${ZOO_LOG_DIR}\" = \"x\" ]\r\n\r\nthen\r\n\r\n   ZOO_LOG_DIR=\"$ZOOKEEPER_HOME\/logs\"\r\n\r\nfi\r\n\r\nif [ \"x${ZOO_LOG4J_PROP}\" = \"x\" ]\r\n\r\nthen\r\n\r\n   ZOO_LOG4J_PROP=\"INFO,ROLLINGFILE\"\r\n\r\nfi\r\n\r\n\/\/ \u4fee\u6539zookeeper\u7684\u65e5\u5fd7\u914d\u7f6e\u6587\u4ef6\r\n\r\n$ vim conf\/log4j.properties\r\n\r\nzookeeper.root.logger=INFO,ROLLINGFILE\r\n\r\n\/\/ \u521b\u5efa\u65e5\u5fd7\u76ee\u5f55\r\n\r\n$ mkdir logs\r\n\r\n\u5c06hadoop-slave1\u8282\u70b9\u4e0a\u7684Zookeeper\u76ee\u5f55\u540c\u6b65\u5230hadoop-slave2\u548chadoop-slave3\u8282\u70b9\uff0c\u5e76\u4fee\u6539Zookeeper\u7684\u6570\u636e\u6587\u4ef6\u3002\u6b64\u5916\uff0c\u4e0d\u8981\u5fd8\u8bb0\u8bbe\u7f6e\u7528\u6237\u73af\u5883\u53d8\u91cf\u3002\r\n\r\n\/\/ \u5728hadoop-slave1\u4e2d\u5c06zookeeper\u76ee\u5f55\u590d\u5236\u5230\u5176\u5b83\u8282\u70b9\r\n\r\n$ cd ~\r\n\r\n$ scp -r app\/cdh\/zookeeper-3.4.5-cdh5.7.1hadoop-slave2:\/home\/hadoop\/app\/cdh\r\n\r\n$ scp -r app\/cdh\/zookeeper-3.4.5-cdh5.7.1 hadoop-slave3:\/home\/hadoop\/app\/cdh\r\n\r\n\/\/\u5728hadoop-slave2\u4e2d\u4fee\u6539data\u76ee\u5f55\u4e2d\u7684myid\u6587\u4ef6\r\n\r\n$ echo \"2\" >app\/cdh\/zookeeper-3.4.5-cdh5.7.1\/data\/myid\r\n\r\n\/\/\u5728hadoop-slave3\u4e2d\u4fee\u6539data\u76ee\u5f55\u4e2d\u7684myid\u6587\u4ef6\r\n\r\n$ echo \"3\" >app\/cdh\/zookeeper-3.4.5-cdh5.7.1\/data\/myid\r\n\r\n\u6700\u540e\uff0c\u5728\u5b89\u88c5\u4e86Zookeeper\u7684\u5404\u8282\u70b9\u4e0a\u542f\u52a8Zookeeper\uff0c\u5e76\u67e5\u770b\u8282\u70b9\u72b6\u6001\uff0c\u65b9\u6cd5\u5982\u4e0b\uff1a\r\n\r\n\/\/ \u542f\u52a8\r\n\r\n$ zkServer.sh start\r\n\r\n\/\/ \u67e5\u770b\u72b6\u6001\r\n\r\n$ zkServer.sh status\r\n\r\n\/\/ \u5173\u95ed\r\n\r\n$ zkServer.sh stop\r\n<\/pre>\n
Hadoop HA\u914d\u7f6e<\/strong><\/div>\n
\r\n\/\/ \u5728hadoop-master1\u8282\u70b9\u89e3\u538bhadoop\u5b89\u88c5\u5305\r\n$ tar-xvf hadoop-2.6.0-cdh5.7.1.tar.gz -C \/home\/hadoop\/app\/cdh\/\r\n\r\n\/\/ \u5220\u9664\u5b89\u88c5\u5305\r\n$ rmhadoop-2.6.0-cdh5.7.1.tar.gz\r\n\r\n\/\/ \u4fee\u6539hadoop-env.sh\u6587\u4ef6\r\n$ cd\/home\/hadoop\/app\/cdh\/hadoop-2.6.0-cdh5.7.1\/etc\/hadoop\r\n\r\n$ vimhadoop-env.sh\r\nexportJAVA_HOME=\/home\/hadoop\/app\/jdk1.7.0_79\r\n<\/pre>\n
\r\n\/\/ \u914d\u7f6ecore-site.xml\u6587\u4ef6\r\n$ vim core-site.xml\r\n\r\n<configuration>\r\n  <!-- \u6307\u5b9ahdfs\u7684nameservices\u540d\u79f0\u4e3amycluster\uff0c\u4e0ehdfs-site.xml\u7684HA\u914d\u7f6e\u76f8\u540c -->\r\n  <property>\r\n    <name>fs.defaultFS<\/name>\r\n    <value>hdfs:\/\/mycluster<\/value>\r\n  <\/property>\r\n\t\r\n  <!-- \u6307\u5b9a\u7f13\u5b58\u6587\u4ef6\u5b58\u50a8\u7684\u8def\u5f84 -->\r\n  <property>\r\n    <name>hadoop.tmp.dir<\/name>\r\n    <value>\/home\/hadoop\/app\/cdh\/hadoop-2.6.0-cdh5.7.1\/data\/tmp<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u914d\u7f6ehdfs\u6587\u4ef6\u88ab\u6c38\u4e45\u5220\u9664\u524d\u4fdd\u7559\u7684\u65f6\u95f4\uff08\u5355\u4f4d\uff1a\u5206\u949f\uff09\uff0c\u9ed8\u8ba4\u503c\u4e3a0\u8868\u660e\u5783\u573e\u56de\u6536\u7ad9\u529f\u80fd\u5173\u95ed -->\r\n  <property>\r\n    <name>fs.trash.interval<\/name>\r\n    <value>1440<\/value>\r\n  <\/property>\r\n  \r\n  <!-- \u6307\u5b9azookeeper\u5730\u5740\uff0c\u914d\u7f6eHA\u65f6\u9700\u8981 -->\r\n  <property>\r\n    <name>ha.zookeeper.quorum<\/name>\r\n    <value>hadoop-slave1:2181,hadoop-slave2:2181,hadoop-slave3:2181<\/value>\r\n  <\/property>\r\n<\/configuration><\/pre>\n
\r\n\/\/ \u914d\u7f6ehdfs-site.xml\u6587\u4ef6\r\n$ vim hdfs-site.xml\r\n\r\n<configuration>\r\n  <!-- \u6307\u5b9ahdfs\u5143\u6570\u636e\u5b58\u50a8\u7684\u8def\u5f84 -->\r\n  <property>\r\n    <name>dfs.namenode.name.dir<\/name>\r\n    <value>\/home\/hadoop\/app\/cdh\/hadoop-2.6.0-cdh5.7.1\/data\/namenode<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u6307\u5b9ahdfs\u6570\u636e\u5b58\u50a8\u7684\u8def\u5f84 -->\r\n  <property>\r\n    <name>dfs.datanode.data.dir<\/name>\r\n    <value>\/home\/hadoop\/app\/cdh\/hadoop-2.6.0-cdh5.7.1\/data\/datanode<\/value>\r\n  <\/property>\r\n  \r\n  <!-- \u6570\u636e\u5907\u4efd\u7684\u4e2a\u6570 -->\r\n  <property>\r\n    <name>dfs.replication<\/name>\r\n    <value>3<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u5173\u95ed\u6743\u9650\u9a8c\u8bc1 -->\r\n  <property>\r\n    <name>dfs.permissions.enabled<\/name>\r\n    <value>false<\/value>\r\n  <\/property>\r\n  \r\n  <!-- \u5f00\u542fWebHDFS\u529f\u80fd\uff08\u57fa\u4e8eREST\u7684\u63a5\u53e3\u670d\u52a1\uff09 -->\r\n  <property>\r\n    <name>dfs.webhdfs.enabled<\/name>\r\n    <value>true<\/value>\r\n  <\/property>\r\n  \r\n  <!-- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\u4ee5\u4e0b\u4e3aHDFS HA\u7684\u914d\u7f6e\/\/\/\/\/\/\/\/\/\/\/\/\/\/ -->\r\n  <!-- \u6307\u5b9ahdfs\u7684nameservices\u540d\u79f0\u4e3amycluster -->\r\n  <property>\r\n    <name>dfs.nameservices<\/name>\r\n    <value>mycluster<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u6307\u5b9amycluster\u7684\u4e24\u4e2anamenode\u7684\u540d\u79f0\u5206\u522b\u4e3ann1,nn2 -->\r\n  <property>\r\n    <name>dfs.ha.namenodes.mycluster<\/name>\r\n    <value>nn1,nn2<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u914d\u7f6enn1,nn2\u7684rpc\u901a\u4fe1\u7aef\u53e3 -->\r\n  <property>\r\n    <name>dfs.namenode.rpc-address.mycluster.nn1<\/name>\r\n    <value>hadoop-master1:8020<\/value>\r\n  <\/property>\r\n  <property>\r\n    <name>dfs.namenode.rpc-address.mycluster.nn2<\/name>\r\n    <value>hadoop-master2:8020<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u914d\u7f6enn1,nn2\u7684http\u901a\u4fe1\u7aef\u53e3 -->\r\n  <property>\r\n    <name>dfs.namenode.http-address.mycluster.nn1<\/name>\r\n    <value>hadoop-master1:50070<\/value>\r\n  <\/property>\r\n  <property>\r\n    <name>dfs.namenode.http-address.mycluster.nn2<\/name>\r\n    <value>hadoop-master2:50070<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u6307\u5b9anamenode\u5143\u6570\u636e\u5b58\u50a8\u5728journalnode\u4e2d\u7684\u8def\u5f84 -->\r\n  <property>\r\n    <name>dfs.namenode.shared.edits.dir<\/name>\r\n    <value>qjournal:\/\/hadoop-slave1:8485;hadoop-slave2:8485;hadoop-slave3:8485\/mycluster<\/value>\r\n  <\/property>\r\n  \r\n  <!-- \u6307\u5b9ajournalnode\u65e5\u5fd7\u6587\u4ef6\u5b58\u50a8\u7684\u8def\u5f84 -->\r\n  <property>\r\n    <name>dfs.journalnode.edits.dir<\/name>\r\n    <value>\/home\/hadoop\/app\/cdh\/hadoop-2.6.0-cdh5.7.1\/data\/journal<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u6307\u5b9aHDFS\u5ba2\u6237\u7aef\u8fde\u63a5active namenode\u7684java\u7c7b -->\r\n  <property>\r\n    <name>dfs.client.failover.proxy.provider.mycluster<\/name>\r\n    <value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u914d\u7f6e\u9694\u79bb\u673a\u5236\u4e3assh -->\r\n  <property>\r\n    <name>dfs.ha.fencing.methods<\/name>\r\n    <value>sshfence<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u6307\u5b9a\u79d8\u94a5\u7684\u4f4d\u7f6e -->\r\n  <property>\r\n    <name>dfs.ha.fencing.ssh.private-key-files<\/name>\r\n    <value>\/home\/hadoop\/.ssh\/id_rsa<\/value>\r\n  <\/property>\r\n  \r\n  <!-- \u5f00\u542f\u81ea\u52a8\u6545\u969c\u8f6c\u79fb -->\r\n  <property>\r\n    <name>dfs.ha.automatic-failover.enabled<\/name>\r\n    <value>true<\/value>\r\n  <\/property>\r\n<\/configuration><\/pre>\n
\r\n\/\/ \u914d\u7f6emapred-site.xml\u6587\u4ef6\r\n$ vim mapred-site.xml\r\n\r\n<configuration>\r\n  <!-- \u6307\u5b9aMapReduce\u8ba1\u7b97\u6846\u67b6\u4f7f\u7528YARN -->\r\n  <property>\r\n    <name>mapreduce.framework.name<\/name>\r\n    <value>yarn<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u6307\u5b9ajobhistory server\u7684rpc\u5730\u5740 -->\r\n  <property>\r\n    <name>mapreduce.jobhistory.address<\/name>\r\n    <value>hadoop-master1:10020<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u6307\u5b9ajobhistory server\u7684http\u5730\u5740 -->\r\n  <property>\r\n    <name>mapreduce.jobhistory.webapp.address<\/name>\r\n    <value>hadoop-master1:19888<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u5f00\u542fuber\u6a21\u5f0f\uff08\u9488\u5bf9\u5c0f\u4f5c\u4e1a\u7684\u4f18\u5316\uff09 -->\r\n  <property>\r\n    <name>mapreduce.job.ubertask.enable<\/name>\r\n    <value>true<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u914d\u7f6e\u542f\u52a8uber\u6a21\u5f0f\u7684\u6700\u5927map\u6570 -->\r\n  <property>\r\n    <name>mapreduce.job.ubertask.maxmaps<\/name>\r\n    <value>9<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u914d\u7f6e\u542f\u52a8uber\u6a21\u5f0f\u7684\u6700\u5927reduce\u6570 -->\r\n  <property>\r\n    <name>mapreduce.job.ubertask.maxreduces<\/name>\r\n    <value>1<\/value>\r\n  <\/property>\r\n<\/configuration><\/pre>\n
\r\n\/\/ \u914d\u7f6eyarn-site.xml\u6587\u4ef6\r\n$ vim yarn-site.xml\r\n\r\n<configuration>\r\n  <!-- NodeManager\u4e0a\u8fd0\u884c\u7684\u9644\u5c5e\u670d\u52a1\uff0c\u9700\u914d\u7f6e\u6210mapreduce_shuffle\u624d\u53ef\u8fd0\u884cMapReduce\u7a0b\u5e8f -->\r\n  <property>\r\n    <name>yarn.nodemanager.aux-services<\/name>\r\n    <value>mapreduce_shuffle<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u914d\u7f6eWeb Application Proxy\u5b89\u5168\u4ee3\u7406\uff08\u9632\u6b62yarn\u88ab\u653b\u51fb\uff09 -->\r\n  <property>\r\n    <name>yarn.web-proxy.address<\/name>\r\n    <value>hadoop-master2:8888<\/value>\r\n  <\/property>\r\n  \r\n  <!-- \u5f00\u542f\u65e5\u5fd7 -->\r\n  <property>\r\n    <name>yarn.log-aggregation-enable<\/name>\r\n    <value>true<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u914d\u7f6e\u65e5\u5fd7\u5220\u9664\u65f6\u95f4\u4e3a7\u5929\uff0c-1\u4e3a\u7981\u7528\uff0c\u5355\u4f4d\u4e3a\u79d2 -->\r\n  <property>\r\n    <name>yarn.log-aggregation.retain-seconds<\/name>\r\n    <value>604800<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u4fee\u6539\u65e5\u5fd7\u76ee\u5f55 -->\r\n  <property>\r\n    <name>yarn.nodemanager.remote-app-log-dir<\/name>\r\n    <value>\/logs<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u914d\u7f6enodemanager\u53ef\u7528\u7684\u8d44\u6e90\u5185\u5b58 -->\r\n  <property>\r\n    <name>yarn.nodemanager.resource.memory-mb<\/name>\r\n    <value>2048<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u914d\u7f6enodemanager\u53ef\u7528\u7684\u8d44\u6e90CPU -->\r\n  <property>\r\n    <name>yarn.nodemanager.resource.cpu-vcores<\/name>\r\n    <value>2<\/value>\r\n  <\/property>\r\n  \r\n  <!-- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\u4ee5\u4e0b\u4e3aYARN HA\u7684\u914d\u7f6e\/\/\/\/\/\/\/\/\/\/\/\/\/\/ -->\r\n  <!-- \u5f00\u542fYARN HA -->\r\n  <property>\r\n    <name>yarn.resourcemanager.ha.enabled<\/name>\r\n    <value>true<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u542f\u7528\u81ea\u52a8\u6545\u969c\u8f6c\u79fb -->\r\n  <property>\r\n    <name>yarn.resourcemanager.ha.automatic-failover.enabled<\/name>\r\n    <value>true<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u6307\u5b9aYARN HA\u7684\u540d\u79f0 -->\r\n  <property>\r\n    <name>yarn.resourcemanager.cluster-id<\/name>\r\n    <value>yarncluster<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u6307\u5b9a\u4e24\u4e2aresourcemanager\u7684\u540d\u79f0 -->\r\n  <property>\r\n    <name>yarn.resourcemanager.ha.rm-ids<\/name>\r\n    <value>rm1,rm2<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u914d\u7f6erm1\uff0crm2\u7684\u4e3b\u673a -->\r\n  <property>\r\n    <name>yarn.resourcemanager.hostname.rm1<\/name>\r\n    <value>hadoop-master1<\/value>\r\n  <\/property>\r\n  <property>\r\n    <name>yarn.resourcemanager.hostname.rm2<\/name>\r\n    <value>hadoop-master2<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u914d\u7f6eYARN\u7684http\u7aef\u53e3 -->\r\n  <property>\r\n    <name>yarn.resourcemanager.webapp.address.rm1<\/name>\r\n    <value>hadoop-master1:8088<\/value>\r\n  <\/property>\t\r\n  <property>\r\n    <name>yarn.resourcemanager.webapp.address.rm2<\/name>\r\n    <value>hadoop-master2:8088<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u914d\u7f6ezookeeper\u7684\u5730\u5740 -->\r\n  <property>\r\n    <name>yarn.resourcemanager.zk-address<\/name>\r\n    <value>hadoop-slave1:2181,hadoop-slave2:2181,hadoop-slave3:2181<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u914d\u7f6ezookeeper\u7684\u5b58\u50a8\u4f4d\u7f6e -->\r\n  <property>\r\n    <name>yarn.resourcemanager.zk-state-store.parent-path<\/name>\r\n    <value>\/rmstore<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u5f00\u542fyarn resourcemanager restart -->\r\n  <property>\r\n    <name>yarn.resourcemanager.recovery.enabled<\/name>\r\n    <value>true<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u914d\u7f6eresourcemanager\u7684\u72b6\u6001\u5b58\u50a8\u5230zookeeper\u4e2d -->\r\n  <property>\r\n    <name>yarn.resourcemanager.store.class<\/name>\r\n    <value>org.apache.hadoop.yarn.server.resourcemanager.recovery.ZKRMStateStore<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u5f00\u542fyarn nodemanager restart -->\r\n  <property>\r\n    <name>yarn.nodemanager.recovery.enabled<\/name>\r\n    <value>true<\/value>\r\n  <\/property>\r\n\r\n  <!-- \u914d\u7f6enodemanager IPC\u7684\u901a\u4fe1\u7aef\u53e3 -->\r\n  <property>\r\n    <name>yarn.nodemanager.address<\/name>\r\n    <value>0.0.0.0:45454<\/value>\r\n  <\/property>\r\n<\/configuration><\/pre>\n
\r\n\/\/ \u914d\u7f6eslaves\u6587\u4ef6\r\n$ vimslaves\r\nhadoop-slave1\r\nhadoop-slave2\r\nhadoop-slave3\r\n\r\n\/\/ \u521b\u5efa\u914d\u7f6e\u6587\u4ef6\u4e2d\u6d89\u53ca\u7684\u76ee\u5f55\r\n$ cd\/home\/hadoop\/app\/cdh\/hadoop-2.6.0-cdh5.7.1\/\r\n\r\n$ mkdir-p data\/tmp\r\n\r\n$ mkdir-p data\/journal\r\n\r\n$ mkdir-p data\/namenode\r\n\r\n$ mkdir-p data\/datanode\r\n\r\n\/\/ \u5c06hadoop\u5de5\u4f5c\u76ee\u5f55\u540c\u6b65\u5230\u96c6\u7fa4\u5176\u5b83\u8282\u70b9\r\n$ scp-r \/home\/hadoop\/app\/cdh\/hadoop-2.6.0-cdh5.7.1\/hadoop-master2:\/home\/hadoop\/app\/cdh\/\r\nscp -r\/home\/hadoop\/app\/cdh\/hadoop-2.6.0-cdh5.7.1\/ hadoop-slave1:\/home\/hadoop\/app\/cdh\/\r\nscp -r\/home\/hadoop\/app\/cdh\/hadoop-2.6.0-cdh5.7.1\/ hadoop-slave2:\/home\/hadoop\/app\/cdh\/\r\nscp -r\/home\/hadoop\/app\/cdh\/hadoop-2.6.0-cdh5.7.1\/ hadoop-slave3:\/home\/hadoop\/app\/cdh\/\r\n\r\n\/\/ \u5728\u96c6\u7fa4\u5404\u8282\u70b9\u4e0a\u4fee\u6539\u7528\u6237\u73af\u5883\u53d8\u91cf\r\n$ vim .bash_profile\r\nexport HADOOP_HOME=\/home\/hadoop\/app\/cdh\/hadoop-2.6.0-cdh5.7.1\r\nexport LD_LIBRARY_PATH=$HADOOP_HOME\/lib\/native\r\nexport PATH=$PATH:$HADOOP_HOME\/bin:$HADOOP_HOME\/sbin\r\n\r\n\/\/ \u4f7f\u4fee\u6539\u7684\u73af\u5883\u53d8\u91cf\u751f\u6548\r\n$ source.bash_profile\r\n\r\n\/\/ \u89e3\u51b3\u672c\u5730\u5e93\u6587\u4ef6\u4e0d\u5b58\u5728\u7684\u95ee\u9898\r\n\u5728apache\u5b98\u7f51\u4e0b\u8f7dhadoop-2.6.0.tar.gz\uff0c\u89e3\u538b\u540e\u5c06lib\/native\u4e0b\u6240\u6709\u6587\u4ef6\u590d\u5236\u5230$HADOOP_HOME\/lib\/native\u4e2d\u3002\r\n<\/pre>\n
Hadoop\u96c6\u7fa4\u7684\u521d\u59cb\u5316<\/strong><\/div>\n
\r\n\/\/ \u542f\u52a8zookeeper\u96c6\u7fa4\uff08\u5206\u522b\u5728slave1\u3001slave2\u548cslave3\u4e0a\u6267\u884c\uff09\r\n$ zkServer.shstart\r\n\r\n\/\/ \u683c\u5f0f\u5316ZKFC\uff08\u5728master1\u4e0a\u6267\u884c\uff09\r\n$ hdfszkfc -formatZK\r\n\r\n\/\/ \u542f\u52a8journalnode\uff08\u5206\u522b\u5728slave1\u3001slave2\u548cslave3\u4e0a\u6267\u884c\uff09\r\n$ hadoop-daemon.shstart journalnode\r\n\r\n\/\/ \u683c\u5f0f\u5316HDFS\uff08\u5728master1\u4e0a\u6267\u884c\uff09\r\n$ hdfsnamenode -format\r\n\r\n\/\/ \u5c06\u683c\u5f0f\u5316\u540emaster1\u8282\u70b9hadoop\u5de5\u4f5c\u76ee\u5f55\u4e2d\u7684\u5143\u6570\u636e\u76ee\u5f55\u590d\u5236\u5230master2\u8282\u70b9\r\n$ scp-r app\/cdh\/hadoop-2.6.0-cdh5.7.1\/data\/namenode\/*hadoop-master2:\/home\/hadoop\/app\/cdh\/hadoop-2.6.0-cdh5.7.1\/data\/namenode\/\r\n\r\n\/\/ \u521d\u59cb\u5316\u5b8c\u6bd5\u540e\u53ef\u5173\u95edjournalnode\uff08\u5206\u522b\u5728slave1\u3001slave2\u548cslave3\u4e0a\u6267\u884c\uff09\r\n$ hadoop-daemon.shstop journalnode\r\n<\/pre>\n
\n