架构
HDFS和YARN是两个概念,搭建YARN和HDFS无冲突。
HOST | NN | NN | JNN | DN | ZKFC | ZK | RM | NM |
---|---|---|---|---|---|---|---|---|
node01 | * | * | * | |||||
node02 | * | * | * | * | * | * | ||
node03 | * | * | * | * | * | |||
node04 | * | * | * | * |
发展进程
hdoop | 1.x | 2.x | 3.x |
---|---|---|---|
hdfs | no ha | ha(向前兼容,没有过多的改NN,而是通过新增角色zkfc) | |
yarn | no yarn | yarn(已经有了ha的概念,不是新增角色,而是直接在RM进程中增加了HA的模块) |
通过官网
https://hadoop.apache.org/docs/r2.10.1/hadoop-yarn/hadoop-yarn-site/ResourceManagerHA.html
伪分布式
etc/hadoop/mapred-site.xml
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
etc/hadoop/yarn-site.xml
<configuration>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
</configuration>
HA
etc/hadoop/yarn-site.xml
<property>
<name>yarn.resourcemanager.ha.enabled</name>
<value>true</value>
</property>
<property>
<name>yarn.resourcemanager.zk-address</name>
<value>node01:2181,node02:2181,node03:2181</value>
</property>
<property>
<name>yarn.resourcemanager.cluster-id</name>
<value>mashibing</value>
</property>
<property>
<name>yarn.resourcemanager.ha.rm-ids</name>
<value>rm1,rm2</value>
</property>
<property>
<name>yarn.resourcemanager.hostname.rm1</name>
<value>node03</value>
</property>
<property>
<name>yarn.resourcemanager.hostname.rm2</name>
<value>node04</value>
</property>
<property>
<name>yarn.resourcemanager.webapp.address.rm1</name>
<value>node03:8088</value>
</property>
<property>
<name>yarn.resourcemanager.webapp.address.rm2</name>
<value>node04:8088</value>
</property>
配置
分发
scp mapred-site.xml yarn-site.xml node02:`pwd`
scp mapred-site.xml yarn-site.xml node03:`pwd`
scp mapred-site.xml yarn-site.xml node04:`pwd`
vi slaves //可以不用管,搭建hdfs时候已经改过了
启动
# 启动 NodeManager
start-yarn.sh
# 启动 ResourceManager
yarn-daemon.sh start resourcemanager
访问验证
http://node03:8088
http://node04:8088
使用
hdfs dfs -mkdir -p /data/wc/input
hdfs dfs -D dfs.blocksize=1048576 -put data.txt /data/wc/input
计算
hadoop jar hadoop-mapreduce-examples-2.10.1.jar wordcount /data/wc/input /data/wc/output
结果
代码
maven打包
- clean
- package