Hadoop部署MapReduce+YARN

1.yarn部署:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
	 MapReduce: 计算的 是jar包提交的Yarn上  本身不需要部署
Yarn: 资源和作业调度 是需要部署的
因为:MapReduce on Yarn(mapreduce是运行在yarn上)


> Configure parameters as follows:(配置信息步骤)
>
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>

2.sbin/start-yarn.sh 启动yarn:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ jps
4001 NodeManager
3254 SecondaryNameNode
3910 ResourceManager
3563 NameNode
4317 Jps
3087 DataNode

ResourceManager daemon (老大 资源管理者)
NodeManager daemon (小弟 节点管理者)
$ sbin/start-yarn.sh
Browse the web interface for the ResourceManager; by default it is available at:
ResourceManager - http://localhost:8088/
这时我们可以去看一下yarn的web界面:http://localhost:8088/

3.怎样查看错误:

1
2
3
4
5
6
7
8
9
10
 在生产中我们要会查看日志,在日志中查找错误
logs/目录下:
hadoop-hadoop-datanode-hadoop002.log
对应的名字分别是:
hadoop-用户-进程名称-机器名称
一共有三种方法可以去查看:
01 vi :/搜索 ERROR
02 tail -200f xxx.log(倒着查看log中的后200行日志) 另外窗口重启进程 为了再现这个错误

03 rz上传到windows editplus去定位查看 备份 (一般对于生产中日志比较大的文件)

4.运行mr

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
	 map 	(映射)
reduce (规约)


> 词频统计

[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ vi a.log(先编辑一个文件保存)
ruoze
jepson
www.ruozedata.com
dashu
adai
fanren
1
a
b
c
a b c ruoze jepon
[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ vi b.txt(再编辑一个文件保存)
a b d e f ruoze
1 1 3 5

[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ hdfs dfs -mkdir -p /wordcount/input (在hdfs家目录下创建一个级联文件及)

[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ hdfs dfs -put a.log /wordcount/input
[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ hdfs dfs -put b.txt /wordcount/input(将a.log和b.text文件上传到文件夹下)
[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ hdfs dfs -ls /wordcount/input/(查看一下文件夹下的内容)
Found 2 items
-rw-r--r-- 1 hadoop supergroup 76 2019-02-16 21:59 /wordcount/input/a.log
-rw-r--r-- 1 hadoop supergroup 24 2019-02-16 21:59 /wordcount/input/b.txt

这里我们做一个列子,mapreduce中会给出 examples,
​ 我们可以通过:find ./ -name ‘example.jar’找到这个jar包:
​ ./share/hadoop/mapreduce2/hadoop-mapreduce-examples-2.6.0-cdh5.7.0.jar
​ 虽然我们不知道命令时什么,但是我们可以查看命令帮助:
​ hadoop回车,向下翻看,会发现有一个命令是 jar
然后我们继续输入:继续输入命令:(注意:output1事先一定是不存在的)
在这里插入图片描述查看计算结果:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ hadoop jar \
./share/hadoop/mapreduce2/hadoop-mapreduce-examples-2.6.0-cdh5.7.0.jar \
wordcount /wordcount/input /wordcount/output1

[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ hdfs dfs -cat /wordcount/output1/part-r-00000
19/02/16 22:05:46 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
1 3
3 1
5 1
a 3
adai 1
b 3
c 2
d 1
dashu 1
e 1
f 1
fanren 1
jepon 1
jepson 1
ruoze 3
www.ruozedata.com 1
[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ hdfs dfs -get /wordcount/output1/part-r-00000 ./
[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ cat part-r-00000
1 3
3 1
5 1
a 3
adai 1
b 3
c 2
d 1
dashu 1
e 1
f 1
fanren 1
jepon 1
jepson 1
ruoze 3
www.ruozedata.com 1

本文标题:Hadoop部署MapReduce+YARN

文章作者:skygzx

发布时间:2019年04月07日 - 10:35

最后更新:2019年04月07日 - 15:08

原始链接:http://yoursite.com/2019/04/07/3.Hadoop伪分布式(MapReduce+YARN)/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

-------------本文结束感谢您的阅读-------------
0%