1. 安装nfs软件:
# yum install nfs-utils -y
2. 开放nfs服务:
在/etc/exports里写入类似的行
# echo "/data/nfs/volumes 10.18.0.0/24(rw,no_root_squash)" >> /etc/exports
3. 启动nfs服务:
# systemctl start nfs
# systemctl enable nfs
4. 服务验证:
# showmount -e
5. 如果有防火墙,需要开放端口(tcp 111, tcp 2049, udp 111, udp 4046):
# iptables -I INPUT -p tcp --dport 111 -j ACCEPT
# iptables -I INPUT -p tcp --dport 2049 -j ACCEPT
# iptables -I INPUT -p udp --dport 111 -j ACCEPT
# iptables -I INPUT -p udp --dport 4046 -j ACCEPT
6. 挂载验证:
假设nfs服务器的IP为10.18.0.10,挂到/mnt目录下
# mount -t nfs 10.18.0.10:/data/nfs/volumes /mnt