1.检查是否有 NFS 和 RPC
rpm -qa nfs-utils bind-utils
2.安装NFS 和 RPC(两个都有就跳过)
yum -y install nfs-utils
yum -y install bind-utils
3.在server端配置共享目录在/etc/exports添加如下内容:
共享目录 客户端内网IP(rw,sync,no_root_squash)
vim /etc/exports
/nfs/code 10.0.*(rw,sync,no_root_squash)
或者
cat >>/etc/exports<<EOF
> /nfs/code 10.0.*(rw,sync,no_root_squash)
> EOF
4.在server端创建共享目录
mkdir -p /nfs/code
cd /nfs/code
touch xs.txt
5.运行nfs
systemctl restart nfs
systemctl enable nfs
6.客户端挂载server目录
mkdir -p /nfs/code
7.重启nfs
systemctl restart nfs
systemctl enable nfs
mount -t nfs server端内网ip:共享目录地址 客户端共享目录地址
如:mount -t nfs 172.16.0.13:/nfs/code /mnt/
8.查看共享目录下的文件
ls /nfs/code
若显示xs.txt则代表挂载成功