准备工作
在搭建服务器前要保证linux上有网,能够ping通网址(可使用桥接模式)
关闭防火墙
查看防火墙当前状态:systemctl status firewalld
关闭防火墙:systemctl stop firewalld
永久关闭防火墙(开机不自启):systemctl disable firewalld
NFS服务器的搭建
安装:
yum install nfs-utils
设置 NFS 服务开机启动:
systemctl enable rpcbind
systemctl enable nfs
启动 NFS 服务:
systemctl start rpcbind
systemctl start nfs
服务启动之后,我们在服务端配置一个共享目录
mkdir -p /data/nfs
设置文件的权限
chmod -R 777 /data/nfs
根据这个目录,相应配置导出目录
vi /etc/exports
添加如下配置
/data/nfs/ 192.168.0.0/24(rw,sync,no_root_squash,no_all_squash,insecure)
/data/nfs/ :
共享目录位置。
192.168.0.0/24:
客户端 IP 范围,* 代表所有,即没有限制。
rw:
权限设置,可读可写。
sync:
同步共享目录。
no_root_squash:
可以使用 root 授权。
no_all_squash:
可以使用普通用户授权。
保存设置::wq
重启 NFS 服务:
systemctl restart nfs
可以检查一下本地的共享目录
showmount -e localhost