跳转到主内容

什么是 .nfsxxxx 文件以及如何删除它们?

Views:
1,123
Visibility:
Public
Votes:
4
Category:
ontap-9
Specialty:
nas
Last Updated:

适用场景

NFS

问题解答

  • 如果 .nfsXXXXNFS客户端删除当前在客户端上打开的文件、则NFS客户端会创建具有类似命名约定的文件
  • 客户端将重命名 .nfsXXXX 不鼓励其他客户端/进程使用此文件的文件
  • 执行重命名的客户端应在客户端进程关闭文件后将其删除。如果客户端已执行dsiconnected、重新启动或终止了问题描述 删除的过程、则可能不会执行此删除
  • 这些文件不是由ONTAP 进程生成的、而是根据客户端请求创建的
  • 使用 .nfsxxxx 文件查找NFS客户端和进程可能非常耗时
  • 它需要检查每个NFS客户端上可能正在访问包含该文件的NFS共享的每个进程
  • 可以 lsof 使用等实用程序来确定使用 .nfsxxxx 该文件的过程
  • 要防止 .nfsXXXX 创建文件、请勿在文件打开时将其删除
  • 如果 .nfsxxxx 确定文件不再使用、则可以将其删除。如果删除操作导致生成新 .nfsxxxx 文件、则此NFS客户端上的进程将打开此文件
  • 创建和删除 .nfsxxxx 文件的演示:
  1. 在NFS客户端中、在挂载的NFS共享中创建一个文件、然后使用tail命令将其打开
    • 暂停使用 ctrl-z 新终端的过程或打开新终端以完成其余演示

      shell# echo test > foo
      shell# tail -f foo
      test
      ^Z
      [1]+ Stopped tail -f foo

       
  2. 删除此文件 foo 以使NFS客户端创建 .nfsxxxx 此文件

    shell# rm foo
    shell# ls -A
    .nfs5ACF

     
  3. 请注意、后续 rm 命令只会使NFS客户端重新重命名文件

    shell# rm .nfs5ACF
    shell# ls -A
    .nfs6ACF

     
  4. 使用lsof或fuser找到已打开文件的进程

    shell# lsof ./.nfs6ACF
    COMMAND   PID USER   FD   TYPE DEVICE  SIZE NODE NAME
    tail   25725 root   3r   REG   8,1 27603 6647 .nfs6ACF

    shell# fuser .nfs6ACF
    .nfs6ACF 25725o

  5. 最后、终止保持文件打开的进程、并观察 .nfsxxx 文件现在已被删除

    shell# kill 25725
    shell# ls -al
    total x
    drwxr-sr-x  2 root src   400 Mar 29 15:39 .
    drwxrwsr-x 36 root src   3336 Mar 21 09:37 ..

追加信息

是否可以从 ONTAP 确定客户端是否已打开文件取决于所使用的协议:

  • NFSv3 :通常不存在锁定,因为 NFSv3 为无状态。
  • NFSv4.0 或 4.1 :如果客户端已打开文件,nfsv4 则会 nfsv4.1 出现或锁定。

cluster2::> vserver locks show -vserver svm1 -volume unix -path /unix/.nfs000000000000006000000009
Vserver: svm1
Volume   Object Path         LIF      Protocol  Lock Type   Client
-------- ------------------------- ----------- --------- ----------- ----------
unix    /unix/.nfs000000000000006000000009
                  svm1_cifs_nfs_lif1
                        nfsv4    share-level 10.64.24.10
         Sharelock Mode: write-deny_none

  • 只有当文件存在 NFSv4 或 nfsv4.1 锁定时,才能确定客户端 IP 。
  • 如果不存在任何锁定,则没有命令可显示 NFSv3 客户端是否正在使用此文件。

注意:对于 9.8 之前的 ONTAP 版本,要获取 NFSv4 和 nfsv4.1 类型锁定的客户端 IP ,需要使用其他 diag 模式命令。

Please contact NetApp Technical Support or log into the NetApp Support Site to create a case. Reference this article for assistance with the solution. 

  • The solution requires Diagnostic-level recovery. 
  • The use of Diagnostic commands and recovery steps is potentially disruptive and should only be used with guidance from NetApp Support. 

 

NetApp provides no representations or warranties regarding the accuracy or reliability or serviceability of any information or recommendations provided in this publication or with respect to any results that may be obtained by the use of the information or observance of any recommendations provided herein. The information in this document is distributed AS IS and the use of this information or the implementation of any recommendations or techniques herein is a customer's responsibility and depends on the customer's ability to evaluate and integrate them into the customer's operational environment. This document and the information contained herein may be used solely in connection with the NetApp products discussed in this document.