NFS是我们经常要用到的服务,用于linux系统之间文档目录的共享。其实NFS配置是很简单的,同样我也用简单的方字来记录说明一下NFS的配置要点。

1)服务端配置文件: /etc/exports
文件格式: Directory hostname (options)
Directory 为要共享的目录;
hostname 客户机的域名/IP地址/IP地址段;也可以为空,空则代表任意主机;
options 可选,如不指定,则采用默认选项。如ro,rw,sync,async等;
如:

  • /home 192.168.1.* (rw,async,no_root_squash)


Rw;可读可写
Async;同步,服务端只有接受到客户端的回应,才进行下一步,以确保连接更可靠
No_root_squash;不压缩root用户的权限,如要更安全请用roo_squash

在服务端可以用exportfs命令来输出exports对外共享的目录;

2)确保启动portmap和NFS

  • # /etc/rc.d/init.d/portmap start (or: # /service portmap start )  
  • # /etc/rc.d/init.d/nfs start (or: # /serverice nfs start)



注:可用netstat –untlp,来查看portmap和nfs服务是否启动,2049端口就是NFS服务器,111端口对应的就是portmap服务,可以发现在TCP和UDP上都有对应的端口;
3) NFS客户端配置(mount或fstab文件)

  • # mount –t nfs hostname(orIP):/directory /mountpoint


-t nfs可以省略;
/directory为绝对路径;

或是在/etc/fstab文件中增加NFS文件系统的挂载记录

  • NFSserverIP:/directory /mountpoint nfs defaults 0 0  



可以用mount查一下挂载点的情况。

 posted on 2011-01-14 13:44  海听途说  阅读(2125)  评论(0编辑  收藏  举报