服务器端
第一步: 安装 nfs-utils
yum -y install nfs-utils
第二步: 创建一个共享目录
第三步: 写配置文件 (/etc/exports)
要写的内容及格式: 共享目录名 + 可以让那些主机共享
vim /etc/exports /webData 192.168.12.0/24(rw)
查看是否搭建成功
exportfs -v
第四步: 关闭 selinux 和 firewalld; 启动 nfs-serves
vim /etc/selinux/config/ 找到 SELINUX = 改为 SELINUX=disabled
- systemctl stop firewalld ; systemctl enable firewalld
- systemctl start nfs-server ; systemctl enable nfs-server
客户端
第一步: 安装 nfs-utils httpd/nginx
yum -y install nfs-utils httpd
第二步: 自动挂载共享目录
自动挂载配置文件要写的内容及格式
nfs 服务端的共享目录 要挂载到哪里 文件系统是啥类型 default 0 0
查看 uuid 的命令: blkid
- vim /etc/fstab
- 192.168.12.66:/webData /var/www/html/ nfs default 0 0
生效挂载
mount -a
查看挂载
df -h
第三步: 启动 nfs 服务 HTTP 服务; 关闭防火墙
systemctl start nfs-server ; systemctl restart httpd ; systecmctl stop firewalld ; systemctl enable firewalld
查看服务状态
systemctl status nfs-server
来源: http://www.bubuko.com/infodetail-2539892.html