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.pswp.cn/news/274192.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/274192.shtml
英文地址,請注明出處:http://en.pswp.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/…