注意说明:
NFS文件系统需要root权限启动服务(服务端口号无法设置1024以下)
传输协议 | 端口1 | 端口2 |
TCP | 111 | 2049 |
UDP | 111 | 4096 |
Centos7 防火墙关闭:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
systemctl list-unit-files|grep firewalld.service #防火墙处于状态
需要开启防火墙自行配置配置对应的端口。
NFS服务端部署
安装nfs服务需要的环境包
yum install nfs-utils rpcbind –y
编辑共享配置文件及ip访问限制
vim /etc/exports
/opt/test 192.168.1.101/32(rw,no_root_squash,all_squash,sync)
启动nfs相关服务
service rpcbind start
service nfs start
设置开机启动
chkconfig rpcbind on
chkconfig nfs on
配置文件修改,重新加载配置文件生效配置
exportfs -a
客户端配置
客户端安装环境
yum install nfs-utils –y
客户端测试
showmount -e 192.168.1.100
客户端配置挂载
/bin/mount -t nfs 192.168.1.100:/opt/test /test_data
客户端挂载脚本
cat /opt/shell/mount.sh
#!/bin/bash
list=`df -h |grep test |wc -l`
if [ $list -ne 1 ];then
/bin/mount -t nfs 192.168.1.100:/opt/test /test_data
fi
添加计划任务:
crontab -e
* * * * * /bin/sh /opt/shell/mount.sh > /dev/null 2>&1