十:HDFS Short-Circuit Local Reads 短路本地读取

    当client请求数据时,datanode会读取数据然后通过TCP协议发送给client.short-circuit绕过了datanode直接读取数据。short-circuit的前提是client和数据在同一个结点上。
    short-circuit需要libhadoop.so,一个本地库。该功能使用unix套接字,client和node通过套接字连接,需要对这个套接字设置一个路径,并且datanode有创建这个路径的权限,一般建在/var/run或者/var/lib。client和datanode通过共享内在/dev/shm交换数据。
    client和datanode都要进行配置;

Example Configuration

Here is an example configuration.

<configuration>
  <property>
    <name>dfs.client.read.shortcircuit</name>
    <value>true</value>
  </property>
  <property>
    <name>dfs.domain.socket.path</name>
    <value>/var/lib/hadoop-hdfs/dn_socket</value>
  </property>
</configuration>

    

旧式的short-circuit本地读依然被支持,但是配置不一样,要注意其安全性:
<configuration>
  <property>
    <name>dfs.client.read.shortcircuit</name>
    <value>true</value>
  </property>
  <property>
    <name>dfs.client.use.legacy.blockreader.local</name>
    <value>true</value>
  </property>
  <property>
    <name>dfs.datanode.data.dir.perm</name>
    <value>750</value>
  </property>
  <property>
    <name>dfs.block.local-path-access.user</name>
    <value>foo,bar</value>
  </property>
</configuration>








原文地址:https://www.cnblogs.com/skyrim/p/7455604.html