Mais conteúdo relacionado
Semelhante a HDFS (fsimage and edits) in CDH3,CDH4 (20)
HDFS (fsimage and edits) in CDH3,CDH4
- 3. CDH3のメタデータ
[root@localhost ~]# ls -ltr /var/lib/hadoop-0.20/cache/hadoop/dfs/name/current/
total 1100
-rw-r--r-- 1 hdfs hdfs 101 Jan 30 00:21 VERSION
-rw-r--r-- 1 hdfs hdfs 8 Jan 30 00:21 fstime
-rw-r--r-- 1 hdfs hdfs 57248 Jan 30 00:21 fsimage
-rw-r--r-- 1 hdfs hdfs 1048580 Jan 31 16:16 edits
after checkpoint
[root@localhost ~]# ls -ltr /var/lib/hadoop-0.20/cache/hadoop/dfs/name/current/
total 84
-rw-r--r-- 1 hdfs hdfs 101 Feb 5 14:37 VERSION
-rw-r--r-- 1 hdfs hdfs 8 Feb 5 14:37 fstime
-rw-r--r-- 1 hdfs hdfs 66760 Feb 5 14:37 fsimage
-rw-r--r-- 1 hdfs hdfs 4 Feb 5 14:37 edits
- 4. メタ情報の更新 (CDH3)
NameNode CheckPoint CheckPoint
put file start Done
t0 t1 t2 t3 t4
リネーム
fsimage fsimage.ckpt fsimage
edits更新
edits メモリ上のメタ情報更新 edits.new edits
作成 リネーム
fstime fstime
取得 転送 時刻更新
Secondary NameNode
fsimage fsimage.ckpt
マージ
edits
- 6. CDH4のメタデータ
HDFSフォーマット直後
-bash-4.1$ ls -l /var/lib/hadoop-hdfs/cache/hdfs/dfs/name/current/
total 1040
-rw-r--r-- 1 hdfs hdfs 1048576 Feb 5 01:35 edits_inprogress_0000000000000000001
-rw-rw-r-- 1 hdfs hdfs 119 Feb 5 01:33 fsimage_0000000000000000000
-rw-rw-r-- 1 hdfs hdfs 62 Feb 5 01:33 fsimage_0000000000000000000.md5
-rw-r--r-- 1 hdfs hdfs 2 Feb 5 01:35 seen_txid
-rw-rw-r-- 1 hdfs hdfs 202 Feb 5 01:33 VERSION
-bash-4.1$ hexdump -C /var/lib/hadoop-hdfs/cache/hdfs/dfs/name/current/seen_txid
00000000 31 0a |1.|
00000002
seen_txidにはトラ
ンザクションIDが含
まれる
- 8. oiv - fsimage viewer
-bash-4.1$ hdfs oiv -i /var/lib/hadoop-
hdfs/cache/hdfs/dfs/name/current/fsimage_000000000000000
0000 -o aaa
-bash-4.1$ cat aaa
drwxr-xr-x - hdfs supergroup 0 1969-12-31 19:00 /
checkpointが発生していないので
putしたファイルは
まだfsimageに書き込まれていない
- 9. oev – edits viewer
-bash-4.1$ hdfs oev -i /var/lib/hadoop-hdfs/cache/hdfs/dfs/name/current/edits_0000000000000000020-0000000000000000027 -o bbb
cat bbb
<?xml version="1.0" encoding="UTF-8"?>
<EDITS>
<EDITS_VERSION>-40</EDITS_VERSION>
<RECORD>
<OPCODE>OP_START_LOG_SEGMENT</OPCODE>
<DATA>
開始トランザ
<TXID>20</TXID>
</DATA>
クションID
</RECORD>
<RECORD>
<OPCODE>OP_SET_GENSTAMP</OPCODE>
<DATA>
<TXID>21</TXID>
<GENSTAMP>1003</GENSTAMP>
</DATA> トランザク
</RECORD>
<RECORD> ションID
<OPCODE>OP_ADD</OPCODE>
ここから <DATA>
<TXID>22</TXID>
putトラ <LENGTH>0</LENGTH>
<PATH>/user/training/hosts._COPYING_</PATH>
ンザク <REPLICATION>1</REPLICATION>
<MTIME>1360046220628</MTIME>
ション <ATIME>1360046220628</ATIME>
<BLOCKSIZE>67108864</BLOCKSIZE>
<CLIENT_NAME>DFSClient_NONMAPREDUCE_1911533003_1</CLIENT_NAME>
<CLIENT_MACHINE>127.0.0.1</CLIENT_MACHINE>
<PERMISSION_STATUS>
<USERNAME>training</USERNAME>
<GROUPNAME>supergroup</GROUPNAME>
<MODE>420</MODE>
</PERMISSION_STATUS>
</DATA>
</RECORD>
- 10. oev – edits viewer (cont)
ファイル名edits_0000000000000000020-0000000000000000027
<RECORD>
<OPCODE>OP_SET_GENSTAMP</OPCODE>
<DATA>
<TXID>23</TXID>
<GENSTAMP>1004</GENSTAMP>
</DATA>
</RECORD>
<RECORD>
<OPCODE>OP_UPDATE_BLOCKS</OPCODE>
<DATA>
<TXID>24</TXID>
<PATH>/user/training/hosts._COPYING_</PATH>
<BLOCK>
<BLOCK_ID>-3498739165311848505</BLOCK_ID>
<NUM_BYTES>0</NUM_BYTES>
<GENSTAMP>1004</GENSTAMP>
</BLOCK>
</DATA>
</RECORD>
<RECORD>
<OPCODE>OP_CLOSE</OPCODE>
<DATA>
<TXID>25</TXID>
<LENGTH>0</LENGTH>
<PATH>/user/training/hosts._COPYING_</PATH>
<REPLICATION>1</REPLICATION>
<MTIME>1360046220735</MTIME>
<ATIME>1360046220628</ATIME>
<BLOCKSIZE>67108864</BLOCKSIZE>
<CLIENT_NAME></CLIENT_NAME>
<CLIENT_MACHINE></CLIENT_MACHINE>
<BLOCK>
<BLOCK_ID>-3498739165311848505</BLOCK_ID>
<NUM_BYTES>83</NUM_BYTES>
<GENSTAMP>1004</GENSTAMP>
</BLOCK>
- 11. oev – edits viewer (cont)
ファイル名:edits_0000000000000000020-0000000000000000027
<PERMISSION_STATUS>
<USERNAME>training</USERNAME>
<GROUPNAME>supergroup</GROUPNAME>
<MODE>420</MODE>
</PERMISSION_STATUS>
</DATA>
</RECORD>
<RECORD>
<OPCODE>OP_RENAME_OLD</OPCODE>
<DATA>
<TXID>26</TXID>
<LENGTH>0</LENGTH>
<SRC>/user/training/hosts._COPYING_</SRC>
<DST>/user/training/hosts</DST> 最終トランザ
<TIMESTAMP>1360046220738</TIMESTAMP>
</DATA> クションID
</RECORD>
<RECORD>
<OPCODE>OP_END_LOG_SEGMENT</OPCODE>
<DATA>
<TXID>27</TXID>
</DATA>
</RECORD>
</EDITS>
- 12. チェックポイント後
チェックポイント後
-bash-4.1$ ls -l /var/lib/hadoop-hdfs/cache/hdfs/dfs/name/current/
total 1376
-rw-r--r-- 1 hdfs hdfs 1317 Feb 5 01:36 edits_0000000000000000001-0000000000000000019
-rw-r--r-- 1 hdfs hdfs 471 Feb 5 01:37 edits_0000000000000000020-0000000000000000027
-rw-r--r-- 1 hdfs hdfs 30 Feb 5 01:38 edits_0000000000000000028-0000000000000000029
-rw-r--r-- 1 hdfs hdfs 30 Feb 5 01:39 edits_0000000000000000030-0000000000000000031
-rw-r--r-- 1 hdfs hdfs 30 Feb 5 01:40 edits_0000000000000000032-0000000000000000033
-rw-r--r-- 1 hdfs hdfs 30 Feb 5 01:41 edits_0000000000000000034-0000000000000000035
(略)
-rw-r--r-- 1 hdfs hdfs 30 Feb 5 02:53 edits_0000000000000000178-0000000000000000179
-rw-r--r-- 1 hdfs hdfs 30 Feb 5 02:54 edits_0000000000000000180-0000000000000000181
-rw-r--r-- 1 hdfs hdfs 30 Feb 5 02:55 edits_0000000000000000182-0000000000000000183
-rw-r--r-- 1 hdfs hdfs 30 Feb 5 02:56 edits_0000000000000000184-0000000000000000185
-rw-r--r-- 1 hdfs hdfs 30 Feb 5 02:58 edits_0000000000000000186-0000000000000000187
-rw-r--r-- 1 hdfs hdfs 1048576 Feb 5 02:58 edits_inprogress_0000000000000000188
-rw-rw-r-- 1 hdfs hdfs 119 Feb 5 01:33 fsimage_0000000000000000000
-rw-rw-r-- 1 hdfs hdfs 62 Feb 5 01:33 fsimage_0000000000000000000.md5
-rw-r--r-- 1 hdfs hdfs 1211 Feb 5 02:58 fsimage_0000000000000000187
-rw-r--r-- 1 hdfs hdfs 62 Feb 5 02:58 fsimage_0000000000000000187.md5
-rw-r--r-- 1 hdfs hdfs 4 Feb 5 02:58 seen_txid
seen_txidにはトラ
-bash-4.1$ hexdump -C /var/lib/hadoop-hdfs/cache/hdfs/dfs/name/current/seen_txid ンザクションIDが含
00000000 31 38 38 0a
00000004
|188.|
まれる
- 13. oiv - fsimage viewer
-bash-4.1$ hdfs oiv -i /var/lib/hadoop-
hdfs/cache/hdfs/dfs/name/current/fsimage_0000000000000000187 -o aaa
-bash-4.1$ cat aaa
drwxr-xr-x - hdfs supergroup 0 2013-02-05 01:35 /
drwxr-xr-x - hdfs supergroup 0 2013-02-05 01:35 /user
drwxr-xr-x - mapred supergroup 0 2013-02-05 01:35 /var
drwxrwxrwt - hdfs supergroup 0 2013-02-05 01:37 /user/training
-rw-r--r-- 1 training supergroup 83 2013-02-05 01:37 /user/training/hosts
drwxr-xr-x - mapred supergroup 0 2013-02-05 01:35 /var/lib
drwxr-xr-x - mapred supergroup 0 2013-02-05 01:35 /var/lib/hadoop-hdfs
drwxr-xr-x - mapred supergroup 0 2013-02-05 01:35 /var/lib/hadoop-hdfs/cache
drwxr-xr-x - mapred supergroup 0 2013-02-05 01:35 /var/lib/hadoop-
hdfs/cache/mapred
drwxr-xr-x - mapred supergroup 0 2013-02-05 01:35 /var/lib/hadoop-
hdfs/cache/mapred/mapred
drwx------ - mapred supergroup 0 2013-02-05 01:35 /var/lib/hadoop-
checkpointが発生した
hdfs/cache/mapred/mapred/system
のでfsimageに書き込
-rw------- 1 mapred supergroup 4 2013-02-05 01:35 /var/lib/hadoop-
hdfs/cache/mapred/mapred/system/jobtracker.info
まれている
- 14. oev – edits viewer
-bash-4.1$ hdfs oev -i /var/lib/hadoop-hdfs/cache/hdfs/dfs/name/current/edits_inprogress_0000000000000000188 -o
bbb
-bash-4.1$ cat bbb
<?xml version="1.0" encoding="UTF-8"?>
<EDITS>
<EDITS_VERSION>-40</EDITS_VERSION>
開始トランザ
<RECORD> クションID
<OPCODE>OP_START_LOG_SEGMENT</OPCODE>
<DATA>
<TXID>188</TXID>
</DATA>
</RECORD>
</EDITS>
- 15. メタ情報の更新(CDH4)-1
NameNode
ロール ロール
t0 t
(トランザクションが10回あった)
1 t
(トランザクションが22回あった)
2
fsimage_0 新しいトランザクションIDで 新しいトランザクションIDで
新規作成 新規作成
edits_inprogress_1 edits_inprogress_11 edits_inprogress_33
edits_1-10 edits_1-10
1-10までのトランザクションを
edits_11-32
ファイナライズしてリネーム
11-32までのトランザク
Secondary NameNode ションをファイナライ
ズしてリネーム
最初の10回+今回のト
ロールの発生タイミング ラザクション22回
1) NNの開始
2) saveNameSpace
3) SecondaryNNのCheckPoint
4) 失敗したストレージ領域が利用
可能になった
5) 管理コマンド
- 16. メタ情報の更新(CDH4)-2
NameNode CheckPoint CheckPoint
start Done
t4 t5 t6
fsimage_0 fsimage_0
fsimage_ckpt_33
fsimage_33 リネーム
edits_inprogress_33 edits_inprogress_34
作成
edits_1-10 edits_1-10
edits_11-32 edits_11-32
転送
edits_33-
Secondary NameNode
33
取得
fsimage_ckpt_33
マージ
- 17. メタ情報の更新(CDH4)-3
fsimage_0 保持する世代数
fsimage_33 dfs.namenode.num.checkpoints.retained
edits_inprogress_34
edits_1-10
edits_11-32 保持する世代数
edits_33-33 dfs.namenode.num.extra.edits.retained
チェックポイントを行う間隔
dfs.namenode.checkpoint.period
チェックポイントを行うトランザクション数
dfs.namenode.checkpoint.txns
SecondaryNameNodeがNameNodeをポーリングする間隔
dfs.namenode.checkpoint.check.period
※ファイル名にトランザクションIDが付与されるため、
fstimeは不要となった
- 19. リカバリ
• クラッシュなどからの復旧時の挙動
• _inprogressが名前に付いているファイルが存在するディレク
トリ
• Invalidになったファイルを含むディレクトリがある場合
NameNodeはそのディレクトリへの書き込みを中止
• 複数のストレージディレクトリがあり、一部のディレクトリだけ壊
れているようなケース
• アクティブな編集ログのセットを含んでいる場合はNameNode
がクラッシュしているということ
• 起動時にリプレイが必要
- 21. 参考資料
• HDFSのパラメータ一覧
• http://archive.cloudera.com/cdh4/cdh/4/hadoop/hadoop-
project-dist/hadoop-hdfs/hdfs-default.xml
• HDFS-1073
• https://issues.apache.org/jira/secure/attachment/12478323/hdfs
1073.pdf
• O’Reilly Hadoop: The definitive Guide, 2nd edition