Server常用服务-NFS服务器
安装
yum -y install nfs-utils rpcbind
配置
-
配置文件在 /etc/exports
内容示例:
/opt/public 192.168.2.1(rw,sync,all_squash) ## 将/opt/public目录共享给192.168.2.1,模式为读写,立即同步,所有者为 nfsnobodyPS:将192.168.2.1换为 * 为共享给任何人
PS:NFS不支持用户账号密码认证,要控制连接只能使用 IP 控制
-
重启服务
systemctl enable rpcbind --now systemctl enable nfs-server --now -
测试
可使用
showmount -e测试nfs功能是否正常 -
挂载
PS:客户端需下载nfs软件包
yum -y install nfs-utils-
临时挂载
mount ip:路径 本地挂载路径需要以ROOT身份挂载mount 192.168.0.5:/opt/public /mnt
-
永久挂载
修/etc/fstab 文件 👉fstab
格式为:
192.168.0.5:/opt/public /mnt nfs defaults,_netdev 0 0
-