LINUX nfs server配置


LINUX nfs server配置
 
1.配置nfs
1.1#rpm -qa |grep nfs (查询系统中是否安装有nfs包)
2.2 # vi /etc/exports    (编译nfs服务的配置文件,我要把我的/data目录共享出来,允许所有网段的用户可以访问)
/rhome/nfs1     *(rw,async)
2.3.#exportfs –rv(这个命令可以验证我们设置的配置文件是    否正确,如果是下面的输出,就说明是正确的)
[root@station83 ~]# exportfs -rv
exporting *:/rhome/nfs1
或showmount -e localhost
[root@station83 ~]# showmount -e localhost
Export list for localhost:
/rhome/nfs1   *
2.4 # chkconfig --list |grep nfs (这个命令是查看nfs服务在哪几种启动级别会自动启动)
nfs             0:off   1:off   2:off   3:off   4:off   5:off   6:off
nfslock         0:off   1:off   2:off   3:on    4:on    5:on    6:off
[root@station38 ~]# chkconfig nfs on (为了让nfs服务在2345这几个启动级别都启动,我执行了这个命令)
[root@station38 ~]# chkconfig --list |grep nfs (现在去查看一下)
nfs             0:off   1:off   2:on    3:on    4:on    5:on    6:off
2.5 [root@station38 ~]# service nfs restart    (现在我们就可以启动这个服务的,让我们的配置文件生效)
 
安全:配合/etc/hosts.allow与hosts.deny 固定IP访问
 
2.6 客户端测试
[root@station73 other]#  showmount -e 192.168.0.83
Export list for 192.168.0.83:
/rhome/nfs1   *
3.配置autofs
用autofs实现挂载192.168.0.83:/rhome/nfs1 到本机。
3.1 vim /etc/auto.master
#
/misc   /etc/auto.misc
/nfs    /etc/auto.home
/rhome  /etc/auto.misc
/home   /etc/auto.misc
#
# vi /etc/auto.misc
cd              -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom下增加这行
nfs1            192.168.0.83:/rhome/nfs1
3.2 #service autofs restart  重新启动autofs服务
3.3 以nfs1在客户端登录
ssh nfs1@192.168.0.73
成功后[nfs1@station73 ~]$
---------------------------------------------------------------------------
 
1.服务端和客户端都需要开启portmap服务。RCP是nfs mount和umount时通信的方式。
2.假如客户端portmap没有启动,mount时,会非常慢,最终会失败。umount时,即使本地的portmap是关闭的,也能umount成功。 
3.挂载完成后,服务端的portmap停止后,nfs仍然工作正常,但是umout财会提示: not found / mounted or server not reachable。重启服务器的portmap也无济于事。
4.假如服务端的portmap重启了,那么nfs也要跟着重启,否则nfs工作仍然是不正常的。
5.假如服务端nfs关闭(IP是通的),这时客户端会无法umount,这时使用umount -f /nfs一般能成功,当服务端死机时,umount -f /nfs 有可能会失败,这时可以使用 umount -l /nfs .
 
最终建议:
1.使用NFS,就要使用portmap,NFS严重依赖于portmap,所以不要试图去停止它(portmap)。
2.当不能umount /nfs 分区时,试着使用umount -f /nfs,一般都能成功。
3.当umount -f /nfs不能umount时,可以试试umount -l /nfs. umount -l是最终级的umount。
 

相关内容

    暂无相关文章