HDFS中block的大小

news/2024/5/20 4:29:19 标签: hdfs, hadoop, 大数据, unix, java

block的大小与修改

Hadoop2.x/3.x版本中Block的默认大小为128M,早前版本中默认为64M,开发人员可以在hdfs-site.xml中添加如下标标签进行修改。

<!-- hdfs-site.xml --> 
<property>
  <name>dfs.blocksize</name>
  #value值代表block块的大小
  <value>256m</value>
</property>

HDFS默认配置

<!-- 
HDFS默认配置
hdfs-default.xml
-->
<property>
  <name>dfs.blocksize</name>
  <value>134217728</value>
  <description>
      The default block size for new files, in bytes.
      You can use the following suffix (case insensitive):
      k(kilo), m(mega), g(giga), t(tera), p(peta), e(exa) to specify the size (such as 128k, 512m, 1g, etc.),
      Or provide complete size in bytes (such as 134217728 for 128 MB).
  </description>
</property>

Hadoop2.x、3.x中block为什么默认为128M

block越大对一个block的传输时间会越长,block越小寻找block的时间会越长,通常认为寻址时间是传输时间的1%时为最佳状态。
HDFS中寻址时间一般为10ms,则传输时间最好为10ms/1%=1000ms=1s,而当前普通的机械硬盘的传输速度为100M/s左右,所以为了达到最佳状态,每个地址的数据大小最好为1s*100M/s=100M。
由此每个block大的大小默认设置为128M。

当切换了拥有更高传输速率的硬盘(如固态硬盘)时,可以将Block的大小适当增加以达到最佳状态。

block为什么不能过小或过大

如果block过小,存放的文件会被切分的过于零散,程序会将更多的时间消耗在寻找block中,NameNode也会消耗更多的空间来存储block所在主机的信息。
如果block过大,传输时间的%1会明显大于寻址时间,导致寻址时间与传输时间不平衡,另外InputFormat的默认切片规则会以block的大小确定切片的大小,block越大,切片就会越大,Map过程会变得缓慢。


http://www.niftyadmin.cn/n/1276365.html

相关文章

springBoot整合SqlSessionTemplate使用

实际开发中我们操作数据库持久化&#xff0c;总是需要写重复的mapper&#xff0c;service&#xff0c;xml浪费了我们大量的时间&#xff0c;在这里推荐大家使用SqlSessionTemplate 1.application.xml配置 server.port8081 #server.servlet.context-path/recordLog#数据源必填…

mysql 5.7 invalid default value for timestamp field

这是因为sql_mode中的NO_ZEROR_DATE导制的。 在strict mode中不允许0000-00-00作为合法日期&#xff0c;可以使用 show variables like sql_mode查看sql_mode&#xff0c;一种是把sql_modeSTRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUT‌​ION 另一种设置AL…

vue nodejs 构建_如何使用nodejs后端打字稿版本开发和构建vue js应用

vue nodejs 构建There are so many ways we can build Vue.js apps and ship for production. One way is to create the Vue app with NodeJS or Java, and another way is to develop and serve that static content with the NGINX web server. With NodeJS, we have to dea…

springboot查看所有的Bean

修改启动类的代码&#xff0c;配置如下&#xff1a; public static void main(String[] args) {ConfigurableApplicationContext run SpringApplication.run(启动类xxx.class, args);String[] beanDefinitionNames run.getBeanDefinitionNames(); }String[]存储着所有的bean…

React中的编码实践

Let’s first be clear that this is not a post with all the best coding practices in React. It’s a post about some of the practices that I have learned over years of my experience while working with React. They might not be the best ones, but they surely a…

使用vue js和传单创建交互式位置选择器

Interactive maps are good for displaying geographic information. But we can also use them to get location data from users. This comes in handy if we are building location-based applications and we want an alternative to address text fields.交互式地图非常适…

linux命令 ftp的使用

1. 连接ftp服务器 格式&#xff1a;ftp [hostname| ip-address] a)在linux命令行下输入&#xff1a;ftp 10.18.34.115 b)服务器询问你用户名和口令&#xff0c;待认证通过即可。 2. 下载文件 下载文件通常用get和mget这两条命令。 a) get 格式&#xff1a;get [remote-file] …

关于docker in docker的利用

首先判断是否为docker环境&#xff0c;是否存在docker.sock文件,以及判断docker命令是否能够使用 来打印主机信息 docker -H unix:///host/var/run/docker.sock info反弹shell的环境下无法进入容器终端&#xff0c;无法使用-it进入容器内部 启动一个新的容器&#xff0c;虚拟机…