当前位置:   article > 正文

实验4 - YARN 的安装部署和管理_yarn 部署

yarn 部署

YARN的安装测试
实验环境
1.Linux Ubuntu 16.04

2.Hadoop3.0.0

以上实验环境我们都已经为您搭建好

实验内容
在只安装Linux系统的服务器上,安装测试YARN

首先双击打开桌面上的命令行终端,以下命令都在命令行终端中执行
1.YARN的安装
由于Hadoop从2.0本后以后自带yarn,本机中安装的Hadoop是3.0版本,所以本机安装的Hadoop中自带yarn,无需安装。

下面我们运用yarn做一个词频统计的测试

2.启动hadoop
配置yarn-site.xml

leafpad /apps/hadoop/etc/hadoop/yarn-site.xml
  • 1

将yarn相关配置,添加到标签之间

<property>
  <name>yarn.nodemanager.disk-health-checker.max-disk-utilization-per-disk-percentage</name>
  <value>98.5</value>
</property>
  • 1
  • 2
  • 3
  • 4

输入以下命令,回车,进入/apps/hadoop/sbin目录

cd /apps/hadoop/sbin
  • 1

回车后显示如下

dolphin@tools:/apps/hadoop/sbin$
  • 1

在当前目录下输入以下命令,回车,启动hadoop

./start-all.sh
  • 1

启动正常显示如下

WARNING: Attempting to start all Apache Hadoop daemons as dolphin in 10 seconds.
WARNING: This is not a recommended production deployment configuration.
WARNING: Use CTRL-C to abort.
Starting namenodes on [0.0.0.0]
0.0.0.0: Warning: Permanently added '0.0.0.0' (ECDSA) to the list of known hosts.
Starting datanodes
localhost: Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
Starting secondary namenodes [tools.hadoop-s.ambari]
tools.hadoop-s.ambari: Warning: Permanently added 'tools.hadoop-s.ambari,172.25.0.2' (ECDSA) to the list of known hosts.
Starting resourcemanager
Starting nodemanagers
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

输入以下命令,回车,查看hadoop是否已经启动

jps
  • 1

正常显示类似如下信息

931 ResourceManager
1349 Jps
1046 NodeManager
646 SecondaryNameNode
391 NameNode
490 DataNode
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

出现以上信息说明hadoop启动成功

3.在本地准备测试文件
首先输入以下命令,回车,创建yarn目录

mkdir /apps/yarn
  • 1

输入以下命令,回车,在/apps/yarn目录下创建words.txt文件,并进入该文件

leafpad /apps/yarn/words.txt
  • 1

接着在文件中,写入以下内容

hello tom
hello ethan
hello jony
hello tom
hello tom
  • 1
  • 2
  • 3
  • 4
  • 5

内容写入完成后,进行退出并保存

输入以下命令回车,查看/apps/yarn/目录下,测试文件 words.txt 是否创建成功

ls -l /apps/yarn/
  • 1

/apps/yarn/目录显示如下

-rw-r--r-- 1 root root 54 7\u6708  20 10:49 words.txt
  • 1

/apps/yarn/目录下生成了words.txt文件,说明测试文件创建成功

4.将本地测试文件上传到hdfs
首先输入以下命令,回车,在hdfs上创建wordcount目录

hdfs dfs -mkdir -p /wordcount/input
  • 1

接着输入以下命令,回车,将本地/apps/yarn/目录下的测试数据words.txt文件上产到hdfs的/wordcount/input目录

hdfs dfs -put /apps/yarn/words.txt /wordcount/input
  • 1

最后输入以下命令,回车,查看测试文件上传是否成功

hdfs dfs -ls /wordcount/input
  • 1

回车后显示如下

Found 1 items
-rw-r--r--   1 dolphin supergroup         54 2018-07-20 03:02 /wordcount/input/words.txt
  • 1
  • 2

显示以上信息说明测试数据上传成功

5.执行测试
输入以下命令,回车

yarn jar \
  • 1

回车后显示如下

>
  • 1

继续输入以下命令,回车

/apps/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-3.0.0.jar \
  • 1

回车后显示如下

>
  • 1

继续输入以下命令,回车

wordcount \
  • 1

回车后显示如下

>
  • 1

继续输入以下命令,回车

/wordcount/input \
  • 1

回车后显示如下

>
  • 1

继续输入以下命令,回车

/wordcount/output
  • 1

回车后显示类似如下信息

18/05/29 20:40:59 INFO client.RMProxy: Connecting to ResourceManager at /0.0.0.0:8032
18/05/29 20:40:59 INFO input.FileInputFormat: Total input files to process : 1
18/05/29 20:41:00 INFO mapreduce.JobSubmitter: number of splits:1
18/05/29 20:41:00 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1526991305992_0001
18/05/29 20:41:01 INFO impl.YarnClientImpl: Submitted application application_1526991305992_0001
18/05/29 20:41:01 INFO mapreduce.Job: The url to track the job: http://hadoop000:8088/proxy/application_1526991305992_0001/
18/05/29 20:41:01 INFO mapreduce.Job: Running job: job_1526991305992_0001
18/05/29 20:41:14 INFO mapreduce.Job: Job job_1526991305992_0001 running in uber mode : false
18/05/29 20:41:14 INFO mapreduce.Job:  map 0% reduce 0%
18/05/29 20:41:23 INFO mapreduce.Job:  map 100% reduce 0%
18/05/29 20:41:29 INFO mapreduce.Job:  map 100% reduce 100%
18/05/29 20:41:30 INFO mapreduce.Job: Job job_1526991305992_0001 completed successfully
18/05/29 20:41:30 INFO mapreduce.Job: Counters: 49
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

继续输入以下命令,回车,查看 hdfs 下的/wordcount/output目录

hdfs dfs -ls /wordcount/output
  • 1

显示该目录下信息如下

Found 2 items
-rw-r--r--   1 dolphin supergroup          0 2018-07-20 03:19 /wordcount/output/_SUCCESS
-rw-r--r--   1 dolphin supergroup         29 2018-07-20 03:19 /wordcount/output/part-r-00000
  • 1
  • 2
  • 3

输入以下命令,回车,继续查看该目录下的part-r-00000文件

hdfs dfs -cat /wordcount/output/part-r-00000
  • 1

显示当前文件内容如下

ethan   1
hello   5
jony    1
tom     3
  • 1
  • 2
  • 3
  • 4

统计出了测试数据文件中各个词的词频,说明测试成功

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/852337
推荐阅读
相关标签
  

闽ICP备14008679号