RHEL7에서 nfs를 다시 마운트할 때 이상한 문제가 발견되었습니다.
nfs-server에는 2개의 디렉터리가 공유되어 있습니다.
# showmount -e
Export list for localhost.localdomain:
/file2 192.168.122.1
/file1 192.168.122.1
그런 다음 클라이언트에 설치합니다.
# sudo mount 192.168.122.100:/file2 /media
# sudo mount 192.168.122.100:/file1 /mnt/file1
# mount
192.168.122.100:/file1 on /mnt/file1 type nfs4 (rw,relatime,vers=4.0,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.122.1,local_lock=none,addr=192.168.122.100)
192.168.122.100:/file2 on /media type nfs4 (rw,relatime,vers=4.0,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.122.1,local_lock=none,addr=192.168.122.100)
그런 다음 그 중 하나를 ro에 다시 설치하려고했습니다.
# sudo mount -o ro,remount /mnt/file1/
이때 이상한 일이 일어나서 둘 다 RO로 변했습니다.
192.168.122.100:/file1 on /mnt/file1 type nfs4 (ro,relatime,vers=4.0,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.122.1,local_lock=none,addr=192.168.122.100)
192.168.122.100:/file2 on /media type nfs4 (ro,relatime,vers=4.0,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.122.1,local_lock=none,addr=192.168.122.100)
일부 패킷을 캡처했지만 다시 마운트할 때 패킷이 전송되지 않은 것으로 나타났습니다.
지금은 모르겠습니다. 누군가 나를 도와줄 수 있나요?
감사해요.
답변1
찾았어요.
이는 NFS가 기본적으로 공유 캐시를 사용하기 때문입니다. 또한보십시오 man nfs
:
sharecache / nosharecache
Determines how the client's data cache and attribute cache are shared when mounting the same export more than once concurrently. Using the same
cache reduces memory requirements on the client and presents identical file contents to applications when the same remote file is accessed via dif‐
ferent mount points.
If neither option is specified, or if the sharecache option is specified, then a single cache is used for all mount points that access the same
export. If the nosharecache option is specified, then that mount point gets a unique cache. Note that when data and attribute caches are shared,
the mount options from the first mount point take effect for subsequent concurrent mounts of the same export.
As of kernel 2.6.18, the behavior specified by nosharecache is legacy caching behavior. This is considered a data risk since multiple cached copies
of the same file on the same client can become out of sync following a local update of one of the copies.
매뉴얼 페이지에는 a single cache is used for all mount points that access the same export
.
그런 다음 옵션을 사용했는데 nosharecache
이제는 제대로 작동합니다.
192.168.122.100:/file1 on /mnt/file1 type nfs4 (ro,relatime,vers=4.0,rsize=131072,wsize=131072,namlen=255,hard,nosharecache,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.122.1,local_lock=none,addr=192.168.122.100)
192.168.122.100:/file2 on /mnt/file2 type nfs4 (rw,relatime,vers=4.0,rsize=131072,wsize=131072,namlen=255,hard,nosharecache,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.122.1,local_lock=none,addr=192.168.122.100