yum install -y nfs-utils systemctl start nfs & systemctl enable nfs vi /etc/exports 增加内容 /home/mnt/data 192.168.1.30/24(rw,sync) 重启 systemctl restart nfs & systemctl restart rpcbind客户端操作:
创建需要挂载nfs的目录(例如):
mkdir /home/attachments
添加挂载目录:
mount -t nfs 192.168.1.30:/home/mnt/question /home/attachments/
测试是否挂载成功:
客户端操作:
cd /home/attachments mkdir test
服务器端操作:
cd /home/mnt/question
ls查看能看到test文件夹证明挂载成功
如果挂载不成功的话请关闭nfs服务器的防火墙
firewall-cmd --state systemctl stop firewalld systemctl disable firewalld开机自启动nfs:
因为在centos7中/etc/rc.d/rc.local的权限被降低了,所以需要赋予其可执行权
chmod +x /etc/rc.d/rc.local
编写自启动脚本
红色所代表的ip是platform所在机器对应的ip
vim /usr/local/sbin/nfsboot.sh
往脚本填写一下内容:
#! /bin/bash ## This is nfs自启动 shell script. ## Writen by Luyouzhi 2020-04-03. date mount -t nfs 192.168.1.30:/home/mnt/question /home/attachments/ echo "nfs自启动 success!!"
赋予脚本可执行权限
chmod +x /usr/local/sbin/nfsboot.sh
打开/etc/rc.d/rc.local文件,在末尾增加如下内容
/usr/local/sbin/nfsboot.sh



