一,服务端---------------------------------------------------
1.在被挂载的机器(真正存放文件的目录)安装nfs组件
yum install nfs-utils
2.配置共享目录
vi /etc/exports
加入:
/home/important-data/V11_215_vcentos-code 192.168.0.215(rw,no_root_squash,sync)
3.启动rpc服务
service rpcbind start
4.启动nfs服务
service nfs start
5.查看本机共享目录
showmount -e localhost
6.开机启动:
chkconfig rpcbind on
chkconfig nfs on
7.修改端口:
vi /etc/sysconfig/nfs
在最后添加如下内容:
RQUOTAD_PORT=30001
LOCKD_TCPPORT=30002
LOCKD_UDPPORT=30002
MOUNTD_PORT=30003
STATD_PORT=30004
然后重启:
service rpcbind restart
service nfs restart
7.修改防火墙:
-A INPUT -p tcp -m state --state NEW -m tcp --dport 111 -j ACCEPT
-A INPUT -p udp -m state --state NEW -m udp --dport 111 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 2049 -j ACCEPT
-A INPUT -p udp -m state --state NEW -m udp --dport 2049 -j ACCEPT
-A INPUT -p udp -m state --state NEW -m udp --dport 30001:30004 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 30001:30004 -j ACCEPT
二,客户端---------------------------------------------------
1.安装nfs组件
yum install nfs-utils
2.启动rpc服务
service rpcbind start
3.启动nfs服务
service nfs start
4.查看指定IP的共享目录
showmount -e 192.168.0.10
5.在home下创建目录:
mkdir -p /home/V11_215_vcentos-code
然后执行挂载命令:
mount -t nfs 192.168.0.10:/home/important-data/V11_215_vcentos-code /home/V11_215_vcentos-code -o proto=tcp -o nolock
通过以下命令可以看到
df -h
解除挂载:
umount /home/V11_215_vcentos-code/