- 建立在Hadoop-ha搭建的基础上
一、MapReduce配置
-
hadoop的window版本解压到E:\usr\local\hadoop-2.6.5,要求路径不能有特殊符号
-
在Windows中配置两个环境变量:
- HADOOP_USER_NAME=root
- HADOOP_HOME=E:\usr\local\hadoop-2.6.5
- 将hadoop的bin和sbin添加到PATH中%HADOOP_HOME%\bin,和sbin
-
将E:\usr\local\hadoop-2.6.5\bin中的hadoop.dll文件放到C:\Windows\System32中
-
在eclipse的plugins目录中添加hadoop插件
- hadoop-eclipse-plugin-2.6.0.jar
-
新建文件夹E:\usr\local\hadoop265libs,在其中添加E:\usr\local\hadoop-2.6.5\share\hadoop中jar包,共121个,包括:
- common及lib
- hdfs及lib
- mapreduce及lib
- yarn及lib
- tools及lib
-
启动eclipse
-
创建namenode1和namenode2
-
在eclipse工具栏Window-Preferences-Java-Build Path-User Libreries,右边New新建hdfslibs,AddExternal JARs…放入jar,即E:\usr\local\hadoop265libs中全选
-
新建java项目,右击Build Path-Add Libraries-User Library-hdfslibs(刚建的),添加JUnit-4,Build Path-Add Libraries-JUnit-4
-
放配置文件,右击新建文件夹conf,在conf下新建文件夹ha,放入配置文件
* core-site.xml
* hdfs-site.xml
* 右击ha文件夹,Build Path-Use As Source Floder
- 新建Class
二、Yarn搭建
- mapred-site.xml.template配置
- 拷贝一份:cp mapred-site.xml.template mapred-site.xml
- 配置:vim mapred-site.xml
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
- yarn-site.xml配置
<configuration>
<!-- Site specific YARN configuration properties -->
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<!--启用ResourceManager的高可用-->
<property>
<name>yarn.resourcemanager.ha.enabled</name>
<value>true</value>
</property>
<!--指代ResourceManager HA的两台RM的逻辑名称 -->
<property>
<name>yarn.resourcemanager.cluster-id</name>
<value>rmhacluster1</value>
</property>
<!--指定该高可用ResourceManager下的两台ResourceManager的逻辑名称-->
<property>
<name>yarn.resourcemanager.ha.rm-ids</name>
<value>rm1,rm2</value>
</property>
<!--指定第一台ResourceManager服务器所在的主机名称 -->
<property>
<name>yarn.resourcemanager.hostname.rm1</name>
<value>node3</value>
</property>
<property>
<name>yarn.resourcemanager.hostname.rm2</name>
<value>node4</value>
</property>
<!--指定resourcemanager的web服务器的主机名和端口号-->
<property>
<name>yarn.resourcemanager.webapp.address.rm1</name>
<value>node3:8088</value>
</property>
<property>
<name>yarn.resourcemanager.webapp.address.rm2</name>
<value>node4:8088</value>
</property>
<!--做ResourceManager HA故障切换用到的zookeeper集群地址 -->
<property>
<name>yarn.resourcemanager.zk-address</name>
<value>node2:2181,node3:2181,node4:2181</value>
</property>
</configuration>
- 操作
- 先启动Hadoop-ha: