【问题标题】:Hadoop: Is it possible to avoid replication for certain files?Hadoop:是否可以避免某些文件的复制?
【发布时间】:2015-07-30 21:03:06
【问题描述】:

据我所知,在 hdfs 中,所有文件都被复制,但我们会在工作的情况下进行某些日志记录,我们不希望复制的文件可能会不必要地维护复制的副本,是否可以这样做?即避免只复制日志文件。?

【问题讨论】:

    标签: hadoop hdfs replication


    【解决方案1】:

    您可以使用 -setrep 标志和 hadoop fs shell 命令来设置复制。

    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
    

    为避免复制,您可以将 numReplicas 设置为 1。

    【讨论】:

    • 感谢 venkata 的回复,但我想知道是否可以仅为某些文件而不是整个文件系统设置复制因子。有办法吗?
    • 是的,我提到的只是一个文件。如果要为整个文件系统设置,则必须更改属性文件。
    猜你喜欢
    • 1970-01-01
    • 2021-02-14
    • 1970-01-01
    • 2013-09-17
    • 2015-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多