nfsv4 相关;NFSv4文件锁

  • A+
所属分类:linux技术
摘要

本博客是和nfsv4相关文章:操作参考:https://help.ubuntu.com/community/NFSv4Howto关于NFS安装请参考:https://www.cnblogs.com/xuyaowen/p/NFS_install.html

本博客是和nfsv4相关文章:

操作参考:https://help.ubuntu.com/community/NFSv4Howto

关于NFS安装请参考:https://www.cnblogs.com/xuyaowen/p/NFS_install.html

NFSv4:https://linux.die.net/man/5/nfs 

NFSv4扩展阅读:

https://www.snia.org/sites/default/files/SNIA_An_Overview_of_NFSv4-3_0.pdf

https://www.netapp.com/us/media/tr-3580.pdf

https://www.netapp.com/us/media/tr-4067.pdf

本文章操作系统:

NAME="Ubuntu" VERSION="18.04.5 LTS (Bionic Beaver)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 18.04.5 LTS" VERSION_ID="18.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=bionic UBUNTU_CODENAME=bionic

apt show -a nfs-common:

➜  ~ apt show -a nfs-common Package: nfs-common Version: 1:1.3.4-2.1ubuntu5.3 Priority: optional Section: net Source: nfs-utils Origin: Ubuntu Maintainer: Ubuntu Developers <[email protected]> Original-Maintainer: Debian kernel team <[email protected]> Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 768 kB Provides: nfs-client Depends: libc6 (>= 2.15), libcap2 (>= 1:2.10), libcom-err2 (>= 1.01), libdevmapper1.02.1 (>= 2:1.02.97), libevent-2.1-6 (>= 2.1.8-stable), libgssapi-krb5-2 (>= 1.14+dfsg), libkeyutils1 (>= 1.5.9), libkrb5-3 (>= 1.6.dfsg.2), libmount1 (>= 2.19.1), libnfsidmap2, libtirpc1 (>= 0.2.4), libwrap0 (>= 7.6-4~), rpcbind, adduser, ucf, lsb-base (>= 1.3-9ubuntu3), keyutils Recommends: python3 Suggests: open-iscsi, watchdog Conflicts: nfs-client Breaks: nfs-kernel-server (<< 1:1.2.8-6~) Replaces: mount (<< 2.13~), nfs-client, nfs-kernel-server (<< 1:1.2.8-6~) Homepage: http://nfs.sourceforge.net/ Supported: 5y Download-Size: 206 kB APT-Manual-Installed: yes APT-Sources: http://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 Packages Description: NFS support files common to client and server  Use this package on any machine that uses NFS, either as client or  server.  Programs included: lockd, statd, showmount, nfsstat, gssd,  idmapd and mount.nfs.  Package: nfs-common Version: 1:1.3.4-2.1ubuntu5 Priority: optional Section: net Source: nfs-utils Origin: Ubuntu Maintainer: Ubuntu Developers <[email protected]> Original-Maintainer: Debian kernel team <[email protected]> Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 766 kB Provides: nfs-client Depends: libc6 (>= 2.15), libcap2 (>= 1:2.10), libcomerr2 (>= 1.01), libdevmapper1.02.1 (>= 2:1.02.97), libevent-2.1-6 (>= 2.1.8-stable), libgssapi-krb5-2 (>= 1.14+dfsg), libkeyutils1 (>= 1.5.9), libkrb5-3 (>= 1.6.dfsg.2), libmount1 (>= 2.19.1), libnfsidmap2, libtirpc1 (>= 0.2.4), libwrap0 (>= 7.6-4~), rpcbind, adduser, ucf, lsb-base (>= 1.3-9ubuntu3), keyutils Recommends: python3 Suggests: open-iscsi, watchdog Conflicts: nfs-client Breaks: nfs-kernel-server (<< 1:1.2.8-6~) Replaces: mount (<< 2.13~), nfs-client, nfs-kernel-server (<< 1:1.2.8-6~) Homepage: http://nfs.sourceforge.net/ Supported: 5y Download-Size: 205 kB APT-Sources: http://mirrors.aliyun.com/ubuntu bionic/main amd64 Packages Description: NFS support files common to client and server  Use this package on any machine that uses NFS, either as client or  server.  Programs included: lockd, statd, showmount, nfsstat, gssd,  idmapd and mount.nfs.

apt show -a nfs-kernel-server:

apt show -a nfs-kernel-server Package: nfs-kernel-server Version: 1:1.3.4-2.1ubuntu5.3 Priority: optional Section: net Source: nfs-utils Origin: Ubuntu Maintainer: Ubuntu Developers <[email protected]> Original-Maintainer: Debian kernel team <[email protected]> Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 345 kB Provides: knfs, nfs-server Depends: libblkid1 (>= 2.16), libc6 (>= 2.15), libcap2 (>= 1:2.10), libsqlite3-0 (>= 3.5.9), libtirpc1 (>= 0.2.4), libwrap0 (>= 7.6-4~), nfs-common (= 1:1.3.4-2.1ubuntu5.3), ucf, netbase, lsb-base (>= 1.3-9ubuntu3), keyutils Conflicts: knfs, nfs-server Replaces: knfs, nfs-server Homepage: http://nfs.sourceforge.net/ Supported: 5y Download-Size: 93.8 kB APT-Manual-Installed: yes APT-Sources: http://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 Packages Description: support for NFS kernel server  The NFS kernel server is currently the recommended NFS server for use  with Linux, featuring features such as NFSv3 and NFSv4, Kerberos  support via GSS, and much more. It is also significantly faster and  usually more reliable than the user-space NFS servers (from the  unfs3 and nfs-user-server packages). However, it is more difficult to  debug than the user-space servers, and has a slightly different  feature set.  .  This package contains the user-space support needed to use the  NFS kernel server. Most administrators wishing to set up an NFS server  would want to install this package.  Package: nfs-kernel-server Version: 1:1.3.4-2.1ubuntu5 Priority: optional Section: net Source: nfs-utils Origin: Ubuntu Maintainer: Ubuntu Developers <[email protected]> Original-Maintainer: Debian kernel team <[email protected]> Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 344 kB Provides: knfs, nfs-server Depends: libblkid1 (>= 2.16), libc6 (>= 2.15), libcap2 (>= 1:2.10), libsqlite3-0 (>= 3.5.9), libtirpc1 (>= 0.2.4), libwrap0 (>= 7.6-4~), nfs-common (= 1:1.3.4-2.1ubuntu5), ucf, netbase, lsb-base (>= 1.3-9ubuntu3), keyutils Conflicts: knfs, nfs-server Replaces: knfs, nfs-server Homepage: http://nfs.sourceforge.net/ Supported: 5y Download-Size: 94.0 kB APT-Sources: http://mirrors.aliyun.com/ubuntu bionic/main amd64 Packages Description: support for NFS kernel server  The NFS kernel server is currently the recommended NFS server for use  with Linux, featuring features such as NFSv3 and NFSv4, Kerberos  support via GSS, and much more. It is also significantly faster and  usually more reliable than the user-space NFS servers (from the  unfs3 and nfs-user-server packages). However, it is more difficult to  debug than the user-space servers, and has a slightly different  feature set.  .  This package contains the user-space support needed to use the  NFS kernel server. Most administrators wishing to set up an NFS server  would want to install this package.

 dpkg -L nfs-common:

/. /etc /etc/default /etc/default/nfs-common /etc/init.d /etc/init.d/nfs-common /etc/request-key.d /etc/request-key.d/id_resolver.conf /lib /lib/systemd /lib/systemd/system /lib/systemd/system/auth-rpcgss-module.service /lib/systemd/system/nfs-client.target /lib/systemd/system/nfs-config.service /lib/systemd/system/nfs-idmapd.service /lib/systemd/system/nfs-utils.service /lib/systemd/system/proc-fs-nfsd.mount /lib/systemd/system/rpc-gssd.service /lib/systemd/system/rpc-statd-notify.service /lib/systemd/system/rpc-statd.service /lib/systemd/system/rpc-svcgssd.service /lib/systemd/system/run-rpc_pipefs.mount /sbin /sbin/mount.nfs /sbin/osd_login /sbin/rpc.statd /sbin/showmount /sbin/sm-notify /usr /usr/lib /usr/lib/systemd /usr/lib/systemd/scripts /usr/lib/systemd/scripts/nfs-utils_env.sh /usr/sbin /usr/sbin/blkmapd /usr/sbin/mountstats /usr/sbin/nfsidmap /usr/sbin/nfsiostat /usr/sbin/nfsstat /usr/sbin/rpc.gssd /usr/sbin/rpc.idmapd /usr/sbin/rpc.svcgssd /usr/sbin/rpcdebug /usr/sbin/start-statd /usr/share /usr/share/bug /usr/share/bug/nfs-common /usr/share/bug/nfs-common/control /usr/share/bug/nfs-common/script /usr/share/bug/nfs-utils /usr/share/bug/nfs-utils/control /usr/share/bug/nfs-utils/presubj /usr/share/doc /usr/share/doc/nfs-common /usr/share/doc/nfs-common/README.Debian.nfsv4 /usr/share/doc/nfs-common/changelog.Debian.gz /usr/share/doc/nfs-common/copyright /usr/share/lintian /usr/share/lintian/overrides /usr/share/lintian/overrides/nfs-common /usr/share/man /usr/share/man/man5 /usr/share/man/man5/nfs.5.gz /usr/share/man/man5/nfsidmap.5.gz /usr/share/man/man5/nfsmount.conf.5.gz /usr/share/man/man8 /usr/share/man/man8/blkmapd.8.gz /usr/share/man/man8/gssd.8.gz /usr/share/man/man8/idmapd.8.gz /usr/share/man/man8/mount.nfs.8.gz /usr/share/man/man8/mountstats.8.gz /usr/share/man/man8/nfsiostat.8.gz /usr/share/man/man8/nfsstat.8.gz /usr/share/man/man8/rpcdebug.8.gz /usr/share/man/man8/showmount.8.gz /usr/share/man/man8/sm-notify.8.gz /usr/share/man/man8/statd.8.gz /usr/share/man/man8/svcgssd.8.gz /usr/share/man/man8/umount.nfs.8.gz /usr/share/nfs-common /usr/share/nfs-common/conffiles /usr/share/nfs-common/conffiles/idmapd.conf /usr/share/nfs-common/conffiles/nfs-common.default /var /var/lib /var/lib/nfs /var/lib/nfs/sm /var/lib/nfs/sm.bak /var/lib/nfs/state /lib/systemd/system/nfs-common.service /sbin/mount.nfs4 /sbin/umount.nfs /sbin/umount.nfs4 /usr/share/man/man8/rpc.gssd.8.gz /usr/share/man/man8/rpc.idmapd.8.gz /usr/share/man/man8/rpc.sm-notify.8.gz /usr/share/man/man8/rpc.statd.8.gz /usr/share/man/man8/rpc.svcgssd.8.gz

dpkg -L nfs-kernel-server:

/. /etc /etc/init.d /etc/init.d/nfs-kernel-server /lib /lib/systemd /lib/systemd/system /lib/systemd/system/nfs-blkmap.service /lib/systemd/system/nfs-mountd.service /lib/systemd/system/nfs-server.service /sbin /sbin/nfsdcltrack /usr /usr/sbin /usr/sbin/exportfs /usr/sbin/rpc.mountd /usr/sbin/rpc.nfsd /usr/share /usr/share/bug /usr/share/bug/nfs-kernel-server /usr/share/bug/nfs-kernel-server/script /usr/share/doc /usr/share/doc/nfs-kernel-server /usr/share/doc/nfs-kernel-server/NEWS.Debian.gz /usr/share/doc/nfs-kernel-server/copyright /usr/share/lintian /usr/share/lintian/overrides /usr/share/lintian/overrides/nfs-kernel-server /usr/share/man /usr/share/man/man5 /usr/share/man/man5/exports.5.gz /usr/share/man/man7 /usr/share/man/man7/nfsd.7.gz /usr/share/man/man8 /usr/share/man/man8/exportfs.8.gz /usr/share/man/man8/mountd.8.gz /usr/share/man/man8/nfsd.8.gz /usr/share/man/man8/nfsdcltrack.8.gz /usr/share/nfs-kernel-server /usr/share/nfs-kernel-server/conffiles /usr/share/nfs-kernel-server/conffiles/etc.exports /usr/share/nfs-kernel-server/conffiles/nfs-kernel-server.default /var /var/lib /var/lib/nfs /var/lib/nfs/etab /var/lib/nfs/rmtab /var/lib/nfs/v4recovery /var/lib/nfs/xtab /lib/systemd/system/nfs-kernel-server.service /usr/share/doc/nfs-kernel-server/changelog.Debian.gz /usr/share/man/man8/rpc.mountd.8.gz /usr/share/man/man8/rpc.nfsd.8.gz

 导出文件系统:

# /etc/exports: the access control list for filesystems which may be exported #        to NFS clients.  See exports(5). # # Example for NFSv2 and NFSv3: # /srv/homes       hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check) # # Example for NFSv4: # /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check) # /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check) # /home/yaowen/nfsv4 192.168.0.0/24(rw,nohide,insecure,no_subtree_check,no_root_squash,sync)

重启:

systemctl restart nfs-kernel-server.service systemctl restart nfs-idmapd.service

查看挂载:

showmount -e 192.168.0.125

mount -t nfs4 -o proto=tcp,port=2049 192.168.0.125:/home/yaowen/nfsv4 /mnt/nfs
mount -t nfs4 -o proto=tcp,port=2049,nfsvers=4.2 192.168.0.125:/home/yaowen/nfsv4 /mnt/nfs

192.168.0.125:/home/yaowen/nfsv4 nfs4      352G   16G  318G   5% /mnt/nfs

查看挂载命令说明: man mount.nfs / man mount.nfs4

Under  Linux  2.6.32  and later kernel versions, mount.nfs can mount all NFS file system versions.  Under earlier Linux kernel versions, mount.nfs4 must be used for mounting NFSv4 file systems while mount.nfs must be used for NFSv3 and v2.

NFS中文件锁:

The  Network  Lock  Manager protocol is a separate sideband protocol used to manage file locks in NFS version 2 and version 3.  To support lock recovery after a client or server reboot, a second sideband protocol -- known as the Network Status Manager protocol -- is also required.  In NFS version 4, file locking is sup‐ ported directly in the main NFS protocol, and the NLM and NSM sideband protocols are not used.

我最理想的nfsv4导出方式:

/home/yaowen/nfsv4 192.168.0.0/24(rw,insecure,sync,nohide,no_subtree_check,no_root_squash) To apply changes to this file, run exportfs -ra or restart the NFS server.

我最理想的nfsv4挂载方式:

mount -t nfs4 -o nfsvers=4.2,hard,retrans=5,rsize=1048576,wsize=1048576,ac,sharecache,proto=tcp,port=2049,lock,cto,local_lock=none 192.168.0.125:/home/yaowen/nfsv4 /mnt/nfs

尝试进行读写;保持更新;