前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >命令修改副本数:hadoop fs -setrep

命令修改副本数:hadoop fs -setrep

作者头像
程裕强
发布2022-05-06 19:35:10
2780
发布2022-05-06 19:35:10
举报

1、hadoop fs -setrep

代码语言:javascript
复制
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.

2、示例演示

(1)查看文件副本数,第二列的3表示3副本

代码语言:javascript
复制
[root@node1 ~]# hadoop fs -ls /test
18/01/23 01:24:46 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Found 4 items
-rw-r--r--   3 root hbase  100797385 2018-01-22 22:26 /test/a.tar
-rw-r--r--   3 root hbase  100854145 2018-01-22 22:26 /test/a.zip
-rw-r--r--   3 root hbase   38009648 2018-01-22 22:27 /test/kafka-2.10-0.10.2.0.x86_64.rpm
-rw-r--r--   3 root hbase    2374608 2018-01-22 22:27 /test/zookeeper-3.4.6-1.x86_64.rpm
[root@node1 ~]# 

(2)修改/test目录的副本数

代码语言:javascript
复制
[root@node1 ~]# hadoop fs -setrep -w 2 /test
18/01/23 01:24:58 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Replication 2 set: /test/a.tar
Replication 2 set: /test/a.zip
Replication 2 set: /test/kafka-2.10-0.10.2.0.x86_64.rpm
Replication 2 set: /test/zookeeper-3.4.6-1.x86_64.rpm
Waiting for /test/a.tar ...
WARNING: the waiting time may be long for DECREASING the number of replications.
. done
Waiting for /test/a.zip ... done
Waiting for /test/kafka-2.10-0.10.2.0.x86_64.rpm ... done
Waiting for /test/zookeeper-3.4.6-1.x86_64.rpm ... done
[root@node1 ~]# 

(3)再次查看副本数,第二列变成了2

代码语言:javascript
复制
[root@node1 ~]# hadoop fs -ls /test
18/01/23 01:25:12 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Found 4 items
-rw-r--r--   2 root hbase  100797385 2018-01-22 22:26 /test/a.tar
-rw-r--r--   2 root hbase  100854145 2018-01-22 22:26 /test/a.zip
-rw-r--r--   2 root hbase   38009648 2018-01-22 22:27 /test/kafka-2.10-0.10.2.0.x86_64.rpm
-rw-r--r--   2 root hbase    2374608 2018-01-22 22:27 /test/zookeeper-3.4.6-1.x86_64.rpm
[root@node1 ~]# 
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018-01-23,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1、hadoop fs -setrep
  • 2、示例演示
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档