系统环境: rhel 6
在服务器端和客户端安装nfs服务,安装rpcbind支持nfs远程映射本地。
同时设置开机自启动。
[[email protected]server ~]# service iptables stop
[[email protected]server ~]# yum -y install nfs-utils rpcbind
[[email protected]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
[[email protected]server ~]# rpm -qa rpcbind
rpcbind-0.2.0-8.el6.i686
[[email protected]server ~]# chkconfig nfs on
[[email protected]server ~]# chkconfig rpcbind on
1、配置nfs共享
[[email protected] ~]# 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、启动rpcbind、nfs服务
[[email protected] ~]# service rpcbind start
Starting rpcbind: [ OK ]
[[email protected] ~]# service nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
3、服务端查看nfs共享信息
[[email protected] ~]# showmount -e
Export list for server.localdomain:
/wwwshare 192.168.80.11
4、客户端开启rpcbind、nfs服务,查看nfs共享信息
[[email protected] ~]# service rpcbind start
[[email protected] ~]# service nfs start
[[email protected] ~]# showmount -e 192.168.80.10
Export list for 192.168.80.10:
/wwwshare 192.168.80.11
5、客户端临时挂载nfs共享
[[email protected] ~]# mount 192.168.80.10:/wwwshare /var/www/html/
[[email protected] ~]# 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在服务器端可以看到已经同步过去了
[[email protected] html]# echo "index.html" > index.html
[[email protected] wwwshare]# ls
Index.html
6、客户端配置开机自动挂载
[[email protected] ~]# vi /etc/fstab
... ...
192.168.80.10:/wwwshare/var/www/htmlnfsdefaults,_netdev0 0