博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hadoop HDFS 设置文件复试数(备份数)
阅读量:4114 次
发布时间:2019-05-25

本文共 678 字,大约阅读时间需要 2 分钟。

HDFS高可恢复行,高抗灾行,很重要一点就是通过存放多个副本来保证的,但是根据集群的规模不同,可能要设置不同的复制数,可通过配置文件和程序来实现。

方法一:通过配置文件实现 
在hdfs-site.xml中有个属性在hdfs-site.xml中有个属性

dfs.replication
3
Default block replication. The actual number of replications can be specified when the file is created. The default is used if replication is not specified in create time.
value默认为3,这个可以根据自己的情况设置。
方法二:在程序中设置

Configuration conf = new Configuration();		FileSystem fs = FileSystem.get(URI.create(hadoop_path), conf);		Path path = new Path(hadoop_path);		FSDataOutputStream out = fs.create(path);		// 控制复本数量-wt		fs.setReplication(path, (short) 1);

这里把复制数设为了1,在hdfs中只保存一个副本,通过管理webUI查看

你可能感兴趣的文章
Reverse Integer--反转整数
查看>>
Container With Most Water --装最多水的容器(重)
查看>>
Longest Common Prefix -最长公共前缀
查看>>
Letter Combinations of a Phone Number
查看>>
Single Number II --出现一次的数(重)
查看>>
Valid Parentheses --括号匹配
查看>>
Generate Parentheses--生成匹配括号(重)
查看>>
Remove Element--原地移除重复元素
查看>>
Remove Duplicates from Sorted Array--从有序数组中移除重复元素
查看>>
Count and Say
查看>>
Gas Station
查看>>
Palindrome Partitioning --回文切割 深搜(重重)
查看>>
Valid Palindrome 简单的回文判断
查看>>
Pascal's Triangle -- 生成杨辉三角
查看>>
Pascal's Triangle II 生成杨辉三角中的某行
查看>>
Minimum Depth of Binary Tree -- 二叉树的最小深度 DFS 加剪枝
查看>>
Climbing Stairs 爬楼梯方法 动态规划
查看>>
Merge Two Sorted Lists 合并两个有序链表
查看>>
pow(x,n) 为什么错这么多次
查看>>
Jump Game 动态规划
查看>>