使 HDFS 计算本地文件的校验和。

Make HDFS calulcate checksum for local file.

我正在尝试使用 hadoop fs -checksum 计算本地文件校验和。但它只有 returns None。

[centos@sandbox tmp]$ hadoop fs -checksum file:///user/centos//a.json file:///user/centos/a.json NONE

我试过使用

hadoop fs -copyFromLocal a.json file:///user/centos/a.json 这样在本地文件夹 /user/centos 生成一个 .a.json.crc file。但是结果校验和还是returnsnone。

如何让Hadoop在本地计算校验和?

hadoop fs -checksum 目前无法计算本地文件系统中文件的校验和。可能的解决方法是:

  • Apache JIRA HADOOP-12326 tracks supporting files on the local file system as a target of the hadoop fs -checksum command. If you really need the capability now, then you could potentially download the Hadoop source, apply the patch attached to HADOOP-12326, and create a custom build by following the directions in BUILDING.txt。请注意,该补丁尚未获得 Apache Hadoop 社区的批准和提交,因此使用风险自负。
  • 如果您只是想在将文件从 HDFS 复制到本地文件系统时寻找一种携带 CRC 信息的方法,那么您可以将 -crc 参数传递给 get命令。

示例:

hadoop fs -get -crc hello

ls -lrta 
...
-rw-r--r--   1 cnauroth                    cnauroth                       12 Jun 23 15:28 .hello.crc
-rw-r--r--   1 cnauroth                    cnauroth                        6 Jun 23 15:28 hello
...