说明:
生产环境下,hadoop的副本因子一般配置为3,但在测试环境或本地pc虚拟机下,如果磁盘较小,可以考虑调整副本数以减少容量限制。
命令格式:
hadoop fs -setrep [-R] [-w]
参数说明:
-R:(向后兼容)
-w:(等待副本复制完成)
-rep:numReplicas
-path:希望进行副本数调整的hdfs路径
来自官网的说明:http://hadoop.apache.org/docs/stable/hadoop-project-dist/hadoop-common/FileSystemShell.html
setrep
Usage: hadoop fs -setrep [-R] [-w] <numReplicas> <path>
Changes the replication factor of a file. If path is a directory then the command recursively changes the replication factor of all files under the directory tree rooted at path.
Options:
The -w flag requests that the command wait for the replication to complete. This can potentially take a very long time.(等待副本复制完成)
The -R flag is accepted for backwards compatibility. It has no effect.(向后兼容)
Example:
hadoop fs -setrep -w 3 /user/hadoop/dir1
Exit Code:
Returns 0 on success and -1 on error.