概览
NFS网关,允许将HDFS作为客户机本地文件系统的一部分挂载。用户可以做如下操作:
- 使用兼容NFSv3的客户端,像浏览本地文件一样浏览客户端
- 用户可以从HDFS下载文件到本地
- 用户可以从本地文件上传
- 通过挂载点将数据直传到HDFS,支持追加,不支持随机写。
NFS的主机需要可以访问HDFS。
配置
NFS网关使用代理用户访问数据。非安全模式下,代理用户是运行网关的用户。安全模式下,使用的是kerberos中keytab用户。
Namenode中需要配置
core-site.xml中配置
- NFS用户可以代理哪些用户
<property>
<name>hadoop.proxyuser.nfsserver.groups</name>
<value>root,users-group1,users-group2</value>
<description>
The 'nfsserver' user is allowed to proxy all members of the 'users-group1' and
'users-group2' groups. Note that in most cases you will need to include the
group "root" because the user "root" (which usually belonges to "root" group) will
generally be the user that initially executes the mount on the NFS client system.
Set this to '*' to allow nfsserver user to proxy any group.
</description>
- NFS用户可以代理哪些机器?
</property>
<property>
<name>hadoop.proxyuser.nfsserver.hosts</name>
<value>nfs-client-host1.com</value>
<description>
This is the host where the nfs gateway is running. Set this to '*' to allow
requests from any hosts to be proxied.
</description>
</property>
- 安全模式配置
hdfs-site.xml需要额外配置
<property>
<name>nfs.keytab.file</name>
<value>/etc/hadoop/conf/nfsserver.keytab</value> <!-- path to the nfs gateway keytab -->
</property>
<property>
<name>nfs.kerberos.principal</name>
<value>nfsserver/_HOST@YOUR-REALM.COM</value>
</property>
- 使用AIX NFS需要配置
<property>
<name>nfs.aix.compatibility.mode.enabled</name>
<value>true</value>
</property>
- NFS配置超级用户
超级用户和namenode启动用户一样的不进行权限检查,但是仍然遵循core-site里面的主机限制
<property>
<name>nfs.superuser</name>
<value>the_name_of_hdfs_superuser</value>
</property>
- 修改atime间隔
hdfs读取文件时,两次超过1小时才会去更新access time(更新需要和NN交互)。如果说系统禁用了accesstime,那么没必要设置当前值。
<property>
<name>dfs.namenode.accesstime.precision</name>
<value>3600000</value>
<description>The access time for HDFS file is precise upto this value.
The default value is 1 hour. Setting a value of 0 disables
access times for HDFS.
</description>
</property>
- NFS dump目录
NFS网络客户端可能无序写入多个文件,超过内存阈值之后会dump盘,需要有一个目录进行最坏情况下的排序。
<property>
<name>nfs.dump.dir</name>
<value>/tmp/.hdfs-nfs</value>
</property>
- NFSexport权限控制
控制什么用户可以具有什么样的访问NFS权限
<property>
<name>nfs.exports.allowed.hosts</name>
<value>* rw</value>
</property>
- NFS metrics信息
读写信息
<property>
<name>nfs.metrics.percentiles.intervals</name>
<value>100</value>
<description>Enable the latency histograms for read, write and
commit requests. The time unit is 100 seconds in this example.
</description>
</property>
- HDFS NFS挂载点
默认是根目录
<property>
<name>nfs.export.point</name>
<value>/</value>
</property>
启动和停止NFS
服务命令
bin/hdfs --daemon start nfs3
bin/hdfs --daemon start portmap
bin/hdfs --daemon stop nfs3
bin/hdfs --daemon stop portmap
需要安装工具
yum install nfs-utils-*
yum install rpcbind-*
挂载NFS
如果要增加传输效率,可以增加rsize/或者wsize
[root]>mount -t nfs -o vers=3,proto=tcp,nolock,noacl,sync $server:/ $mount_point