hadoop深入研究:(五)——Archives

转载请注明来源地址:http://blog.csdn.net/lastsweetop/article/details/9123155

简介

我们在hadoop深入研究:(一)——hdfs介绍里已讲过,hdfs并不擅长存储小文件,因为每个文件最少一个block,每个block的元数据都会在namenode节点占用内存,如果存在这样大量的小文件,它们会吃掉namenode节点的大量内存。
hadoop Archives可以有效的处理以上问题,他可以把多个文件归档成为一个文件,归档成一个文件后还可以透明的访问每一个文件,并且可以做为mapreduce任务的输入。

 

用法

hadoop Archives可以使用archive工具创建,同上一篇讲的distcp一样,archive也是一个mapreduce任务。首先我们先来看下我的目录结构:

 

[hadoop@namenode ~]$hadoop fs -lsr
drwxr-xr-x   - hadoop supergroup          0 2013-06-20 12:37 /user/hadoop/har
drwxr-xr-x   - hadoop supergroup          0 2013-05-23 11:35 /user/hadoop/input
-rw-r--r--   2 hadoop supergroup     888190 2013-05-23 11:35 /user/hadoop/input/1901
-rw-r--r--   2 hadoop supergroup     888978 2013-05-23 11:35 /user/hadoop/input/1902
-rw-r--r--   2 hadoop supergroup        293 2013-06-02 17:44 /user/hadoop/news.txt
我们通过archive工具才对该目录进行归档
hadoop archive -archiveName input.har -p /user/hadoop/ input har
archiveName指定archive的文件名,-p代表父目录,可以把多个目录文件放到archive里,我们来看下创建好的har文件。
[hadoop@namenode ~]$hadoop fs -ls har
Found 1 items
drwxr-xr-x   - hadoop supergroup          0 2013-06-20 12:38 /user/hadoop/har/input.har
[hadoop@namenode ~]$hadoop fs -ls har/input.har
Found 4 items
-rw-r--r--   2 hadoop supergroup          0 2013-06-20 12:38 /user/hadoop/har/input.har/_SUCCESS
-rw-r--r--   5 hadoop supergroup        272 2013-06-20 12:38 /user/hadoop/har/input.har/_index
-rw-r--r--   5 hadoop supergroup         23 2013-06-20 12:38 /user/hadoop/har/input.har/_masterindex
-rw-r--r--   2 hadoop supergroup    1777168 2013-06-20 12:38 /user/hadoop/har/input.har/part-0
这里可以看到har文件包括,两个索引文件,多个part文件,这里只显示一个。part文件是多个原文件的集合,根据index文件去找到原文件。
如果用har uri去访问的话,这些文件就会隐藏起来,只显示原文件
[hadoop@namenode ~]$hadoop fs -lsr har:///user/hadoop/har/input.har
drwxr-xr-x   - hadoop supergroup          0 2013-05-23 11:35 /user/hadoop/har/input.har/input
-rw-r--r--   2 hadoop supergroup     888978 2013-05-23 11:35 /user/hadoop/har/input.har/input/1902
-rw-r--r--   2 hadoop supergroup     888190 2013-05-23 11:35 /user/hadoop/har/input.har/input/1901
还可以象普通文件系统那样访问har下一级的文
[hadoop@namenode ~]$hadoop fs -lsr har:///user/hadoop/har/input.har/input
-rw-r--r--   2 hadoop supergroup     888978 2013-05-23 11:35 /user/hadoop/har/input.har/input/1902
-rw-r--r--   2 hadoop supergroup     888190 2013-05-23 11:35 /user/hadoop/har/input.har/input/1901
如果要远程访问的话可以使用以下命令
[hadoop@namenode ~]$hadoop fs -lsr har://hdfs-namenode:9000/user/hadoop/har/input.har/input
-rw-r--r--   2 hadoop supergroup     888978 2013-05-23 11:35 /user/hadoop/har/input.har/input/1902
-rw-r--r--   2 hadoop supergroup     888190 2013-05-23 11:35 /user/hadoop/har/input.har/input/1901
har开头说明时har文件系统,hdfs-域名:端口,har文件系统进行转换直到har文件末位,例子中会转换为hdfs://namenode:9000/user/hadoop/har/input.har,剩余的部分仍然用archive方式打开:input
删除文件相对简单,但需要递归删除,否则报错
[hadoop@namenode ~]$hadoop fs -rmr har/input.har
Deleted hdfs://192.168.115.5:9000/user/hadoop/har/input.har

限制

archive文件有一些限制条件

1.创建archive文件要消耗和原文件一样多的硬盘空间

2.archive文件不支持压缩,尽管archive文件看起来象已经被压缩过了。

3.archive文件一旦创建就无法改变,这就意味这你要改一些东西的话,你需要创新创建archive文件

4.虽然解决了namenode的内存空间问题,但是在执行mapreduce时,会把多个小文件交给同一个mapreduce去split,这样明显是低效的

解决namenode内存的问题可以参照之前的文章中的hdfs federation。

 

 

 

转载于:https://www.cnblogs.com/snake-hand/p/3149452.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/274192.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

人民币小写金额转大写金额

#region 人民币小写金额转大写金额/// <summary>/// 小写金额转大写金额/// </summary>/// <param name"Money">接收需要转换的小写金额</param>/// <returns>返回大写金额</returns>public static string ConvertMoney(Decimal…

饥饿的盛世读后感_满足任何设计师饥饿感的原型制作工具

饥饿的盛世读后感Tell me if this story sounds familiar to you. You just wrapped up a design in Sketch -a design that took you hours, and now you want to bring it to life. Sketch’s built-in prototyping tool doesn’t allow you to create all the interactions …

关于软件版本的说明

Trial&#xff1a;试用版&#xff0c;软件在功能或时间上有所限制&#xff0c;如果想解除限制&#xff0c;需要购买零售版。 Retail&#xff1a;零售版。Free&#xff1a;免费版。Full&#xff1a;完全版。Alpha&#xff1a;内部测试版&#xff0c;通常在Beta版发布之前推出。…

figma 安装插件_我制作Figma插件的经验

figma 安装插件Since Figma released the Figma Community (Beta), I’ve been working on Figma plugins in my free time while I study the code. With the help of an engineer friend of mine, I’ve developed four small plugins so far. As I continue to update these…

术语解释_术语

术语解释Colour has a great impact in the world around us and this is no different in User Interfaces (UI). However, it’s not always given the importance it deserves. Sometimes colour is understood as a purely aesthetic element that is completely relative …

安卓中的对话框通知---简单的对话框入门

当你的应用需要显示一个进度条或需要用户对信息进行确认时&#xff0c;可以使用对话框来完成。 1、用一个按钮来进行测试&#xff0c;在layout文件中的activity_main.xml文件中添加一个Button按钮&#xff1a; <RelativeLayout xmlns:android"http://schemas.android.c…

mac photoshop_我讨厌Photoshop…

mac photoshopIt probably sounds odd to hear a visual designer say they hate Photoshop. It’s sort of like hearing a writer say they hate Word. It’s sort of a given that Photoshop is the medium within which visual designers work their magic. It’s also one…

PHP中的ob_start用法详解

用PHP的ob_start();控制您的浏览器cache Output Control 函数可以让你自由控制脚本中数据的输出。它非常地有用&#xff0c;特别是对于&#xff1a;当你想在数据已经输出后&#xff0c;再输出文件头的情况。输出控制函数不对使用 header() 或 setcookie(), 发送的文件头信息产生…

做事用人 用人做事_做事:构建我的第一个Web应用程序的经验教训

做事用人 用人做事On the 5th of June, 2020, after almost two weeks of (re)learning javascript, fixing bugs, creating new ones and of course, lots of testing, I launched Writty on ProductHunt. An open-source text editor to help anyone who is into writing to …

[转]C#委托的异步调用

本文将主要通过“同步调用”、“异步调用”、“异步回调”三个示例来讲解在用委托执行同一个“加法类”的时候的的区别和利弊。 首先&#xff0c;通过代码定义一个委托和下面三个示例将要调用的方法&#xff1a; /*添加的命名空间using System.Threading;using System.Runtime.…

vista下载_Vista和视图在游戏设计中的功能

vista下载Views in video games are observation points used to highlight a lot of objects into one frame or shot using a special camera move. Vistas are special types of views that show distant objects, mainly far off landscapes.电子游戏中的视图是观察点&…

微软开始提供公共预览版Windows 8.1下载

用户可在微软发布官方更新时免费下载Windows 8.1&#xff0c;这个最新版本的Windows 8系统对搜索系统作出了改进&#xff0c;此外还修改了Windows Store&#xff0c;并对核心应用进行了升级。Windows 8.1还重新推出了“开始”按钮&#xff0c;并对用户界面作出了多处修改。虽然…

keynote使用手册_如何使用Keynote和智能手机为AR创建原型

keynote使用手册Designing for AR is perhaps one of the most interesting applications of UX. As this incredible technology is being put to use for unique applications, UX Designers are tasked with creating user interfaces for an augmented experience, that do…

我会永远永远的爱你,直到你不爱我的那一天

【one】电话铃声响起的时候&#xff0c;林岫正好解下衣服的最后一颗纽扣。她站在原地&#xff0c;看着桌面上不断震动的手机&#xff0c;很久都没有接。“林医生&#xff0c;你的电话”&#xff0c;有同事在身旁好心的提醒。她依然没有动&#xff0c;只是静静注视着那个手机&am…

HTML5工具

HTML5工具 HTML&#xff08;Hyper Text Mark-up Language &#xff09;即超文本标记语言&#xff0c;自万维网初创之日起&#xff0c;它就已经成为满意度很高的公共语言。在过去的两年里&#xff0c;HTML5在性能上得到了很大的提升和改进&#xff0c;当仁不让的获得了大众的青睐…

远程控制工具_不要让您的工具控制您

远程控制工具When to Use Optical Alignment — You’re the Designer. You Know What’s Best.何时使用光学对准—您是设计师。 你知道什么是最好的。 Let’s talk about the tools the vast majority of us use on a day to day basis… These tools are Incredibly powerfu…

模态和非模态代码_我们如何使模态可用和可访问?

模态和非模态代码什么是模态&#xff1f; (What are modals?) A modal, or modal dialog, is an overlay window that opens on top of the current primary content or screen. It places focus on itself, usually making the background inactive (“inert”) — i.e. visu…

如何查看数据文件或者Log文件是否增长过?

在论坛看到一个帖子&#xff0c;说数据库变慢了一段时间&#xff0c;发现这段时间数据库文件的最后修改时间跟变慢的世界一致&#xff0c;想知道这段时间是否文件确实增长了。 其实SQL Server提供了数据增长的Event&#xff0c;而且Default Trace里面就记录了。 下面我们做个测…

软件项目开发 学校自行开发_自行开发游戏

软件项目开发 学校自行开发Making a game is not easy. Quite the contrary; it’s an incredibly difficult and daunting task. Game development typically takes teams of people, thousands of hours worth of labor, and hundreds of thousands — if not millions — of…

jquery Fancybox使用教程

jquery Fancybox使用教程 Fancybox是一款基于jquery的对图片展示播放的插件&#xff0c;当然&#xff0c;它html文本、flash动画、iframe以及ajax也予以支持。还可以通过css自定义外观&#xff0c;阴影效果超级赞&#xff01; 演示效果&#xff1a;http://www.phpddt.com/demo/…