centos7中nfs文件系统的使用

需求:

file01:1.1.1.1(内网ip 172.20.103.212),file02:2.2.2.2(内网ip 172.20.103.211) 这两台机器的 /dev/mapper/myvg-mylv /data  这个盘都挂载到 video01 47.254.78.171, video02 47.254.83.81 这两台机器上

即将file01和file02的/data目录都挂载到video01和video02上

处理:
file01和file02安装
yum install -y exportfs nfs-utils

video01和video02安装
yum install -y nfs-utils

1.在file01和file02添加共享的文件夹和客户端可以访问的IP地址

[root@eus_filmora_file01:~]# vim /etc/exports
/data *(insecure,rw,no_root_squash,sync,anonuid=500,anongid=500)

# 查看共享文件夹

[root@eus_filmora_file01:/data]# exportfs -rv
exporting *:/data

  
# 重启file01的NFS服务  
systemctl restart nfs
  
2.目标机器video01和video02上创建挂载点并挂载

# 客户端video01和video02操作
mkdir /file01_nfs
mkdir /file02_nfs

# 挂载file01和file02
mount -t nfs 172.20.103.212:/data /file01_nfs -o proto=tcp -o nolock
mount -t nfs 172.20.103.211:/data /file02_nfs -o proto=tcp -o nolock

# 卸载nfs
[root@eus_filmora_video01:~]# umount 172.20.103.212:/data


列出nfs服务端共享的目录:
[root@eus_filmora_video01:/file02_nfs]# showmount -e 172.20.103.212
Export list for 172.20.103.212:
/data *

[root@eus_filmora_video01:/file02_nfs]# showmount -e 172.20.103.211
Export list for 172.20.103.211:
/data *

# 添加开机自动挂载
[root@eus_filmora_video01:~]# cat /etc/rc.local 
#!/bin/bash

mount -t nfs 172.20.103.212:/data /file01_nfs -o proto=tcp -o nolock
mount -t nfs 172.20.103.211:/data /file02_nfs -o proto=tcp -o nolock

报错:
mount: wrong fs type, bad option, bad superblock on 10.25.177.47:/opt/data07,
       missing codepage or helper program, or other error
       (for several filesystems (e.g. nfs, cifs) you might
       need a /sbin/mount.<type> helper program)


       In some cases useful info is found in syslog - try
       dmesg | tail or so.

解决:
yum install -y nfs-utils

报错:
mount.nfs: access denied by server while mounting 10.25.177.47:/data/voice 
解决:
nfs服务端
 vim /etc/sysconfig/nfs
修改如下:
RPCNFSDARGS="-N 2 -N 3"
        ----->启用
# Turn off v4 protocol support
RPCNFSDARGS="-N 4"     ---->启用
重启生效
systemctl restart nfs
原文地址:https://www.cnblogs.com/reblue520/p/9689587.html