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>