服务端

1.安装软件包

  1. yum -y install rpcbind nfs-utils

2.设置共享目录

  1. vim /etc/exports 文件内容为空 需要自己手写 格式如下
  2. /root/public 192.168.1.0/24(rw或者ro) 网段
  3. /root/public 192.168.1.1/32(rw或者ro) IP地址
  4. /root/public *.(rw或者ro) 全部地址

3.建立共享目录

  1. #mkdir /root/public

4.启动nfs和rpcbind服务

  1. #systemctl restart nfs
  2. #systemctl restart rpcbind

客户端配置

1.安装nfs-utils软件包

  1. #showmount -e nfs服务器IP

2.并查看nfs服务器共享目录

  1. #showmount -e nfs服务器IP

3.建挂载点并挂载共享目录

  1. #mkdir /mnt/public
  2. #mount -o v3 192.168.1.2:/root/public /mnt/public

4.设置开机自动挂载

  1. #vim /etc/fstab 在文件的最下方添加下面内容
  2. 192.168.1.2:/root/public /mnt/public nfs defaults 0 0