AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 553645
Accepted
Rajalakshmi
Rajalakshmi
Asked: 2019-11-23 09:54:15 +0800 CST2019-11-23 09:54:15 +0800 CST 2019-11-23 09:54:15 +0800 CST

如何安装 nfslock 守护进程

  • 772

我想学习我在网上冲浪的 NFS 锁定机制。使用nfslockd或者 rpc.lockd我们可以做到。但是在 Debian 中没有包。任何人都请帮助我是否应该在Debian中做。

nfs lock
  • 3 3 个回答
  • 2648 Views

3 个回答

  • Voted
  1. Best Answer
    BowlOfRed
    2019-11-23T10:07:24+08:002019-11-23T10:07:24+08:00

    旧版本的 NFS (v2/v3) 可以在没有锁的情况下使用。为了支持锁定,在服务器上使用了一个单独的锁定守护进程,与 nfsd 并驾齐驱。

    对于 NFSv4(您已标记问题),锁定是协议的必需部分,并且单独的锁定守护程序不用于 v4 服务。

    如果你有一个 nfsv4 挂载,你应该能够锁定一个文件,就像你在本地文件系统上锁定一个文件一样。

    感谢您的评论我想将文件锁定在服务器本身,如果一个客户端使用文件,另一个客户端在第一个客户端发布之前不会访问。我想避免这种类型的竞争条件。

    Unix 使用咨询锁定,在客户端强制执行,而不是文件系统(这是 Windows 倾向于这样做的方式)。这意味着您的所有客户都需要参与锁定。

    如果您的客户在访问文件之前请求锁定,那么一切都会好起来的。只有在其他客户端释放锁之后,其他客户端才能获得锁。 fcntl本地和 NFS 文件系统通常都支持调用。

    查看Wikipedia 上的 UNIX 中的文件锁定了解一些背景知识。

    • 0
  2. nocool
    2019-11-23T10:39:39+08:002019-11-23T10:39:39+08:00

    NFS 锁是 NFS 进程的一部分。你不安装它。此外,这并不像你想的那样工作。如果你使用它,一个 MUTEX 锁将不会传递给所有服务器。我见过的唯一能做到这一点的软件是 VERITAS。

    • 0
  3. ron
    2019-11-23T10:58:23+08:002019-11-23T10:58:23+08:00

    我不能专门针对 debian 告诉您,但这是我/etc/sysconfig/nfs来自 SLES 11.4 的文件(我认为它使用的是 NFS v3)。

    #    # Path:        Network/File systems/NFS server
    #    # Description:     number of threads for kernel nfs server
    #    # Type:        integer
    #    # Default:     4
    #    # ServiceRestart:  nfsserver
    #
    # the kernel nfs-server supports multiple server threads
    #
    USE_KERNEL_NFSD_NUMBER="4"
    
    #    # Path:        Network/File systems/NFS server
    #    # Description:     use fixed port number for mountd
    #    # Type:        integer
    #    # Default:     ""
    #    # ServiceRestart:  nfsserver
    #
    #  Only set this if you want to start mountd on a fixed
    #  port instead of the port assigned by rpc. Only for use
    #  to export nfs-filesystems through firewalls.
    #
    MOUNTD_PORT=" xxx  "   set to port opened in firewall!
    
    #    # Path:                Network/File systems/NFS server
    #    # Description:         GSS security for NFS
    #    # Type:                yesno
    #    # Default:             yes
    #    # ServiceRestart:      nfs nfsserver
    #
    # Enable RPCSEC_GSS security for NFS (yes/no)
    #
    NFS_SECURITY_GSS="no"
    
    #    # Path:                Network/File systems/NFS server
    #    # Description:         NFSv4 protocol support
    #    # Type:                yesno
    #    # Default:             yes
    #    # ServiceRestart:      nfs nfsserver
    #
    # Enable NFSv4 support (yes/no)
    #
    NFS4_SUPPORT="no"
    
    #    # Path:                Network/File systems/NFS server
    #    # Description:         NFSv4 server minor version
    #    # Type:                integer
    #    # Default:             0
    #    # ServiceRestart:      nfsserver
    #
    # Select NFSv4 minor version for server to support (0, 1).
    # If '1' is selected, both NFSv4.0 and NFSv4.1 will be supported.
    NFS4_SERVER_MINOR_VERSION="0"
    
    #    # Path:                Network/File systems/NFS server
    #    # Description:         Network Status Monitor options
    #    # Type:                string
    #    # Default:             ""
    #
    # If a fixed port should be used to send reboot notification
    # messages to other systems, that port should be given
    # here as "-p portnumber".
    #
    SM_NOTIFY_OPTIONS="-p xxxxx"    set to port opened in firewall
    
    #    # Path:                Network/File systems/NFS server
    #    # Description:         Always start NFS services
    #    # Type:                yesno
    #    # Default:             no
    #    # ServiceRestart       nfs
    #
    # Always start NFS services (gssd, idmapd), not only if
    # there are nfs mounts in /etc/fstab.  This is likely to be
    # needed if you use an automounter for NFS.
    #
    NFS_START_SERVICES=""
    
    #    # Path:                Network/File systems/NFS server
    #    # Description:         Port rpc.statd should listen on
    #    # Type:                integer
    #    # Default:             ""
    #    # ServiceRestart:      nfsserver
    #
    # Statd will normally choose a random port to listen on and
    # SuSE-Firewall is able to detect which port and allow for it.
    # If you have another firewall, you may want to set a fixed
    # port number which can then be opened in that firewall.
    #
    STATD_PORT="xxxxx"     set to port opened in firewall
    
    #    # Path:                Network/File systems/NFS server
    #    # Description:         Hostname used by rpc.statd
    #    # Type:                string
    #    # Default:             ""
    #    # ServiceRestart:      nfsserver
    #
    # statd will normally use the system hostname in status
    # monitoring conversations with other hosts.  If a different
    # host name should be used, as can be useful with fail-over
    # configurations, that name should be given here.
    #
    STATD_HOSTNAME=""
    
    #    # Path:                Network/File systems/NFS server
    #    # Description:     TCP Port that lockd should listen on
    #    # Type:                integer
    #    # Default:             ""
    #    # ServiceRestart:      nfsserver
    #
    # Lockd will normally choose a random port to listen on and
    # SuSE-Firewall is able to detect which port and allow for it.
    # If you have another firewall, you may want to set a fixed
    # port number which can then be opened in that firewall.
    # lockd opens a UDP and a TCP port.  This setting only affect
    # the TCP port.
    #
    LOCKD_TCPPORT="xxxxx"    set to port opened in firewall
    
    #    # Path:                Network/File systems/NFS server
    #    # Description:     UDP Port that lockd should listen on
    #    # Type:                integer
    #    # Default:             ""
    #    # ServiceRestart:      nfsserver
    #
    # Lockd will normally choose a random port to listen on and
    # SuSE-Firewall is able to detect which port and allow for it.
    # If you have another firewall, you may want to set a fixed
    # port number which can then be opened in that firewall.
    # lockd opens a UDP and a TCP port.  This setting only affect
    # the UDP port.
    #
    LOCKD_UDPPORT="xxxxx"   set to port opened in firewall
    
    #    # Path:                Network/File systems/NFS server
    #    # Description:         Lease time for NFSv4 leases
    #    # Type:                integer
    #    # Default:             ""
    #
    # Set the lease time for the NFSv4 server.  This allows new locks
    # to be taken sooner after a server restart, so it is useful for
    # servers which need to recover quickly after a failure, particularly
    # in fail-over configurations.  Reducing the lease time can be a
    # problem is some clients connect over high latency networks.
    # The default is 90 seconds.  A number like 15 might be appropriate
    # in a fail-over configuration with all clients on well connected
    # low latency links.
    NFSV4LEASETIME=""
    
    #    # Path:                Network/File systems/NFS server
    #    # Description:         Alternate mount point for rpc_pipefs filesystem
    #    # Type:                string
    #    # Default:             ""
    #
    # In a high-availabilty configuration it is possible that /var/lib/nfs
    # is redirected so some shared storage and so it is not convenient to
    # mount the rpc_pipefs filesystem at /var/lib/nfs/rpc_pipefs.  In that
    # case an alternate mount point can be given here.
    RPC_PIPEFS_DIR=""
    
    #    # Path:                Network/File systems/NFS server
    #    # Description:         Options for svcgssd
    #    # Type:                string
    #    # Default:             ""
    #
    # Normally svcgssd does not require any option.  However in a
    # high-availabilty configuration it can be useful to pass "-n"
    # to guide the choice of default credential.  To allow for that
    # case or any other requiring options ot svcgssd, they can
    # be specified here.
    SVCGSSD_OPTIONS=""
    
    #    # Path:                Network/File systems/NFS server
    #    # Description:         Extra options for nfsd
    #    # Type:                string
    #    # Default:             ""
    #
    # This setting allows extra options to be specified for NFSD, such as
    # -H <shared_hostname> in a high-availability configuration.
    NFSD_OPTIONS=""
    
    #    # Path:                Network/File systems/NFS server
    #    # Description:         Extra options for gssd
    #    # Type:                string
    #    # Default:             ""
    #
    # Normally gssd does not require any options.  In some circumstances,
    # -n, -l or other options might be useful. See "man 8 rpc.gssd" for
    # details.  Those options can be set here.
    GSSD_OPTIONS=""
    
    #    # Path:                Network/File systems/NFS server
    #    # Description:         Extra options for mountd
    #    # Type:                string
    #    # Default:             ""
    #
    # Normally mountd does not require any options.  In some circumstances,
    # -n, -t, -g or other options might be useful. See "man 8 rpc.mountd" for
    # details.  Those options can be set here.
    # -p or -N should be set using MOUNTD_PORT or NFS4_SUPPORT rather than
    # this option.
    MOUNTD_OPTIONS=""
    
    #    # Path:                Network/File systems/NFS server
    #    # Description:         Avoid DNS lookups for kerberos principal
    #    # Type:                yesno
    #    # Default:             no
    #    # ServiceRestart:      gssd
    #
    # Avoid DNS lookups when determining kerberos identity
    # of NFS server (yes/no)
    # "yes" is safest, but "no" might be needed to preserve
    # correct behaviour at sites that don't use
    # Fully Qualified Domain Names when mounting NFS Shares.
    #
    NFS_GSSD_AVOID_DNS="no"
    

    “nfs 锁定守护程序”应该是安装的 nfs 包所固有的,并且应该可以正常工作。NFS 的一个依赖项是带有rpc.mountdandrpc.statd和的 RPC rpc.lockd。因此,如果 NFS 正确安装(以及它所需的依赖项,例如 RPC 和 Portmap),它应该可以工作,只要您关闭防火墙,或配置为lockd和mountd. 如果您不指定静态端口,则 NFS 将在每​​次启动时随机选择这些端口 [在引导期间]。使用防火墙[通常默认情况下],您将永远无法解释这些随机选择的端口号,这将阻止锁定机制每次都起作用。

    请注意,我的信息不适用于 NFSv4。

    • 0

相关问题

  • 如何模拟锁定文件?

  • 如何查询 sar(sysstat) 超过一天的数据点

  • 将 root 挂载为 overlayfs

  • systemd-networkd 启动后 nfs 启动挂起

  • 无法在 Alpine Linux LXC 上启动 NFS 服务器

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve