一、 临时修改
可以在执行上传文件命令时,显示地指定存储的块大小。
1. 查看当前 HDFS文件块大小
我这里查看HDFS上的TEST目录下的jdk-7u25-linux-x64.gz 文件存储块大小。
1.1 终端命令方式查看
[xiaoyu@hadoop02 hadoop-1.1.2]$ ./bin/hadoop fs -stat "%o" TEST/jdk-7u25-linux-x64.gz
51200
51200
单位为B(字节)
1.2 或页面方式查看
打开haddop datanode节点的hdfs监控页面:
如下所示:
二、永久修改
这个需要修改hdfs-site.conf配置文件,增加全局参数dfs.block.size。
如下:
修改后参数
把配置同步到其它节点,并重启hdfs。
[xiaoyu@hadoop02 hadoop-1.1.2]
$ bin/stop-dfs.sh
no namenode to stop
hadoop02: stopping datanode
hadoop01: stopping secondarynamenode
[xiaoyu@hadoop02 hadoop-1.1.2] $ bin/start-dfs.sh
starting namenode, logging to /home/xiaoyu/hadoop-1.1.2/libexec/../logs/hadoop-xiaoyu-namenode-hadoop02.out
hadoop02: starting datanode, logging to /home/xiaoyu/hadoop-1.1.2/libexec/../logs/hadoop-xiaoyu-datanode-hadoop02.out
hadoop01: starting secondarynamenode, logging to /home/xiaoyu/hadoop-1.1.2/libexec/../logs/hadoop-xiaoyu-secondarynamenode-hadoop01.out
no namenode to stop
hadoop02: stopping datanode
hadoop01: stopping secondarynamenode
[xiaoyu@hadoop02 hadoop-1.1.2] $ bin/start-dfs.sh
starting namenode, logging to /home/xiaoyu/hadoop-1.1.2/libexec/../logs/hadoop-xiaoyu-namenode-hadoop02.out
hadoop02: starting datanode, logging to /home/xiaoyu/hadoop-1.1.2/libexec/../logs/hadoop-xiaoyu-datanode-hadoop02.out
hadoop01: starting secondarynamenode, logging to /home/xiaoyu/hadoop-1.1.2/libexec/../logs/hadoop-xiaoyu-secondarynamenode-hadoop01.out
重新查看TEST/jdk-7u25-linux-x64.gz 文件存储的块大小:
重新上传文件到HDFS,并重命名为 比较用_jdk-7u25-linux-x64.gz
参考资料:
本文转自xiaoyuwang 51CTO博客,原文链接:http://blog.51cto.com/wangxiaoyu/1293825,如需转载请自行联系原作者