跳转到主内容

什么是 .nfsXXXX 文件,如何删除它们?

Views:
1,800
Visibility:
Public
Votes:
7
Category:
ontap-9
Specialty:
nas
Last Updated:

适用于

NFS

问题解答

  • 具有类似命名约定的文件 .nfsXXXX 由 NFS 客户端创建,当客户端删除当前在客户端上打开的文件时
  • 客户端将文件重命名为 .nfsXXXX ,以阻止其他客户端/进程使用该文件
  • 执行重命名的客户端应在文件被客户端进程关闭后将其删除如果客户端断开连接、重新启动或将发出删除命令的进程已终止,则可能不会发生此删除
  • 这些文件不是由 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 是无状态的。
    • 尝试删除文件时,出现错误 "Device or resource busy"
      Error:"[root@Linux 107.11x.1xx.53]# rm -rf File_01
      rm: cannot remove 'File_01/.nfs000000008e3901c6000000e6': Device or resource busy
    • NFSv4.0 或 4.1:如果客户端已打开文件,则将存在 nfsv4nfsv4.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 客户端是否正在使用该文件。
  • 使用 FlexGroups 管理客户端异步删除 ONTAP 目录的权限

:对于 9.8 之前的 ONTAP 版本,获取 nfsv4 和 nfsv4.1 类型锁的客户端 IP 需要额外的诊断模式命令。

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.