NFS 服务器搭建
yum install nfs-utils -y
systemctl start nfs-server
ps aux|grep nfs
配置
vi /etc/exports
/web 192.168.0.0/16(rw,sync,no_wdelay,no_subtree_check,no_root_squash)
exportfs -rv
sudo chmod -R 777 /web
#/web 是我们共享的文件夹的路径--》使用绝对路径 --》需要自己新建
#192.168.0.0/24 允许过来访问的客户机的ip地址网段
#(rw,all_squash,sync) 表示权限的限制
# rw 表示可读可写 read and write
# ro 表示只能读 read-only
# all_squash :任何客户机上的用户过来访问的时候,都把它认为是普通的用户
# root_squash 当NFS客户端以root管理员访问时,映射为NFS服务器匿名用户
# no_root_squash 当NFS客户端以root管理员访问时,映射为NFS服务器的root管理员
# sync 同时将数据写入到内存与硬盘中,保证不丢失数据
# async 优先将数据保存到内存,然后再写入硬盘,效率更高,但可能丢失数据
挂载
yum install nfs-utils -y
#查看挂载目录
showmount -e ip
mount -t nfs ip:/web /web
# 自动挂载
vi /etc/fstab
ip:/vuser /vuser nfs auto 0 0
echo "/usr/bin/mount -a" >> /etc/rc.local