#nfs
#安装 NFS 服务端
yum install -y nfs-utils
apt install -y nfs-kernel-server
# 这里的 * 可以替换为 IP,如 192.168.1.1/24
echo "/nfs/data/ *(insecure,rw,sync,no_root_squash)" > /etc/exports
# 执行以下命令启动 NFS 服务并创建共享目录
mkdir -p /nfs/data
systemctl enable rpcbind --now
systemctl enable nfs-server --now
# 使配置生效
exportfs -r
# 检查配置是否生效
exportfs#NFS 客户端连接
# 列出该 IP 下 NFS 的共享列表
showmount -e 192.168.70.12
mkdir -p /nfs/data
# 挂载
mount -t nfs 192.168.70.12:/nfs/data /nfs/data#开机自动挂载 NFS
vi /etc/fstab
192.168.70.12:/volume1/data /nfs/data nfs defaults 0 0