HDFS 我们如何在Hadoop中设置特定于每个文件的块大小?

5anewei6  于 2022-12-09  发布在  HDFS
关注(0)|答案(1)|浏览(200)

例如,如果我的输入文件有500MB,我想这分裂250MB每个,如果我的输入文件是600MB块大小应该是300MB

y53ybaqx

y53ybaqx1#

If you are loading files into hdfs you can put with dfs.blocksize oprtion, you can calculate parameter in a shell depending on size.

hdfs dfs -D dfs.blocksize=268435456 -put myfile /some/hdfs/location

If you already have files in HDFS and want to change it's block size, you need to rewrite it.
(1) move file to tmp location:

hdfs dfs -mv /some/hdfs/location/myfile /tmp

(2) Copy it back with -D dfs.blocksize=268435456

hdfs dfs -D dfs.blocksize=268435456 -cp /tmp/myfile /some/hdfs/location

相关问题