HDFS NFS Gateway安装配置详解

来源:互联网 发布:报价管理系统 php 编辑:程序博客网 时间:2024/06/02 01:41

HDFS NFS Gateway安装配置详解

1.概述

HDFS NFS Gateway能够把HDFS挂载到客户机上作为本地文件系统来管理,支持NFSv3。当前版本的NFS Gateway有如下可用特性。

l  用户在支持NFSv3的操作系统上可以通过本地文件系统浏览HDFS。

l  使用NFS Gateway 用户能够直接下载和上传HDFS文件到本地文件系统中。

l  用户可以通过挂载点直接传输数据流至HDFS,但只能增量添加不能随机写数据。

2.开启NFS Gateway

NFS服务需要三个守护进程rpcbind或portmap(portmap在centos6上被改名为rpcbind), mountd and nfsd,NFS Gateway已经包含了nfsd和mountd。挂载时会把HDFS根目录作为唯一的挂载点。由于在RHEL6.2等操作系统上rpcbind有bug,推荐使用NFS Gateway软件包里自带的portmap.

开启nfs gateway步骤如下:

1)停止系统本身的nfs/rpcbind/portmap服务 

service nfs stop

service rpcbind stop 

2) 开启自带的portmap服务,需要root权限。 

hadoop portmap(默认会在前台一直运行,并输出运行信息)

hadoop-daemon.sh start portmap 

3)开启mountd和nfsd。此处不需要root权限,但是注意保证启动NFS Gateway用户和启动hadoop集群的用户是同一个。   

    hadoop nfs3 (默认会在前台一直运行,并输出运行信息)

   

    hadoop-daemon.shstart portmap 

关闭NFS Gateway方法如下: 

    hadoop-daemon.sh stop nfs3

hadoop-daemon.sh stop portmap

3.验证

1)执行以下命令验证是否服务已经开启。

rpcinfo  -p  $nfs_server_ip 

实例操作如下(在虚拟机100.2.12.142、144、146三台机器上安装了transwarp,在100.2.12.133上进行测试):



2)查看机器可被挂载的nfs目录:

       showmount-e $nfs_server_ip



3)查看已经挂载到机器的本地和远程用户列表


说明:100.2.2.45为windows7办公用机,可以挂载,但是当前打开挂载的目录出错,暂未能解决。

4.挂载HDFS根目录“/”

当前NFS v3只支持TCP传输同,由于不支持NLM协议,挂载时需要指定参数nolock,另外推荐使用hark link,英文说明如下:

 

 

 

连接命令如下:

mount -t nfs -o vers=3,proto=tcp,nolock$server:/  $mount_point

实际示例(挂载,并复制一文件至挂载点内文件夹,安装的transwarp的hdfs根目录没有写权限,选择已有文件夹内复制)


5.操作(复制文件和删除文件)

1)复制文件至挂载点



在142上查看hdfs


2)删除已复制的文件


在142上查看hdfs



6.配置建议

大部分情况下NFS Gateway使用默认配置即可工作,但是强烈建议根据使用情况做一些配置,这些配置都可以hdfs-site.xml中完成。

transwarp中配置文件所在如下:


原文关于配置说明如下:

  • If the client mounts the export with access time update allowed, make sure the following property is not disabled in the configuration file. Only NameNode needs to restart after this property is changed. On some Unix systems, the user can disable access time update by mounting the export with "noatime". If the export is mounted with "noatime", the user doesn't need to change the following property and thus no need to restart namenode.

<property>

 <name>dfs.namenode.accesstime.precision</name>

  <value>3600000</value>

  <description>The access time for HDFSfile is precise upto this value.

    The default value is 1 hour. Setting avalue of 0 disables

    access times for HDFS.

  </description>

</property>

  • Users are expected to update the file dump directory. NFS client often reorders writes. Sequential writes can arrive at the NFS gateway at random order. This directory is used to temporarily save out-of-order writes before writing to HDFS. For each file, the out-of-order writes are dumped after they are accumulated to exceed certain threshold (e.g., 1MB) in memory. One needs to make sure the directory has enough space. For example, if the application uploads 10 files with each having 100MB, it is recommended for this directory to have roughly 1GB space in case if a worst-case write reorder happens to every file. Only NFS gateway needs to restart after this property is updated.

     <property>   

            <name>dfs.nfs3.dump.dir</name>   

            <value>/tmp/.hdfs-nfs</value>

  </property>

  • By default, the export can be mounted by any client. To better control the access, users can update the following property. The value string contains machine name and access privilege, separated by whitespace characters. Machine name format can be single host, wildcards, and IPv4 networks.The access privilege uses rw or ro to specify readwrite or readonly access of the machines to exports. If the access privilege is not provided, the default is read-only. Entries are separated by ";". For example: "192.168.0.0/22 rw ; host*.example.com ; host1.test.org ro;". Only NFS gateway needs to restart after this property is updated.

<property>

       <name>dfs.nfs.exports.allowed.hosts</name>

       <value>*rw</value>

</property>

  • Customize log settings. To get NFS debug trace, users can edit the log4j.property file to add the following. Note, debug trace, especially for ONCRPC, can be very verbose.

To change logging level:

   log4j.logger.org.apache.hadoop.hdfs.nfs=DEBUG

To get more details of ONCRPC requests:

log4j.logger.org.apache.hadoop.oncrpc=DEBUG

以上内容参考文档:

http://hadoop.apache.org/docs/r2.3.0/hadoop-project-dist/hadoop-hdfs/HdfsNfsGateway.html

7 windows7挂载尝试(可挂载,未能正常打开)

windows7自带了一个NFS组件,可以挂载nfs系统,安装过程:控制面板——所有控制面板项——程序和功能——打开或关闭windows功能--勾选NFS服务,包括NFS客户端,nfs管理工具。

挂载:CMD 进入命令行

mount ip:/www/abc/z:

 

其它不支持直接连接NFS Server的windows,可以在系统上面安装SFU (Windows Services for UNIX),点开始–>点程序–>点Windows Services for UNIX–>Korn Shell

mount ip:/www/abc/z:

SFU下载地址:

Windows Servicesfor UNIX Version 3.5

http://www.microsoft.com/en-us/download/confirmation.aspx?id=274

 

也可以安装Utilities and SDK for Subsystem forUNIX-based Applications in Windows Vista, Windows Vista SP1, and Windows Server2008

地址:

http://www.microsoft.com/en-us/download/details.aspx?id=23754

或Utilities and SDK for Subsystem forUNIX-based Applications in Microsoft Windows 7 and Windows Server 2008 R2

http://www.microsoft.com/en-us/download/details.aspx?id=2391

 

以下是尝试过程:

使用windows7自带NFS组件,试着直接挂载,可以挂载上,但是访问出错,打不开挂载的文件夹,尝试了各种挂载参数设置都未成功。然后试着先把hdfs挂载到某台linux机器的一个文件夹上,然后把这个文件夹作为nfs再挂载到windows机器上,还是出错,提示该文件夹不支持nfs export,但是使用普通文件夹挂载到windows上面成功。

直接挂载后打不开挂载文件夹时portmap 和 hadoop nfs3监控的出错日志如下,在网上搜索了一下,没有搜到相关页面。

portmap

14/08/04 17:31:29WARN portmap.RpcProgramPortmap: Warning, no mapping for key: 100003 2 6

14/08/04 17:31:29WARN portmap.RpcProgramPortmap: Warning, no mapping for key: 100003 2 6

 

nfs3

14/08/04 17:31:29INFO mount.RpcProgramMountd: Path /desktop.ini is not shared.

14/08/04 17:31:29INFO mount.RpcProgramMountd: Path /desktop.ini is not shared

 

后来尝试使用sfu软件,但win7和windows server上都无法安装,再下载Utilities and SDK for Subsystem for UNIX-basedApplications in Microsoft Windows 7 and Windows Server 2008 R2,同样在win7和windows server上安装错误。

 

附:

Linux NFS服务器的安装与配置

http://www.cnblogs.com/mchina/archive/2013/01/03/2840040.html 


Windows下NFS客户端的安装及设置

http://codingstandards.iteye.com/blog/816441

 

NFS各个版本之间的比较

http://blog.csdn.net/ycnian/article/details/8515517

 

1 0
原创粉丝点击