RedHat nfs文件挂载
环境:RedHat-7.0
一,挂载的服务器(192.168.1.196)1.关闭所有服务器的防火墙:systemctl stop firewalld
2.查看防火墙启动状态:systemctl status firewalld
3.启动rpcbind nfs(注意:一定要先启动rpcbind再启动nfs)
a)启动:systemctl start rpcbind nfs
b)或者先启动rpcbind:systemctl start rpcbind
c)在启动nfs:systemctl start nfs
4.查看启动状态:systemctl is-active rpcbind nfs
5.给需要挂载的文件授权
a)编辑:vi /etc/exports
b)添加:目录ip(权限)例:/root/software/nfs 192.168.1.197(被挂载的ip)(rw)(注意:两台服务器必须要有/root/software/nfs目录,否则会导致nfs启动败)
c) 保存退出
6.修改
a) 编辑:vi /etc/sysconfig/nfs
b) RPCNFSDARGS="-N 4"(注明:在" "中加入-N 4)
c) 保存退出
7.重启:systemctl restart rpcbind nfs
二,被挂载的服务器(192.168.1.197)
1.在需要被挂载的服务器操作(192.168.1.197)
a) mount ip(挂载的ip):/目录/本地目录 例:mount 192.168.1.196:/root/software/nfs/ /root/software/nfs/
b) 查看是否成功:df -h
2.测试:在挂载(196)或被挂载(197)的服务器上新建一个文件,看另一台服务器上是否也创建,删除,添加,修改也是一样
注意:如果在被挂载的服务器(197)上新建文件会提示权限不够这时需要在挂载的服务器(196)上将被挂载的文件夹赋权限
a)在挂载的服务器上创建一个文件a.txt
b)查看另一台服务器,下图表示成功