简介php
NFS:是Network FileSystem。最大的做用就是经过网络,让不一样的机器、不一样的做业系统、能够分享档案。
经过将共享目录挂接到本地,就能够像操做本地目录同样去操做共享的目录。
在共享中分为服务器和客户端,须要安装的程序也不同,客户端经过RPC的方式去请求服务端完成相应的操做。
能够想象成为windows的共享目录(权限是在server的/etc/exports中设置的)。html
(一、NFS示意图)linux
(二、RPC在NFS中的位置)ubuntu
服务端windows
安装nfs-server:
sudo apt-get install nfs-kernel-server服务器
配置网络
配置文件通常是在/etc/exports
添加:
/hadoop *(rw,sync,no_subtree_check)
/home/grid *(rw,sync,no_subtree_check)
固然也能够用指定的服务器名称(hostname)或IP代替*
配置完成须要重启nfs-server
重启命令:
sudo /etc/init.d/nfs-kernel-server restart
service nfs-kernel-server restartasync
export选项说明:ide
ro 该主机对该共享目录有只读权限oop
rw 该主机对该共享目录有读写权限
root_squash 客户机用root用户访问该共享文件夹时,将root用户映射成匿名用户
no_root_squash 客户机用root访问该共享文件夹时,不映射root用户
all_squash 客户机上的任何用户访问该共享目录时都映射成匿名用户anonuid 将客户机上的用户映射成指定的本地用户ID的用户
anongid 将客户机上的用户映射成属于指定的本地用户组ID
sync 资料同步写入到内存与硬盘中
async 资料会先暂存于内存中,而非直接写入硬盘insecure 容许从这台机器过来的非受权访问
客户端
(1)安装nfs-client:
sudo apt-get install nfs-common
(2)查看nfs server 上共享的目录
showmount -e 服务器IP
(3)建立共享挂载点,并执行挂载
sudo mkdir /home/grid/nfshadoop
sudo mount -t nfs serverip:/hadoop /home/grid/nfshadoop
(4)修改/etc/fstab文件,让系统在启动时能够自动挂载nfs server目录
serverip:/hadoop /home/grid/nfshadoop nfs defaults 0 0
(5)新建目录看看远程服务器上是否能够看到
touch tmp
进阶阅读
图片来源:http://linux.vbird.org/linux_server/0330nfs.php#ps1
鸟哥的私房菜:http://linux.vbird.org/linux_server/0330nfs.php#ps1
http://f.dataguru.cn/forum.php?mod=viewthread&tid=156968http://blog.csdn.net/ustc_dylan/article/details/8164080http://tech.seety.org/debian/NFSConf.html#id8http://www.92csz.com/study/linux/19.htmhttps://help.ubuntu.com/lts/serverguide/network-file-system.html