如何在Centos6.5下部署Hadoop2.2的完全分布式集群(三)

散仙在上篇文章中,已经讲述了部署Hadoop2.2伪分布式的步骤,那么今天,我们来看下,如何在Centos6.5下,部署完全分布式集群。
下面先来看下具体的系统环境
序号名称描述
1系统环境Centos6.5最好在linux上部署
2Hadoop版本Hadoop2.2.0Hadoop2.x中的第一个稳定版本
3JAVA环境JDK1.764位(build 1.7.0_25-b15)


部署情况
序号IP地址节点名
1192.168.46.28hp1(master)
2192.168.46.29hp2(slave)
3192.168.46.30hp3(slave)


部署步骤
序号操作
1配置SSH无密码登陆
2配置环境变量JAVA(必须),MAVEN,ANT
3配置Hadoop环境变量
4配置core-site.xml文件
5配置hdfs-site.xml文件
6配置mapred-site.xml文件
7配置yarn-site.xml文件
8配置slaves文件
9分发到从机上
10在每台机器上格式化namenode
11启动集群sbin/start-all.sh
12执行jps命令,查询master与slave的java进程
13测试页面访问,集群状态信息,
14可以测试一个MR作业,验证集群



1,首先我们的集群之间的ssh是信任的,方便hadoop进程之间的通信。

生成公钥:ssh-keygen  -t rsa -P ''
拷贝信任:ssh-copy-id -i .ssh/id_rsa.pub  root@hp2
2,配置各种环境变量包括java,maven,ant,hadoop等的变量,代码如下:

Java代码 复制代码   收藏代码
  1. export PATH=.:$PATH  
  2.   
  3. export JAVA_HOME="/usr/local/jdk"  
  4. export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib  
  5. export PATH=$PATH:$JAVA_HOME/bin  
  6.   
  7. export HADOOP_HOME=/root/hadoop  
  8. export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop  
  9. export CLASSPATH=.:$CLASSPATH:$HADOOP_HOME/lib  
  10. export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin  
  11.   
  12. export ANT_HOME=/usr/local/ant  
  13. export CLASSPATH=$CLASSPATH:$ANT_HOME/lib  
  14. export PATH=$PATH:$ANT_HOME/bin  
  15.   
  16. export MAVEN_HOME="/usr/local/maven"  
  17. export CLASSPATH=$CLASSPATH:$MAVEN_HOME/lib  
  18. export PATH=$PATH:$MAVEN_HOME/bin  
<span style="font-family:Arial;font-size:12px;">export PATH=.:$PATH

export JAVA_HOME="/usr/local/jdk"
export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$PATH:$JAVA_HOME/bin

export HADOOP_HOME=/root/hadoop
export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
export CLASSPATH=.:$CLASSPATH:$HADOOP_HOME/lib
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin

export ANT_HOME=/usr/local/ant
export CLASSPATH=$CLASSPATH:$ANT_HOME/lib
export PATH=$PATH:$ANT_HOME/bin

export MAVEN_HOME="/usr/local/maven"
export CLASSPATH=$CLASSPATH:$MAVEN_HOME/lib
export PATH=$PATH:$MAVEN_HOME/bin
</span>

3,配置core-site.xml文件
Xml代码 复制代码   收藏代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>  
  3. <!--  
  4.   Licensed under the Apache License, Version 2.0 (the "License");  
  5.   you may not use this file except in compliance with the License.  
  6.   You may obtain a copy of the License at  
  7.   
  8.     http://www.apache.org/licenses/LICENSE-2.0  
  9.   
  10.   Unless required by applicable law or agreed to in writing, software  
  11.   distributed under the License is distributed on an "AS IS" BASIS,  
  12.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
  13.   See the License for the specific language governing permissions and  
  14.   limitations under the License. See accompanying LICENSE file.  
  15. -->  
  16.   
  17. <!-- Put site-specific property overrides in this file. -->  
  18.   
  19. <configuration>  
  20.     <property>    
  21.         <name>fs.default.name</name>    
  22.         <value>hdfs://192.168.46.28:9000</value>    
  23.     </property>    
  24.   <property>  
  25.     <name>hadoop.tmp.dir</name>  
  26.     <value>/root/hadoop/tmp</value>  
  27.   </property>  
  28.   
  29. </configuration>  


4,配置hdfs-site.xml文件
Xml代码 复制代码   收藏代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>  
  3. <!--  
  4.   Licensed under the Apache License, Version 2.0 (the "License");  
  5.   you may not use this file except in compliance with the License.  
  6.   You may obtain a copy of the License at  
  7.   
  8.     http://www.apache.org/licenses/LICENSE-2.0  
  9.   
  10.   Unless required by applicable law or agreed to in writing, software  
  11.   distributed under the License is distributed on an "AS IS" BASIS,  
  12.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
  13.   See the License for the specific language governing permissions and  
  14.   limitations under the License. See accompanying LICENSE file.  
  15. -->  
  16.   
  17. <!-- Put site-specific property overrides in this file. -->  
  18.   
  19. <configuration>  
  20. <property>    
  21.    <name>dfs.replication</name>    
  22.    <value>1</value>    
  23.  </property>    
  24.   
  25.  <property>    
  26.    <name>dfs.namenode.name.dir</name>    
  27.    <value>/root/hadoop/nddir</value>    
  28.  </property>    
  29.   
  30.   
  31.  <property>    
  32.    <name>dfs.datanode.data.dir</name>    
  33.    <value>/root/hadoop/dddir</value>    
  34.  </property>    
  35.   
  36. <property>    
  37.   <name>dfs.permissions</name>    
  38.   <value>false</value>    
  39. </property>  
  40.   
  41. </configuration>  

配置mapred-site.xml文件
Xml代码 复制代码   收藏代码
  1. <?xml version="1.0"?>  
  2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>  
  3. <!--  
  4.   Licensed under the Apache License, Version 2.0 (the "License");  
  5.   you may not use this file except in compliance with the License.  
  6.   You may obtain a copy of the License at  
  7.   
  8.     http://www.apache.org/licenses/LICENSE-2.0  
  9.   
  10.   Unless required by applicable law or agreed to in writing, software  
  11.   distributed under the License is distributed on an "AS IS" BASIS,  
  12.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
  13.   See the License for the specific language governing permissions and  
  14.   limitations under the License. See accompanying LICENSE file.  
  15. -->  
  16.   
  17. <!-- Put site-specific property overrides in this file. -->  
  18.   
  19. <configuration>  
  20. <property>  
  21. <name>mapred.job.tracker</name>  
  22. <value>hp1:8021</value>  
  23. <final>true</final>  
  24. <description>The host and port that the MapReduce JobTracker runs at. </description>  
  25. </property>  
  26. <property>    
  27.     <name>mapreduce.cluster.temp.dir</name>    
  28.     <value></value>    
  29.     <description>No description</description>    
  30.     <final>true</final>    
  31.   </property>    
  32.     
  33.   <property>    
  34.     <name>mapreduce.cluster.local.dir</name>    
  35.     <value></value>    
  36.     <description>No description</description>    
  37.     <final>true</final>    
  38.   </property>    
  39. </configuration>  


配置yarn-site.xml文件
Xml代码 复制代码   收藏代码
  1. <?xml version="1.0"?>  
  2. <!--  
  3.   Licensed under the Apache License, Version 2.0 (the "License");  
  4.   you may not use this file except in compliance with the License.  
  5.   You may obtain a copy of the License at  
  6.   
  7.     http://www.apache.org/licenses/LICENSE-2.0  
  8.   
  9.   Unless required by applicable law or agreed to in writing, software  
  10.   distributed under the License is distributed on an "AS IS" BASIS,  
  11.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
  12.   See the License for the specific language governing permissions and  
  13.   limitations under the License. See accompanying LICENSE file.  
  14. -->  
  15. <configuration>  
  16.   
  17. <property>  
  18. <name>yarn.nodemanager.aux-services</name>  
  19. <value>mapreduce_shuffle</value>  
  20. </property>  
  21.   
  22. <property>  
  23. <name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name>  
  24. <value>org.apache.hadoop.mapred.ShuffleHandler</value>  
  25. </property>  
  26.   
  27. <property>  
  28. <name>Yarn.nodemanager.aux-services</name>  
  29. <value>mapreduce.shuffle</value>  
  30. </property>  
  31.   
  32. <property>  
  33. <name>yarn.resourcemanager.address</name>  
  34. <value>hp1:8032</value>  
  35. </property>  
  36.   
  37. <property>  
  38. <name>yarn.resourcemanager.scheduler.address</name>  
  39. <value>hp1:8030</value>  
  40. </property>  
  41.   
  42. <property>  
  43. <name>yarn.resourcemanager.resource-tracker.address</name>  
  44. <value>hp1:8031</value>  
  45. </property>  
  46.   
  47. <property>  
  48. <name>yarn.resourcemanager.admin.address</name>  
  49. <value>hp1:8033</value>  
  50. </property>  
  51.   
  52. <property>  
  53. <name>yarn.resourcemanager.webapp.address</name>  
  54. <value>hp1:8088</value>  
  55. </property>  
  56.   
  57. </configuration>  

配置slaves文件
Java代码 复制代码   收藏代码
  1. 192.168.46.28  
  2. 192.168.46.29  
  3. 192.168.46.30  
<span style="font-family:Arial;font-size:12px;">192.168.46.28
192.168.46.29
192.168.46.30</span>

配置好后,注意,在hdfs-site.xml文件里的目录,需要自己在hadoop根目录下创建,以及hadoop的HDFS的tmp目录。一切做好之后,我们就可以分发整套hadoop到从机上,然后格式化namenode,并启动集群,使用jps在主机,和从机上分别显示如下:
master的jps显示如下:
Java代码 复制代码   收藏代码
  1. 4335 SecondaryNameNode  
  2. 4464 ResourceManager  
  3. 4553 NodeManager  
  4. 4102 NameNode  
  5. 4206 DataNode  
  6. 6042 Jps  
<span style="font-family:Arial;font-size:12px;">4335 SecondaryNameNode
4464 ResourceManager
4553 NodeManager
4102 NameNode
4206 DataNode
6042 Jps</span>

slave上的jps显示如下:
Java代码 复制代码   收藏代码
  1. 1727 DataNode  
  2. 1810 NodeManager  
  3. 2316 Jps  
<span style="font-family:Arial;font-size:12px;">1727 DataNode
1810 NodeManager
2316 Jps</span>

确实jps命令显示的java进程正确,我们就可以访问,web界面进行查看了,截图如下:







至此,我们已经成功的部署完成hadoop集群,安装时,注意散仙的步骤,按这样顺序来,一般不容易不错。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值