NFS cache-cleaning command?

前端 未结 5 1737
刺人心
刺人心 2021-01-31 09:55

I have a trouble with NFS client-side attribute caching. I\'m using some servers, one is an NFS server and the others are NFS client servers.

All servers are Debian(lenn

相关标签:
5条回答
  • 2021-01-31 10:26

    Within a given process, calling opendir and closedir on the parent directory of a file invalidates the NFS cache. I used this while programming a job scheduler. Very, very helpful. Try it!

    This is the line number of the relevant code (showing the use in context): https://github.com/earonesty/grun/blob/master/grun#L820

    It was the only way I could fix the issue of job #1 completing and job #2, which needed some output files, firing off in a context where those files were visible,

    0 讨论(0)
  • 2021-01-31 10:30

    Depending on what you mean by "false-caching errors", running sync may get you what you need. This will flush all filesystem buffers.

    If needed, you can also clear out the VM caches in the kernel using /proc/sys/vm/drop_caches.

    # To free pagecache
    echo 1 > /proc/sys/vm/drop_caches
    
    # To free dentries and inodes
    echo 2 > /proc/sys/vm/drop_caches
    
    # To free pagecache, dentries and inodes
    echo 3 > /proc/sys/vm/drop_caches
    
    0 讨论(0)
  • 2021-01-31 10:32

    You're seeing the effects of NFS's attribute cache. See man nfs, and check out DATA AND METADATA COHERENCE.

    NFS by default caches attributes for a minimum of 30 seconds (acregmin and acdirmin) and a maximum of 60 seconds (acregmax and acdirmax). You can override all of these together with actimeo, or disable the attribute cache entirely with noac. With the noac mount option, the behaviour described by the OP goes away, but hits performance.

    lookupcache=positive is useful if you're just looking for the appearance of new files, but deletions will still go through the attribute cache.

    0 讨论(0)
  • 2021-01-31 10:36

    AFAIK, the sync and async options aren't the source of attribute caching. Async allows the server to delay saving data to server filesystem, e.g. it affects the write durability in case of NFS server failures, but if the NFS server is stable then async does not affect the NFS clients.

    There is a lookupcache=positive NFS mount option that might be used to prevent negative lookup caching, e.g. the NFS returning "No such file or directory" when the file actually exists on the server. See Directory entry caching in man nfs.

    0 讨论(0)
  • 2021-01-31 10:38

    clear /var/lib/nfs/rmtab file on nfs server.

    The below commands are used to clear memory related problems. and it is very dangerous too. soem times it will crash ur application hosted on the box

    # sync
    
    # To free pagecache
    echo 1 > /proc/sys/vm/drop_caches
    
    # To free dentries and inodes
    echo 2 > /proc/sys/vm/drop_caches
    
    # To free pagecache, dentries and inodes
    echo 3 > /proc/sys/vm/drop_caches
    
    0 讨论(0)
提交回复
热议问题