Hadoop fs 查找块大小?
在 Hadoop fs 中如何查找特定文件的块大小?
我主要对命令行感兴趣,例如:
hadoop fs ... hdfs://fs1.data/...
但它看起来不存在。有Java解决方案吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
在 Hadoop fs 中如何查找特定文件的块大小?
我主要对命令行感兴趣,例如:
hadoop fs ... hdfs://fs1.data/...
但它看起来不存在。有Java解决方案吗?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(5)
其他答案中的 fsck 命令列出了块并允许您查看块的数量。但是,要查看实际块大小(以字节为单位)且没有额外的麻烦,请执行以下操作:
默认块大小为:
有关单位的详细信息
然而,块大小的单位未记录在 hadoop fs -stat 命令中,看着 源代码行 和 它调用的方法的文档< /a> 我们可以看到它使用字节并且无法报告超过大约 9 艾字节的块大小。
hdfs getconf
命令的单位可能不是字节。它返回配置文件中用于 dfs.blocksize 的任何字符串。 (这可以在 最终函数和其间接调用者)The
fsck
commands in the other answers list the blocks and allow you to see the number of blocks. However, to see the actual block size in bytes with no extra cruft do:Default block size is:
Details about units
The units for the block size are not documented in the
hadoop fs -stat
command, however, looking at the source line and the docs for the method it calls we can see it uses bytes and cannot report block sizes over about 9 exabytes.The units for the
hdfs getconf
command may not be bytes. It returns whatever string is being used fordfs.blocksize
in the configuration file. (This is seen in the source for the final function and its indirect caller)似乎 hadoop fs 没有选项可以执行此操作。
但hadoop fsck 可以。
你可以试试这个
Seems hadoop fs doesn't have options to do this.
But hadoop fsck could.
You can try this
我认为这应该是可行的:
但我得到连接被拒绝
I think it should be doable with:
but I get Connection refused
尝试编写下面的代码
Try to code below
为了显示 HDFS 中现有文件的实际块大小,我使用了:
For displaying the actual block size of the existing file within HDFS I used: