NFS服务部署

NFS:Network File System,网络文件系统,主要用来实现网络文件共享。 


---------------------server

1、创建共享目录
[root@server /]# mkdir /home/TestNFS


2、创建文件
[root@server /]# cd /home/TestNFS/
[root@server TestNFS]# touch test.txt


3、修改exports,配置nsf提供的文件共享目录
[root@server home]# vim /etc/exports

[root@server home]# cat /etc/exports
/home/TestNFS/ 192.168.0.104(rw,async,no_root_squash)

[root@server home]# exportfs -rv
exporting 192.168.0.104:/home/TestNFS


---------------------client

1、查看NFS服务器是否允许本机链接对应的共享目录
[root@client1 /]# showmount -e 192.168.0.104
Export list for 192.168.0.104:
/home/TestNFS 192.168.0.104


2、创建本地挂载点
[root@client1 /]# cd /home/dana
[root@client1 home]# mkdir nfs
[root@client1 home]# ls
dana  nfs


3、挂载共享目录
[root@client1 home]# mount 192.168.0.104:/home/TestNFS nfs
mount.nfs: access denied by server while mounting 192.168.0.104:/home/TestNFS


报错:mount.nfs: access denied by server while mounting 192.168.0.104:/home/TestNFS

原因:NFS服务启动,所使用的端口要求小于1024,而当前虚拟机采用NAT的方式,其网络地址端口转换的时候,一般都是大于1024的,需要禁止secure选项,即添加insecure。

[root@server /]# cat /var/log/messages | grep mount
……
Jan 14 22:59:46 localhost rpc.mountd[13367]: refused mount request from 192.168.0.104 for /home/TestNFS (/home/TestNFS): illegal port 37636

处理方法:server端修改exports
[root@server /]# vim /etc/exports
[root@server /]# cat /etc/exports
/home/TestNFS/ 192.168.0.104(insecure,rw,async,no_root_squash)
[root@server /]# exportfs -rv
exporting 192.168.0.104:/home/TestNFS

4、重新挂载共享目录

[root@client1 home]# mount 192.168.0.104:/home/TestNFS nfs

root@client ~]# mount
……
nfsd on /proc/fs/nfsd type nfsd (rw)
192.168.0.104:/home/TestNFS on /home/nfs type nfs (rw,vers=4,addr=192.168.0.104,clientaddr=172.16.71.129)


5、查看文件
[root@client1 home]# cd nfs
[root@client1 nfs]# ls
test.txt



参考:http://blog.chinaunix.net/uid-20554957-id-3444786.html









你可能感兴趣的:(nfs,服务部署)