NFS  network file share   用于unixlinux文件共享

 

i_f38.gif最简单的搭建:

i_f42.gif说明

服务器端:查询、安装nfs,安装文件传输软件rpcbind;添加发布目录;新建共享目录(注意权限);关闭防火墙、SELinux;重启rpcbindnfs服务;设置自动启动

客户端:查找共享资源,挂载

i_f42.gif服务器端:

yum list |grep nfs         #查看nfs软件组成
yum –y install nfs-utils nfs-utils-lib nfs4-acl-tools #安装nfs
rpm –qa |grep nfs          #确认是否安装
rpm –qa rpcbind            #查看rpcbind是否安装
vim /etc/exports           #添加发布目录
/nfs/share     *(ro;sync)
mkdir /nfs/share –p        #新建共享目录(注意权限)
chown nfsnobody /nfs/share #更改共享目录属性
ll –d /nfs/share           #确认更改
touch /nfs/share/this_is_nfs_from_server #新建文件以方便显示共享
service rpcbind start      #启动rpcbind
service nfs start          #启动
chkconfig rpcbind on       #设置开机启动rpcbind
chkconfig nfs on           #设置开机启动nfs
iptables –F                #清空防火墙配置
iptables save              #保存防火墙配置
setenforce 0         #关闭SELinux

i_f42.gif客户端:

showmount -e 192.168.1.100    #查看特定IP的共享文件
mount.nfs 192.168.1.100:/nfs/share /mnt/ #临时挂载共享文件
ls /mnt/                     #查看挂载的共享文件,成功搭建!
this_is_nfs_from_server

i_f38.gif扩展1:不同IP不同的读写权限

vim /etc/exports#重新更改发布目录
/nfs/share  192.168.1.200(rw,sync)
/nfs/share  192.168.1.201(ro,sync)
exportfs –rv  #重新加载发布目录,也可以用重启命令
[root@client ~]# touch /mnt/a        #IP为192.168.1.200的可以创建文件
[root@client ~]# ls -l /mnt/a
-rw-r--r--. 1 nfsnobody nfsnobody 0 Mar  7 11:04 /mnt/a
 
[root@client mnt]# touch /mnt/a    #更改IP为192.168.1.201后不能创建文件
touch: cannot touch `a': Read-only file system

i_f34.gif扩展2:远程挂载家目录(未完等续)