Apache Hadoop 2.9.2 的归档案例剖析
Apache Hadoop 2.9.2 的归档案例剖析
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
能看到这篇文章说明你对NameNode 工作原理是有深入的理解啦!我们知道每个文件按照块存储,没饿过块的元数据存储在NameNode的内存中,因此Hadoop存储小文件会非常低效。因为大量的小文件会耗尽NameNode中的大部分内存。但注意,存储小文件所需要的磁盘容量和存储这些文件原始内容所需要的磁盘空间相比也不会增多。例如,一个2MB的文件大小为128MB的块存储,使用的是2MB的磁盘空间,而不是128MB。
一.Hadoop存档
Hadoop归档文件或HAR文件,是一个更高效的文件存档工具,它将文件存入HDFS块,在减少NameNode内存使用的同时,允许对文件进行透明访问。具体说来,Hadoop归档文件可以用作MapReduce的输入。
二.归档操作
1>.上传测试文件到hdfs集群中
[root@node101.yinzhengjie.org.cn ~]# ll -R
.:
total
-rw-r--r--. root root Apr : edits.xml
-rw-r--r--. root root Apr : fsimage.xml
drwxr-xr-x root root Apr : krb5.conf.d
-rw-r--r--. root root Apr : seen_txid
drwxr-xr-x root root Apr : yum.repos.d ./krb5.conf.d:
total
-rw-r--r-- root root Apr : krb5.conf ./yum.repos.d:
total
drwxr-xr-x root root Apr : back
-rw-r--r-- root root Apr : CentOS-Base.repo
drwxr-xr-x root root Apr : default
-rw-r--r-- root root Apr : epel.repo
-rw-r--r-- root root Apr : epel-testing.repo ./yum.repos.d/back:
total
-rw-r--r-- root root Apr : CentOS-Base.repo ./yum.repos.d/default:
total
-rw-r--r-- root root Apr : CentOS-Base.repo
-rw-r--r-- root root Apr : CentOS-CR.repo
-rw-r--r-- root root Apr : CentOS-Debuginfo.repo
-rw-r--r-- root root Apr : CentOS-fasttrack.repo
-rw-r--r-- root root Apr : CentOS-Media.repo
-rw-r--r-- root root Apr : CentOS-Sources.repo
-rw-r--r-- root root Apr : CentOS-Vault.repo
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll -R
[root@node101.yinzhengjie.org.cn ~]# ll
total
-rw-r--r--. root root Apr : edits.xml
-rw-r--r--. root root Apr : fsimage.xml
drwxr-xr-x root root Apr : krb5.conf.d
-rw-r--r--. root root Apr : seen_txid
drwxr-xr-x root root Apr : yum.repos.d
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# hadoop fs -mkdir /yinzhengjie
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# hdfs dfs -put ./* /yinzhengjie
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yinzhengjie
Found 5 items
-rw-r--r-- 2 root supergroup 3124 2019-04-16 18:10 /yinzhengjie/edits.xml
-rw-r--r-- 2 root supergroup 1264 2019-04-16 18:10 /yinzhengjie/fsimage.xml
drwxr-xr-x - root supergroup 0 2019-04-16 18:10 /yinzhengjie/krb5.conf.d
-rw-r--r-- 2 root supergroup 3 2019-04-16 18:10 /yinzhengjie/seen_txid
drwxr-xr-x - root supergroup 0 2019-04-16 18:10 /yinzhengjie/yum.repos.d
[root@node101.yinzhengjie.org.cn ~]#

2>. 启动yarn进程(我们使用归档时需要用到该服务进行资源调度)
[root@node101.yinzhengjie.org.cn ~]# ansible all -m shell -a 'jps'
node110.yinzhengjie.org.cn | SUCCESS | rc= >>
Jps
DataNode node101.yinzhengjie.org.cn | SUCCESS | rc= >>
FsShell
NameNode
DataNode
SecondaryNameNode
Jps node103.yinzhengjie.org.cn | SUCCESS | rc= >>
DataNode
Jps [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ansible all -m shell -a 'jps' #yarn服务启动之前存在的进程
[root@node101.yinzhengjie.org.cn ~]# start-yarn.sh
starting yarn daemons
starting resourcemanager, logging to /yinzhengjie/softwares/hadoop-2.9./logs/yarn-root-resourcemanager-node101.yinzhengjie.org.cn.out
node103.yinzhengjie.org.cn: starting nodemanager, logging to /yinzhengjie/softwares/hadoop-2.9./logs/yarn-root-nodemanager-node103.yinzhengjie.org.cn.out
node101.yinzhengjie.org.cn: starting nodemanager, logging to /yinzhengjie/softwares/hadoop-2.9./logs/yarn-root-nodemanager-node101.yinzhengjie.org.cn.out
node110.yinzhengjie.org.cn: starting nodemanager, logging to /yinzhengjie/softwares/hadoop-2.9./logs/yarn-root-nodemanager-node110.yinzhengjie.org.cn.out
node102.yinzhengjie.org.cn: ssh: connect to host node102.yinzhengjie.org.cn port : No route to host
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# start-yarn.sh
[root@node101.yinzhengjie.org.cn ~]# ansible all -m shell -a 'jps'
node110.yinzhengjie.org.cn | SUCCESS | rc= >>
DataNode
NodeManager
Jps node103.yinzhengjie.org.cn | SUCCESS | rc= >>
NodeManager
DataNode
Jps node101.yinzhengjie.org.cn | SUCCESS | rc= >>
NodeManager
FsShell
NameNode
Jps
DataNode
SecondaryNameNode
ResourceManager [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ansible all -m shell -a 'jps' #启动yarn服务之后,我们观察哪些进程启动成功啦!
3>.将多个目录进行归档操作
[root@node101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yinzhengjie
Found items
-rw-r--r-- root supergroup -- : /yinzhengjie/edits.xml
-rw-r--r-- root supergroup -- : /yinzhengjie/fsimage.xml
drwxr-xr-x - root supergroup -- : /yinzhengjie/krb5.conf.d
-rw-r--r-- root supergroup -- : /yinzhengjie/seen_txid
drwxr-xr-x - root supergroup -- : /yinzhengjie/yum.repos.d
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yinzhengjie #归档之前查看目录结构
[root@node101.yinzhengjie.org.cn ~]# hadoop archive -archiveName yinzhengjie-test.har -p /yinzhengjie/yum.repos.d /yinzhengjie/output
// :: INFO client.RMProxy: Connecting to ResourceManager at node101.yinzhengjie.org.cn/172.30.1.101:
// :: INFO client.RMProxy: Connecting to ResourceManager at node101.yinzhengjie.org.cn/172.30.1.101:
// :: INFO client.RMProxy: Connecting to ResourceManager at node101.yinzhengjie.org.cn/172.30.1.101:
// :: INFO mapreduce.JobSubmitter: number of splits:
// :: INFO Configuration.deprecation: yarn.resourcemanager.system-metrics-publisher.enabled is deprecated. Instead, use yarn.system-metrics-publisher.enabled
// :: INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1555408586551_0006
// :: INFO impl.YarnClientImpl: Submitted application application_1555408586551_0006
// :: INFO mapreduce.Job: The url to track the job: http://node101.yinzhengjie.org.cn:8088/proxy/application_1555408586551_0006/
// :: INFO mapreduce.Job: Running job: job_1555408586551_0006
// :: INFO mapreduce.Job: Job job_1555408586551_0006 running in uber mode : false
// :: INFO mapreduce.Job: map % reduce %
// :: INFO mapreduce.Job: map % reduce %
// :: INFO mapreduce.Job: map % reduce %
// :: INFO mapreduce.Job: Job job_1555408586551_0006 completed successfully
// :: INFO mapreduce.Job: Counters:
File System Counters
FILE: Number of bytes read=
FILE: Number of bytes written=
FILE: Number of read operations=
FILE: Number of large read operations=
FILE: Number of write operations=
HDFS: Number of bytes read=
HDFS: Number of bytes written=
HDFS: Number of read operations=
HDFS: Number of large read operations=
HDFS: Number of write operations=
Job Counters
Launched map tasks=
Launched reduce tasks=
Other local map tasks=
Total time spent by all maps in occupied slots (ms)=
Total time spent by all reduces in occupied slots (ms)=
Total time spent by all map tasks (ms)=
Total time spent by all reduce tasks (ms)=
Total vcore-milliseconds taken by all map tasks=
Total vcore-milliseconds taken by all reduce tasks=
Total megabyte-milliseconds taken by all map tasks=
Total megabyte-milliseconds taken by all reduce tasks=
Map-Reduce Framework
Map input records=
Map output records=
Map output bytes=
Map output materialized bytes=
Input split bytes=
Combine input records=
Combine output records=
Reduce input groups=
Reduce shuffle bytes=
Reduce input records=
Reduce output records=
Spilled Records=
Shuffled Maps =
Failed Shuffles=
Merged Map outputs=
GC time elapsed (ms)=
CPU time spent (ms)=
Physical memory (bytes) snapshot=
Virtual memory (bytes) snapshot=
Total committed heap usage (bytes)=
Shuffle Errors
BAD_ID=
CONNECTION=
IO_ERROR=
WRONG_LENGTH=
WRONG_MAP=
WRONG_REDUCE=
File Input Format Counters
Bytes Read=
File Output Format Counters
Bytes Written=
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# hadoop archive -archiveName yinzhengjie-test.har -p /yinzhengjie/yum.repos.d /yinzhengjie/output
[root@node101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yinzhengjie
Found items
-rw-r--r-- root supergroup -- : /yinzhengjie/edits.xml
-rw-r--r-- root supergroup -- : /yinzhengjie/fsimage.xml
drwxr-xr-x - root supergroup -- : /yinzhengjie/krb5.conf.d
drwxr-xr-x - root supergroup -- : /yinzhengjie/output #这个目录就是我们存储归档文件的,我们在上一步已经指明了,我们可以查看该目录下存放文件的名称!
-rw-r--r-- root supergroup -- : /yinzhengjie/seen_txid
drwxr-xr-x - root supergroup -- : /yinzhengjie/yum.repos.d
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yinzhengjie/output
Found items
drwxr-xr-x - root supergroup -- : /yinzhengjie/output/yinzhengjie-test.har #大家看这个名称,我们在归档时使用了-archiveName参数归档文件目录! [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yinzhengjie/output/yinzhengjie-test.har
Found items
-rw-r--r-- root supergroup -- : /yinzhengjie/output/yinzhengjie-test.har/_SUCCESS
-rw-r--r-- root supergroup -- : /yinzhengjie/output/yinzhengjie-test.har/_index
-rw-r--r-- root supergroup -- : /yinzhengjie/output/yinzhengjie-test.har/_masterindex
-rw-r--r-- root supergroup -- : /yinzhengjie/output/yinzhengjie-test.har/part-
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#

4>.查看归档文件
[root@node101.yinzhengjie.org.cn ~]# hadoop fs -ls -R /yinzhengjie/output/yinzhengjie-test.har
-rw-r--r-- root supergroup -- : /yinzhengjie/output/yinzhengjie-test.har/_SUCCESS
-rw-r--r-- root supergroup -- : /yinzhengjie/output/yinzhengjie-test.har/_index
-rw-r--r-- root supergroup -- : /yinzhengjie/output/yinzhengjie-test.har/_masterindex
-rw-r--r-- root supergroup -- : /yinzhengjie/output/yinzhengjie-test.har/part-
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# hadoop fs -ls -R har:///yinzhengjie/output/yinzhengjie-test.har
-rw-r--r-- root supergroup -- : har:///yinzhengjie/output/yinzhengjie-test.har/CentOS-Base.repo
drwxr-xr-x - root supergroup -- : har:///yinzhengjie/output/yinzhengjie-test.har/back
-rw-r--r-- root supergroup -- : har:///yinzhengjie/output/yinzhengjie-test.har/back/CentOS-Base.repo
drwxr-xr-x - root supergroup -- : har:///yinzhengjie/output/yinzhengjie-test.har/default
-rw-r--r-- root supergroup -- : har:///yinzhengjie/output/yinzhengjie-test.har/default/CentOS-Base.repo
-rw-r--r-- root supergroup -- : har:///yinzhengjie/output/yinzhengjie-test.har/default/CentOS-CR.repo
-rw-r--r-- root supergroup -- : har:///yinzhengjie/output/yinzhengjie-test.har/default/CentOS-Debuginfo.repo
-rw-r--r-- root supergroup -- : har:///yinzhengjie/output/yinzhengjie-test.har/default/CentOS-Media.repo
-rw-r--r-- root supergroup -- : har:///yinzhengjie/output/yinzhengjie-test.har/default/CentOS-Sources.repo
-rw-r--r-- root supergroup -- : har:///yinzhengjie/output/yinzhengjie-test.har/default/CentOS-Vault.repo
-rw-r--r-- root supergroup -- : har:///yinzhengjie/output/yinzhengjie-test.har/default/CentOS-fasttrack.repo
-rw-r--r-- root supergroup -- : har:///yinzhengjie/output/yinzhengjie-test.har/epel-testing.repo
-rw-r--r-- root supergroup -- : har:///yinzhengjie/output/yinzhengjie-test.har/epel.repo
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]#
三.解归档文件
1>.查看解归档之前的目录情况
[root@node101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yinzhengjie
Found items
-rw-r--r-- root supergroup -- : /yinzhengjie/edits.xml
-rw-r--r-- root supergroup -- : /yinzhengjie/fsimage.xml
drwxr-xr-x - root supergroup -- : /yinzhengjie/krb5.conf.d
drwxr-xr-x - root supergroup -- : /yinzhengjie/output
-rw-r--r-- root supergroup -- : /yinzhengjie/seen_txid
drwxr-xr-x - root supergroup -- : /yinzhengjie/yum.repos.d
[root@node101.yinzhengjie.org.cn ~]#
2>.进行解归档操作
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# hadoop fs -cp har:///yinzhengjie/output/yinzhengjie-test.har /yinzhengjie/output2019
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yinzhengjie
Found items
-rw-r--r-- root supergroup -- : /yinzhengjie/edits.xml
-rw-r--r-- root supergroup -- : /yinzhengjie/fsimage.xml
drwxr-xr-x - root supergroup -- : /yinzhengjie/krb5.conf.d
drwxr-xr-x - root supergroup -- : /yinzhengjie/output
drwxr-xr-x - root supergroup -- : /yinzhengjie/output2019
-rw-r--r-- root supergroup -- : /yinzhengjie/seen_txid
drwxr-xr-x - root supergroup -- : /yinzhengjie/yum.repos.d
[root@node101.yinzhengjie.org.cn ~]#
3>.对比归档前和解压后的数据是否一致
[root@node101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yinzhengjie/output2019
Found items
-rw-r--r-- root supergroup -- : /yinzhengjie/output2019/CentOS-Base.repo
drwxr-xr-x - root supergroup -- : /yinzhengjie/output2019/back
drwxr-xr-x - root supergroup -- : /yinzhengjie/output2019/default
-rw-r--r-- root supergroup -- : /yinzhengjie/output2019/epel-testing.repo
-rw-r--r-- root supergroup -- : /yinzhengjie/output2019/epel.repo
[root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yinzhengjie/yum.repos.d
Found items
-rw-r--r-- root supergroup -- : /yinzhengjie/yum.repos.d/CentOS-Base.repo
drwxr-xr-x - root supergroup -- : /yinzhengjie/yum.repos.d/back
drwxr-xr-x - root supergroup -- : /yinzhengjie/yum.repos.d/default
-rw-r--r-- root supergroup -- : /yinzhengjie/yum.repos.d/epel-testing.repo
-rw-r--r-- root supergroup -- : /yinzhengjie/yum.repos.d/epel.repo
[root@node101.yinzhengjie.org.cn ~]#

Apache Hadoop 2.9.2 的归档案例剖析的更多相关文章
- Hadoop入门进阶课程6--MapReduce应用案例
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,博主为石山园,博客地址为 http://www.cnblogs.com/shishanyuan ...
- hadoop笔记之MapReduce的应用案例(利用MapReduce进行排序)
MapReduce的应用案例(利用MapReduce进行排序) MapReduce的应用案例(利用MapReduce进行排序) 思路: Reduce之后直接进行结果合并 具体样例: 程序名:Sort. ...
- hadoop笔记之MapReduce的应用案例(WordCount单词计数)
MapReduce的应用案例(WordCount单词计数) MapReduce的应用案例(WordCount单词计数) 1. WordCount单词计数 作用: 计算文件中出现每个单词的频数 输入结果 ...
- Hadoop生态圈-Knox网关的应用案例
Hadoop生态圈-Knox网关的应用案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.Knox网关简介 据Knox官网所述(http://knox.apache.org/) ...
- Hadoop生态圈-CDH与HUE使用案例
Hadoop生态圈-CDH与HUE使用案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.HUE的介绍 1>.HUE的由来 HUE全称是HadoopUser Experi ...
- hadoop一代集群运行代码案例
hadoop一代集群运行代码案例 集群 一个 master,两个slave,IP分别是192.168.1.2.192.168.1.3.192.168.1.4 hadoop版 ...
- Hadoop基础-MapReduce的Partitioner用法案例
Hadoop基础-MapReduce的Partitioner用法案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.Partitioner关键代码剖析 1>.返回的分区号 ...
- Hadoop基础-MapReduce的Combiner用法案例
Hadoop基础-MapReduce的Combiner用法案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.编写年度最高气温统计 如上图说所示:有一个temp的文件,里面存放 ...
- Hadoop的ChainMapper和ChainReducer使用案例(链式处理)(四)
不多说,直接上干货! Hadoop的MR作业支持链式处理,类似在一个生产牛奶的流水线上,每一个阶段都有特定的任务要处理,比如提供牛奶盒,装入牛奶,封盒,打印出厂日期,等等,通过这样进一步的分 ...
随机推荐
- Openlayer 3加载本地ArcGIS切片
第一篇博客,简单的开个头吧.希望自己能坚持记录.一般什么情况什么人需要这样的需求呢,伐木的光头强大哥说我们在深山老林里,没网的啊,地图就手机本地duang的加载一下吧.那么Server啊就要丢掉丢掉. ...
- 一起学Android之ViewPager
本文以一个简单的小例子,简述在Android开发中ViewPager的常见用法,仅供学习分享使用. 概述 ViewPager是一个支持使用者左右滑动的布局管理控件,可以通过一个实现的(适配器)Page ...
- 安卓投屏助手(B1358)之辅助调试
Android远程桌面助手的中文版——安卓投屏助手正式上线.安卓投屏和远程控制的软件其实已经非常多了,如Vysor.Total Control.Mobizen.ApowerMirror.TeamVie ...
- 云服务器内,nginx安装部署,Xshell,Xftp安装
nginx部署 三丰云云服务器,安装nginx nginx部署 在宝塔面板,添加Nginx安装,一般进来会默认推荐安装几款软件,mysql等,暂时可以后面再装,先把nginx装上去,去感受将前端页面放 ...
- 问题解决--无法解析的外部符号 _imp_XXXXXXXXX
错误示例: 出现字符_imp,说明不是真正的静态库,而是某个动态库的导入库,导入函数和自己不同名,所以加了字符_imp.比如说_imp_GetUserNameA就是GetUserNameA函数. 会报 ...
- Kafka单节点及集群配置安装
一.单节点 1.上传Kafka安装包到Linux系统[当前为Centos7]. 2.解压,配置conf/server.property. 2.1配置broker.id 2.2配置log.dirs 2. ...
- MySql安装教程
一.MYSQL的安装 1.打开下载的mysql安装文件mysql-5.0.27-win32.zip,双击解压缩,运行“setup.exe”. 2.选择安装类型,有“Typical(默认)”.“Comp ...
- 芒果绿的blog
--------------------------------------------------------------这是芒果绿的blog!!-------------------------- ...
- timers模块
timers模块 var timers = require('timers'); function A() { //将A对象注册到定时器里 timers.enroll(); //进行激活,如果不激活, ...
- python+selenium运行时,提示元素不可见
python+selenium运行多次新增项目脚本(出错的元素通过by_id的方式定位),当第三次新增时报Message: element not visible的错误,加入等待时间,等页面加载完成, ...