使用 autofs 挂载 NFS 挂载时,我遇到挂载延迟(10 秒到一分钟之间)。如何避免这种延迟,同时仍通过 DNS 解析服务器名称?
我在 Manjaro Linux 上使用自动挂载版本 5.1.6。我使用的是 NFS 版本 4.2。
服务器信息
服务器(主机名verin
)NFS 配置 /etc/exports:
/data 192.168.1.0/24(rw,sync,nohide,no_subtree_check)
客户信息
客户端 autofs 配置:
/etc/autofs/auto.master:
#
# Sample auto.master file
# This is a 'master' automounter map and it has the following format:
# mount-point [map-type[,format]:]map [options]
# For details of the format look at auto.master(5).
#
/misc /etc/autofs/auto.misc
#
# NOTE: mounts done from a hosts map will be mounted with the
# "nosuid" and "nodev" options unless the "suid" and "dev"
# options are explicitly given.
#
/net -hosts proto=tcp
#
# Include /etc/autofs/auto.master.d/*.autofs
# To add an extra map using this mechanism you will need to add
# two configuration items - one /etc/autofs/auto.master.d/extra.autofs file
# (using the same line format as the auto.master file)
# and a separate mount map (e.g. /etc/auto.extra or an auto.extra NIS map)
# that is referred to by the extra.autofs file.
#
+dir:/etc/autofs/auto.master.d
#
# If you have fedfs set up and the related binaries, either
# built as part of autofs or installed from another package,
# uncomment this line to use the fedfs program map to access
# your fedfs mounts.
#/nfs4 /usr/sbin/fedfs-map-nfs4 nobind
#
# Include central master map if it can be found using
# nsswitch sources.
#
# Note that if there are entries for /net or /misc (as
# above) in the included master map any keys that are the
# same will not be seen as the first read key seen takes
# precedence.
#
+auto.master
客户端详细输出
/net/verin/data
当我第一次尝试列出时,这是 automount 的输出:
$ sudo automount -f -v
Starting automounter version 5.1.6, master map auto.master
using kernel protocol version 5.05
mounted indirect on /misc with timeout 300, freq 75 seconds
mounted indirect on /net with timeout 300, freq 75 seconds
attempting to mount entry /net/verin
mounted offset on /net/verin/data with timeout 300, freq 75 seconds
mounted /net/verin
attempting to mount entry /net/verin/data
mounted /net/verin/data
打印该行后有很长的延迟attempting to mount entry /net/verin
。
客户端调试输出
使用调试输出时的输出:
$ sudo automount -f --debug
Starting automounter version 5.1.6, master map auto.master
using kernel protocol version 5.05
lookup_nss_read_master: reading master files auto.master
do_init: parse(sun): init gathered global options: (null)
lookup_read_master: lookup(file): read entry /misc
lookup_read_master: lookup(file): read entry /net
lookup_read_master: lookup(file): read entry +dir:/etc/autofs/auto.master.d
lookup_nss_read_master: reading master dir /etc/autofs/auto.master.d
lookup_read_master: lookup(dir): scandir: /etc/autofs/auto.master.d
lookup_read_master: lookup(file): read entry +auto.master
lookup_nss_read_master: reading master files auto.master
do_init: parse(sun): init gathered global options: (null)
master_do_mount: mounting /misc
automount_path_to_fifo: fifo name /run/autofs.fifo-misc
lookup_nss_read_map: reading map file /etc/autofs/auto.misc
do_init: parse(sun): init gathered global options: (null)
mounted indirect on /misc with timeout 300, freq 75 seconds
st_ready: st_ready(): state = 0 path /misc
master_do_mount: mounting /net
automount_path_to_fifo: fifo name /run/autofs.fifo-net
lookup_nss_read_map: reading map hosts proto=tcp
do_init: parse(sun): init gathered global options: proto=tcp
lookup_read_map: lookup(hosts): read hosts map
lookup_read_map: lookup(hosts): map not browsable, update existing host entries only
mounted indirect on /net with timeout 300, freq 75 seconds
st_ready: st_ready(): state = 0 path /net
handle_packet: type = 3
handle_packet_missing_indirect: token 93, name verin, request pid 383755
attempting to mount entry /net/verin
lookup_mount: lookup(hosts): verin -> (null)
get_exports: lookup(hosts): fetchng export list for verin
parse_mount: parse(sun): expanded entry: "/data" "verin:/data"
parse_mount: parse(sun): gathered options: proto=tcp
parse_mount: parse(sun): dequote(""/data"") -> /data
parse_mapent: parse(sun): gathered options: proto=tcp
parse_mapent: parse(sun): dequote(""verin:/data"") -> verin:/data
update_offset_entry: parse(sun): updated multi-mount offset /data -> -proto=tcp verin:/data
do_mount_autofs_offset: mount offset /net/verin/data at /net/verin
mount_autofs_offset: calling mount -t autofs -s -o fd=11,pgrp=383739,minproto=5,maxproto=5,offset automount /net/verin/data
mounted offset on /net/verin/data with timeout 300, freq 75 seconds
mount_autofs_offset: mounted trigger /net/verin/data at /net/verin/data
dev_ioctl_send_ready: token = 93
mounted /net/verin
handle_packet: type = 5
handle_packet_missing_direct: token 94, name /net/verin/data, request pid 383755
attempting to mount entry /net/verin/data
lookup_mount: lookup(hosts): /net/verin/data -> -proto=tcp verin:/data
parse_mount: parse(sun): expanded entry: -proto=tcp verin:/data
parse_mount: parse(sun): gathered options: proto=tcp
sun_mount: parse(sun): mounting root /net/verin/data, mountpoint /net/verin/data, what verin:/data, fstype nfs, options proto=tcp,nosuid,nodev,intr
mount(nfs): root=/net/verin/data name=/net/verin/data what=verin:/data, fstype=nfs, options=proto=tcp,nosuid,nodev,intr
mount(nfs): nfs options="proto=tcp,nosuid,nodev,intr", nobind=0, nosymlink=0, ro=0
get_nfs_info: called with host verin(192.168.1.2) proto 6 version 0x20
get_nfs_info: nfs v3 rpc ping time: 0.000210
get_nfs_info: host verin cost 209 weight 0
get_nfs_info: called with host verin(fd00::ba97:5aff:fe4e:d196) proto 6 version 0x20
get_nfs_info: nfs v3 rpc ping time: 0.000220
get_nfs_info: host verin cost 220 weight 0
prune_host_list: selected subset of hosts that support NFS3 over TCP
mount_mount: mount(nfs): calling mkdir_path /net/verin/data
mount(nfs): calling mount -t nfs -s -o proto=tcp,nosuid,nodev,intr verin:/data /net/verin/data
mount_mount: mount(nfs): mounted verin:/data on /net/verin/data
dev_ioctl_send_ready: token = 94
mounted /net/verin/data
这里的延迟是在线路之后get_exports: lookup(hosts): fetchng export list for verin
。
附加信息
我在故障排除中收集的一些附加信息:
名称 verin 通过 DNS 解析。两台计算机都在我的主域中。 DNS 可以快速解析其他命令。如果我将 verin 添加到我的/etc/hosts
文件中,延迟就会消失。
在延迟(使用 进行配置)之后,NFS 服务器才会输出日志rpcdebug -m nfsd -s all
。
据我所知,autofs 在解析 verin 时有所延迟,但其他一切(ping、ssh、drill 查找)在解析名称时似乎响应非常迅速。