博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Apache Hadoop文档翻译之四(Edits Viewer指南)
阅读量:7234 次
发布时间:2019-06-29

本文共 3107 字,大约阅读时间需要 10 分钟。

概述

离线Edits查看器是一个解析Edits日志文件的工具。目前的程序用于不同格式之间的转换,包括xml(比二进制文件更易读且容易修改)。

这个工具可以解析formats -18及以后的版本。这个工具只操作文件,并不需要Hadoop集群处于运行状态。

输入格式支持: 1、二进制 2、xml格式

输出格式: 1、二进制 2、xml格式 3、stats:打印统计数据

用法

XML Processor

将edits文件转换成xml格式,并输出文件

bash$ bin/hdfs oev -p xml -i edits -o edits.xml复制代码

因为xml是默认的处理格式,所以上面命令也可以简写成如下

bash$ bin/hdfs oev -i edits -o edits.xml复制代码

输出格式大致如下:

?xml version="1.0" encoding="UTF-8"?>   
-64
OP_START_LOG_SEGMENT
1
OP_UPDATE_MASTER_KEY
2
1
1487921580728
2e127ca41c7de215
...remaining output omitted...复制代码

Binary Processor

xml格式文件转二进制

bash$ bin/hdfs oev -p binary -i edits.xml -o edits复制代码

Stats Processor

统计edits日志文件中各个操作数量

bash$ bin/hdfs oev -p stats -i edits -o edits.stats复制代码

输出格式大致如下:

VERSION                             : -64   OP_ADD                         (  0): 8   OP_RENAME_OLD                  (  1): 1   OP_DELETE                      (  2): 1   OP_MKDIR                       (  3): 1   OP_SET_REPLICATION             (  4): 1   OP_DATANODE_ADD                (  5): 0   OP_DATANODE_REMOVE             (  6): 0   OP_SET_PERMISSIONS             (  7): 1   OP_SET_OWNER                   (  8): 1   OP_CLOSE                       (  9): 9   OP_SET_GENSTAMP_V1             ( 10): 0   ...some output omitted...   OP_APPEND                      ( 47): 1   OP_SET_QUOTA_BY_STORAGETYPE    ( 48): 1   OP_INVALID                     ( -1): 0复制代码

选项

Flag Description
[-i ; --inputFile] input file Specify the input edits log file to process. Xml (case insensitive) extension means XML format otherwise binary format is assumed. Required.
[-o ; --outputFile] output file Specify the output filename, if the specified output processor generates one. If the specified file already exists, it is silently overwritten. Required.
[-p ; --processor] processor Specify the image processor to apply against the image file. Currently valid options are binary, xml (default) and stats.
[-v ; --verbose] Print the input and output filenames and pipe output of processor to console as well as specified file. On extremely large files, this may increase processing time by an order of magnitude.
[-f ; --fix-txids] Renumber the transaction IDs in the input, so that there are no gaps or invalid transaction IDs.
[-r ; --recover] When reading binary edit logs, use recovery mode. This will give you the chance to skip corrupt parts of the edit log.
[-h ; --help] Display the tool usage and help information and exit.

案例研究:Hadoop集群恢复

当Hadoop集群出现问题,比如edits日志文件损坏但还是有部分是正常的。这个时候,我们可以使用该工具将二进制文件转换成xml格式,然后对xml格式进行修改,最终将xml文件转回二进制。如果edits文件缺少结束标识(以opCode -1结束),工具执行时会意识到这一点,通常格式化也将终止。

如果xml文件中没有结束标识,我们可以在最后一个正确的操作记录后面加上结束标识。任何在“opCode -1”的操作都会被忽略。

结束标识示例(带有 opCode -1):

-1
复制代码

转载地址:http://ytlfm.baihongyu.com/

你可能感兴趣的文章
数据库每分钟运行监控SQL
查看>>
Log4net
查看>>
求素数
查看>>
Activemq 平台搭建与C#示列
查看>>
AC日记——聪明的质监员 洛谷 P1314
查看>>
微软推出首个Microsoft Azure Stack技术预览版
查看>>
Proguard语法及常用proguard.cfg代码段
查看>>
OOP 第二章作业总结
查看>>
python什么时候使用多线程,什么时候使用多进程?
查看>>
Quartz中时间表达式的设置-----corn表达式 (转)(http://www.cnblogs.com/GarfieldTom/p/3746290.html)...
查看>>
Flash Media Server 5.0 (FMS)注册码
查看>>
根据匹配词个数排序
查看>>
Xcopy命令参数使用介绍
查看>>
Java ArrayList、Vector和LinkedList等的差别与用法(转)
查看>>
用flock命令解决Linux计划任务重复执行
查看>>
[再寄小读者之数学篇](2014-06-19 两个分部积分)
查看>>
Opencv cvCircle函数
查看>>
CMD命令 - yanghj - 博客园
查看>>
mysql 加入列,改动列,删除列。
查看>>
网格导入设置 Import settings for Meshes
查看>>