一、安装NFS

1、首先安装NFS套件,命令如下:

yum install nfs-utils*(64位系统)

yum install nfs-utils*(32位系统)

2、安装后检测

rpm -qa | grep nfs-utils

[CentOS5]

nfs-utils-版本.el5
nfs-utils-lib-版本.el5

[CentOS6]

nfs-utils-版本.el6
nfs-utils-lib-版本.el6

3、然后安装portmap服务,portmap在centos6中改名为rpcbind

yum install rpcbind(centos6)

yum install portmap(centos5)

二、NFS服务端配置

1、/etc/service 增加端口

nfs             2049/tcp        nfsd
nfs             2049/udp        nfsd
#[CentOS5]

sunrpc          111/tcp         portmapper      # RPC 4.0 portmapper TCP
sunrpc          111/udp         portmapper      # RPC 4.0 portmapper UDP

#[CentOS6]

sunrpc          111/tcp         rpcbind     
sunrpc          111/udp         rpcbind    

2、/etc/exports配置挂接点和权限

/opt/centos6 192.168.0.0/24(ro,no_root_squash)

#/opt/centos6是挂接点

#192.168.0.0/24 这个网段的服务器可以接受挂接nfs文件系统

#ro只读

#no_root_squash 当访问者为root用户时方位该目录具有root权限

三 启动NFS服务

1、读取/etc/exports 文件

exportfs -a

2、启动进程

[CentOS5]

/etc/init.d/portmap start

/etc/init.d/nfs start

chkconfig portmap on

chkconfig nfs on

[CentOS6]

/etc/init.d/rpcbind start

/etc/init.d/nfs start

chkconfig rpcbind on

chkconfig nfs on

3、查看进程和服务

netstat -nulpt |grep -E "111|2049"

看端口和服务是否启动

rpcinfo -p

看nfs  mountd portmapper
 

 

四客户端访问NFS文件系统

 

1、查找NFS服务是否可用

showmount -e NFS-IP

如果看到了可以NFS服务器端相关消息,就可以使用nfs服务了

2、挂载

mount -t nfs NFS-IP:/opt/centos6 /mnt

[注意:如何解决报错信息]

If you got error such as this:

mount.nfs: rpc.statd is not running but is required for remote locking.
mount.nfs: Either use '-o nolock' to keep locks local, or start statd.
mount.nfs: an incorrect mount option was specified

To fix this, you need to do:

rpc.statd

rpc.mountd

rpcinfo -p