系统环境: rhel 6 

在服务器端和客户端安装nfs服务,安装rpcbind支持nfs远程映射本地。

同时设置开机自启动。

[root@server ~]# service iptables stop 

[root@server ~]# yum -y install nfs-utils rpcbind 

[root@server ~]# rpm -qa nfs*

nfs4-acl-tools-0.3.3-5.el6.i686

nfs-utils-1.2.3-7.el6.i686

nfs-utils-lib-1.1.5-3.el6.i686

[root@server ~]# rpm -qa rpcbind

rpcbind-0.2.0-8.el6.i686

[root@server ~]# chkconfig nfs on 

[root@server ~]# chkconfig rpcbind on 

 

1、配置nfs共享

[root@server ~]# vi /etc/exports 

/wwwshare       192.168.80.11(rw,sync,no_root_squash)

#目录   客户端ip/ip(权限)

#       rw:读取,写入

#       sync:同步写入

#       no_root_squash:客户端以root身份访问时,赋予本地root权限默认是no_squash,表示以nfsnobody降权对待.

 

2、启动rpcbindnfs服务

[root@server ~]# service rpcbind start 

Starting rpcbind:                                          [  OK  ]

[root@server ~]# service nfs start 

Starting NFS services:                                      [  OK  ]

Starting NFS quotas:                                       [  OK  ]

Starting NFS daemon:                                      [  OK  ]

Starting NFS mountd:                                      [  OK  ]

3、服务端查看nfs共享信息

[root@server ~]# showmount -e 

Export list for server.localdomain:

/wwwshare 192.168.80.11

4、客户端开启rpcbindnfs服务,查看nfs共享信息

[root@client ~]# service rpcbind start 

[root@client ~]# service nfs start 

[root@client ~]# showmount  -e 192.168.80.10

Export list for 192.168.80.10:

/wwwshare 192.168.80.11

5、客户端临时挂载nfs共享

[root@client ~]# mount 192.168.80.10:/wwwshare /var/www/html/

[root@client ~]# tail -1 /etc/mtab 

192.168.80.10:/wwwshare /var/www/html nfs rw,vers=4,addr=192.168.80.10,clientaddr=192.168.80.11 0 0

在客户端本地创建index.html在服务器端可以看到已经同步过去了

[root@client html]# echo "index.html" >  index.html 

[root@server wwwshare]# ls

Index.html

6、客户端配置开机自动挂载

[root@client ~]# vi /etc/fstab 

... ...

192.168.80.10:/wwwshare/var/www/htmlnfsdefaults,_netdev0 0