HDFS Short-Circuit Local Reads

来源:互联网 发布:2016年coc双王数据 编辑:程序博客网 时间:2024/06/05 17:23

HDFS中,读操作通常通过DataNode。因此,当一个客户端访问DataNode读一个文件的时候,DataNode从磁盘中读出该文件,然后通过TCK Socket发送到客户端。所谓的“short-circuit”是绕开DataNode,允许客户端直接读一个文件。明显地,当客户端与数据在同一地点时可能会出现这种情况。Short-circuit为很多应用提供了巨大的性能提升。

Configuration

为了配置short-circuit本地读,你将需要启用libhadoop.so。查看Native Libraries部分获取更多开启本地库的细节。

Short-circuit读利用了Unix的域套接字。这在文件系统中是一个特别的路径,这允许客户端和DataNode来通信。你将需要设置这个路径到这个Socket中。DataNode需要能够创建这个路径。另一方面,这个路径应该不可能被除了hdfs和root用户之外的任何用户创建。因为这个原因,经常使用中/var/run or /var/lib的子目录的路径。

Short-circuit本地读需要在DataNode和客户端都配置。

Example Configuration

这是一个配置的例子:

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. <configuration>  
  2.   <property>  
  3.    <name>dfs.client.read.shortcircuit</name>  
  4.     <value>true</value>  
  5.   </property>  
  6.   <property>  
  7.    <name>dfs.domain.socket.path</name>  
  8.    <value>/var/lib/hadoop-hdfs/dn_socket</value>  
  9.   </property>  
  10. </configuration>  

Configuration Keys

1.      dfs.client.read.shortcircuit

这个配置参数打开short-circuit本地读

2.      dfs.client.read.shortcircuit.skip.checksum

如果这个配置参数被设置,short-circuit本地读将会跳过checksum。这通常不推荐,但是对于一些特别的安装可能会有用。你可能需要在HDFS外做你自己的checksum。

3.      dfs.client.read.shortcircuit.streams.cache.size

DFSClient维护了一个最近打开文件的描述符的缓存。这个参数管理缓存的大小。设置高了将会使用更多的文件描述符,但是潜在地在查询发在方面提供更好的性能。

4.      dfs.client.read.shortcircuit.streams.cache.expiry.ms

这个参数控制文件描述符在文件因为inactive太长时间可以被关闭之前需要被放进FileInputStreamCache 的最小时间。

5.      dfs.client.domain.socket.data.traffic

这控制我们是否将尝试通过Unix域套接字传送正常的数据流量。

How Improved Short-Circuit Local Reads Bring Better Performance and Security to Hadoop


http://blog.cloudera.com/blog/2013/08/how-improved-short-circuit-local-reads-bring-better-performance-and-security-to-hadoop/


0 0
原创粉丝点击