nfs挂载文件

1. 安装必备插件  以防centos7默认没有启动nfs服务

    yum -y install nfs-utils rpcbind

# 启动 rpcbind 和配置开机自启动
systemctl start rpcbind
systemctl enable rpcbind

# 启动 nfs 和配置开机自启动
systemctl start nfs
systemctl enable nfs
重启服务
service nfs restart
[root@master nfs]# ps -ef|grep nfs
root      5598     2  0 10:08 ?        00:00:00 [nfsd4_callbacks]
root      5604     2  0 10:08 ?        00:00:00 [nfsd]
root      5605     2  0 10:08 ?        00:00:00 [nfsd]
root      5606     2  0 10:08 ?        00:00:00 [nfsd]
root      5607     2  0 10:08 ?        00:00:00 [nfsd]
root      5608     2  0 10:08 ?        00:00:00 [nfsd]
root      5609     2  0 10:08 ?        00:00:00 [nfsd]
root      5610     2  0 10:08 ?        00:00:00 [nfsd]
root      5611     2  0 10:08 ?        00:00:00 [nfsd]
root      5766     2  0 10:09 ?        00:00:00 [nfsv4.1-svc]
root      7703 14805  0 10:15 pts/1    00:00:00 grep --color=auto nfs
root     26932     2  0 09:36 ?        00:00:00 [nfsiod]
root     26942     2  0 09:36 ?        00:00:00 [nfsv4.0-svc]

2. 设置共享目录  去掉密码校验insecure

    vim /etc/exports

  增加一行

   /mnt/nfs/ *(insecure,rw,async,no_root_squash)

  如果是挂载到另外一台服务器

   /mnt/nfs/ 172.19.68.10(insecure,rw,async,no_root_squash)

3. 重启直接用命令挂载

  创建目录

  mkdir /mnt/nfs

  sudo mount -t nfs 172.19.68.9:/mnt/nfs/ /mnt/nfs

查看挂载的目录

nfsstat -m

显示共享目录的情况

showmount -e

附录deployment.yaml内容

kubectl replace -f deployment.yaml

apiVersion: v1
kind: ServiceAccount
metadata:
  name: nfs-client-provisioner
---
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  name: nfs-client-provisioner
spec:
  replicas: 1
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: nfs-client-provisioner
    spec:
      serviceAccount: nfs-client-provisioner
      containers:
      - name: nfs-client-provisioner
        image: quay.io/external_storage/nfs-client-provisioner:latest
        volumeMounts:
        - name: nfs-client-root
          mountPath: /persistentvolumes
        env:
        - name: PROVISIONER_NAME
          value: fuseim.pri/ifs
        - name: NFS_SERVER
          value: 172.19.68.9
        - name: NFS_PATH
          value: /mnt/nfs
      volumes:
      - name: nfs-client-root
        nfs:
          server: 172.19.68.9
          path: /mnt/nfs

 这篇详细https://blog.csdn.net/qq_35992900/article/details/80446005

原文地址:https://www.cnblogs.com/mutong1228/p/10942100.html