安装NFS包
$ yum install nfs-utils
启动nfs
$ systemctl start nfs
$ systemctl enable nfs
准备共享目录
$ mkdir /data/nfs-1
把目录添加到共享中
# cat /etc/exports
/data/nfs-1 *(rw,sync,insecure,no_subtree_check,no_root_squash)
生效配置:
$ exportfs -r
检查已有的共享目录:
$ showmount -e localhost
Export list for localhost:
/data/nfs-1 *
现在你可以使用nfs共享目录 /data/nfs-1了。
附:
如果客户端mount nfs出现:
Output: Running scope as unit run-11138.scope.
mount: wrong fs type, bad option, bad superblock on 10.2.2.120:/data/nfs-data,
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.
Warning FailedMount 6m18s kubelet, k8s-node2 MountVolume.SetUp failed for volume "nfs-client-root" : mount failed: exit status 32
请在客户端安装 :ubuntu: nfs-common,centos : nf-untils
yum install nfs-utils