服务器
#!/bin/bash
#关闭防火墙
service iptables stop
#检查是否有安装nfs和rpc
nu=`rpm -qa|grep "rpcbind"|wc -l`
[ $nu -lt 1 ]&&yun install rpcbind -y
mu=`rpm -qa|grep "nfs-utils"|wc -l`
[ $mu -lt 1 ]&&yum install nfs-utils -y
#启动nfs和rpc服务
service rpcbind restart
chkconfig rpcbind on
service nfs restart
chkconfig nfs on
#创建挂载目录
mkdir -p /nfs/public
#修改目录的所有者和所属组和权限
chown -R nfsnobody:nfsnobody /nfs
chmod -R g+w /nfs
#修改/etc/exports 的配置文件
echo "/nfs/public 192.168.111.129 (rw,sync) ">/etc/exports
#让配置生效
exportfs -r
客户端
#!/bin/bash
#关闭防火墙
service iptables stop
#检查是否有安装nfs和rpc
nu=`rpm -qa|grep "rpcbind"|wc -l`
[ $nu -lt 1 ]&&yum install rpcbind -y
mu=`rpm -qa|grep "nfs-utils"|wc -l`
[ $mu -lt 1 ]&&yum install nfs-utils -y
#创建挂载目录
`mkdir -p /nfs/public`
#挂载
mount 192.168.111.168:/nfs/public /nfs/public