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

1、hadoop fs -setrep

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副本

[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目录的副本数

[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

[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 ~]# 
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值