天天看點

HDFS塊檢查指令Fsck機理的相關分析Fsck指令Fsck參數使用

http://www.2cto.com/kf/201603/496108.html

在HDFS中,所有的檔案都是以block塊的概念而存在的,那麼在這樣海量的檔案資料的情況下,難免會發生一些檔案塊損壞的現象,那麼有什麼好的辦法去發現呢.答案是使用HDFS的fsck相關的指令.這個指令獨立于dfsadmin的指令,可能會讓部分人不知道HDFS中還存在這樣的指令,本文就來深度挖掘一下這個指令的特殊的用處和内在機理的實作.

其實說到fsck指令本身,熟悉Linux作業系統的人,可能或多或少聽到過或使用過這個指令.Fsck指令的全稱為file system check,更加類似的是一種修複指令.當然,本文不會講大量的關于作業系統的fsck怎麼用,而是HDFS下的fsck的使用,在bin/hdfs fsck下還是有很多可選參數的.

本人在測試叢集中輸入hdfs fsck指令,擷取了幫助資訊,在此資訊中展示了最全的參數使用說明:

<a href="http://blog.51cto.com/yntmdr/1771388#">?</a>

<code>$ hdfs fsck</code>

<code>Usage: hdfs fsck[-list-corruptfileblocks | [-move | -delete | -openforwrite] [-files [-blocks [-locations | -racks]]]]start checking from </code><code>this</code> <code>path</code>

<code>    </code><code>-move   move corrupted files to /lost+found</code>

<code>    </code><code>-delete delete corrupted files</code>

<code>    </code><code>-files  print out files being checked</code>

<code>    </code><code>-openforwrite   print out files opened </code><code>for</code> <code>write</code>

<code>    </code><code>-includeSnapshots   include snapshot data </code><code>if</code> <code>the given path indicates a snapshottable directory or there are snapshottable directories under it</code>

<code>    </code><code>-list-corruptfileblocks print out list of missing blocks and files they belong to</code>

<code>    </code><code>-blocks print out block report</code>

<code>    </code><code>-locations  print out locations </code><code>for</code> <code>every block</code>

<code>    </code><code>-racks  print out network topology </code><code>for</code> <code>data-node locations</code>

<code>    </code><code>-storagepolicies    print out storage policy summary </code><code>for</code> <code>the blocks</code>

<code>    </code><code>-blockId    print out which file </code><code>this</code> <code>blockId belongs to, locations (nodes, racks) of </code><code>this</code> <code>block, and other diagnostics info (under replicated, corrupted or not, etc)</code>

簡單的總結一下,首先是必填參數和指令名:

<code>bin/hdfs fsck</code>

然後是一堆的可選參數:

-move: 移動損壞的檔案到/lost+found目錄下 -delete: 删除損壞的檔案 -files: 輸出正在被檢測的檔案 -openforwrite: 輸出檢測中的正在被寫的檔案 -includeSnapshots: 檢測的檔案包括系統snapShot快照目錄下的 -list-corruptfileblocks: 輸出損壞的塊及其所屬的檔案 -blocks: 輸出block的詳細報告 -locations: 輸出block的位置資訊 -racks: 輸出block的網絡拓撲結構資訊 -storagepolicies: 輸出block的存儲政策資訊 -blockId: 輸出指定blockId所屬塊的狀況,位置等資訊

具體參數功能對應到相應的程式會在下文的分析中進行詳細的闡述.

本文轉自 yntmdr 51CTO部落格,原文連結:http://blog.51cto.com/yntmdr/1771388,如需轉載請自行聯系原作者

繼續閱讀