在 Centos 7 上自动挂载 NFS 共享时出现问题

在 Centos 7 上自动挂载 NFS 共享时出现问题

我全新安装了 Centos 7。我似乎无法自动挂载位于192.168.254.105:/srv/nfsshareCentos 客户端的 NFS 共享。

然而,手动安装共享却运行良好。

自动主机管理工具已被完全注释掉以简化问题,除以下行外:

/-       /etc/auto.nfsshare 

/etc/auto.nfs共享 包含以下行:

/tests/nfsshare       -fstype=nfs,credentials=/etc/credentials.txt    192.168.254.105:/srv/nfsshare

/etc/credentials.txt持有:

 user=user
 password=password

预期的行为是,当我ls -l /tests/nfsshare,我将看到我的文件服务器的几个文件/srv/nfs共享目录保存。

但事实并非如此。相反,它什么也没显示。

来自的日志sudo journalctl --unit=autofs.service启动时显示以下内容(启用调试):

 Nov 20 00:25:38 localhost.localdomain systemd[1]: Starting Automounts filesystems on demand...
 Nov 20 00:25:38 localhost.localdomain automount[21204]: Starting automounter version 5.0.7-48.el7, master map auto.master
 Nov 20 00:25:38 localhost.localdomain automount[21204]: using kernel protocol version 5.02
 Nov 20 00:25:38 localhost.localdomain automount[21204]: lookup_nss_read_master: reading master files auto.master
 Nov 20 00:25:38 localhost.localdomain automount[21204]: parse_init: parse(sun): init gathered global options: (null)
 Nov 20 00:25:38 localhost.localdomain automount[21204]: spawn_mount: mtab link detected, passing -n to mount
 Nov 20 00:25:38 localhost.localdomain automount[21204]: spawn_umount: mtab link detected, passing -n to mount
 Nov 20 00:25:38 localhost.localdomain automount[21204]: lookup_read_master: lookup(file): read entry /-
 Nov 20 00:25:38 localhost.localdomain automount[21204]: master_do_mount: mounting /-
 Nov 20 00:25:38 localhost.localdomain automount[21204]: automount_path_to_fifo: fifo name /run/autofs.fifo--
 Nov 20 00:25:38 localhost.localdomain automount[21204]: lookup_nss_read_map: reading map file /etc/auto.nfsshare
 Nov 20 00:25:38 localhost.localdomain automount[21204]: parse_init: parse(sun): init gathered global options: (null)
 Nov 20 00:25:38 localhost.localdomain automount[21204]: spawn_mount: mtab link detected, passing -n to mount
 Nov 20 00:25:38 localhost.localdomain automount[21204]: spawn_umount: mtab link detected, passing -n to mount
 Nov 20 00:25:38 localhost.localdomain automount[21204]: mounted direct on /tests/nfsshare with timeout 300, freq 75 seconds
 Nov 20 00:25:38 localhost.localdomain automount[21204]: do_mount_autofs_direct: mounted trigger /tests/nfsshare
 Nov 20 00:25:38 localhost.localdomain automount[21204]: st_ready: st_ready(): state = 0 path /-
 Nov 20 00:25:38 localhost.localdomain systemd[1]: Started Automounts filesystems on demand.

当我尝试通过以下方式强制安装 nfs 共享时,我的日志中会出现以下内容ls -l /测试/nfs共享

 Nov 20 00:48:05 localhost.localdomain automount[22030]: handle_packet: type = 5
 Nov 20 00:48:05 localhost.localdomain automount[22030]: handle_packet_missing_direct: token 21, name /tests/nfsshare, request pid 22057
 Nov 20 00:48:05 localhost.localdomain automount[22030]: attempting to mount entry /tests/nfsshare
 Nov 20 00:48:05 localhost.localdomain automount[22030]: lookup_mount: lookup(file): looking up /tests/nfsshare
 Nov 20 00:48:05 localhost.localdomain automount[22030]: lookup_mount: lookup(file): /tests/nfsshare -> -fstype=nfs,credentials=/etc/credenti...fsshare
 Nov 20 00:48:05 localhost.localdomain automount[22030]: parse_mount: parse(sun): expanded entry: -fstype=nfs,credentials=/etc/credentials.tx...fsshare
 Nov 20 00:48:05 localhost.localdomain automount[22030]: parse_mount: parse(sun): gathered options: fstype=nfs,credentials=/etc/credentials.txt  
 Nov 20 00:48:05 localhost.localdomain automount[22030]: [90B blob data]
 Nov 20 00:48:05 localhost.localdomain automount[22030]: dev_ioctl_send_fail: token = 21
 Nov 20 00:48:05 localhost.localdomain automount[22030]: failed to mount /tests/nfsshare
 Nov 20 00:48:05 localhost.localdomain automount[22030]: handle_packet:      type = 5
 Nov 20 00:48:05 localhost.localdomain automount[22030]: handle_packet_missing_direct: token 22, name /tests/nfsshare, request pid 22057
 Nov 20 00:48:05 localhost.localdomain automount[22030]: dev_ioctl_send_fail: token = 22

此外,ls -l /测试/nfs共享实际上会产生错误:

 ls: cannot access nfsshare/: No such file or directory

我该如何修复此问题?如前所述,手动安装共享可以正常工作。

编辑:

/var/log/audit/audit.log紧接着的输出sudo restart autofs和一些输出ls -l /tests/nfsshare会生成一些错误消息:

type=USER_END msg=audit(1447955572.809:1699): pid=23825 uid=1000 auid=1000 ses=1 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=PAM:session_close grantors=pam_keyinit,pam_limits,pam_systemd,pam_unix,pam_xauth acct="root" exe="/usr/bin/su" hostname=? addr=? terminal=pts/5 res=success'
type=CRED_DISP msg=audit(1447955572.811:1700): pid=23825 uid=1000 auid=1000 ses=1 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=PAM:setcred grantors=pam_unix acct="root" exe="/usr/bin/su" hostname=? addr=? terminal=pts/5 res=success'
type=SERVICE_START msg=audit(1447955718.341:1701): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg=' comm="fprintd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=USER_AUTH msg=audit(1447955721.421:1702): pid=23956 uid=1000 auid=1000 ses=1 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=PAM:authentication grantors=pam_unix acct="jdoe" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/5 res=success'
type=USER_ACCT msg=audit(1447955721.427:1703): pid=23956 uid=1000 auid=1000 ses=1 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=PAM:accounting grantors=pam_unix,pam_localuser acct="jdoe" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/5 res=success'
type=USER_CMD msg=audit(1447955721.428:1704): pid=23956 uid=1000 auid=1000 ses=1 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='cwd="/home/jdoe" cmd=73797374656D63746C2072657374617274206175746F66732E73657276696365 terminal=pts/5 res=success'
type=CRED_ACQ msg=audit(1447955721.430:1705): pid=23956 uid=0 auid=1000 ses=1 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=PAM:setcred grantors=pam_unix acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/5 res=success'
type=USER_START msg=audit(1447955721.431:1706): pid=23956 uid=0 auid=1000 ses=1 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=PAM:session_open grantors=pam_keyinit,pam_limits acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/5 res=success'
type=SERVICE_STOP msg=audit(1447955721.677:1707): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg=' comm="autofs" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=SERVICE_START msg=audit(1447955721.820:1708): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg=' comm="autofs" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=USER_END msg=audit(1447955721.824:1709): pid=23956 uid=0 auid=1000 ses=1 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=PAM:session_close grantors=pam_keyinit,pam_limits acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/5 res=success'
type=CRED_DISP msg=audit(1447955721.824:1710): pid=23956 uid=0 auid=1000 ses=1 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=PAM:setcred grantors=pam_unix acct="root" exe="/usr/bin/sudo" hostname=? addr=? terminal=/dev/pts/5 res=success'
type=USER_AUTH msg=audit(1447955746.378:1711): pid=24013 uid=1000 auid=1000 ses=1 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=PAM:authentication grantors=pam_unix acct="root" exe="/usr/bin/su" hostname=? addr=? terminal=pts/5 res=success'
type=USER_ACCT msg=audit(1447955746.385:1712): pid=24013 uid=1000 auid=1000 ses=1 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=PAM:accounting grantors=pam_unix,pam_localuser acct="root" exe="/usr/bin/su" hostname=? addr=? terminal=pts/5 res=success'
type=CRED_ACQ msg=audit(1447955746.386:1713): pid=24013 uid=1000 auid=1000 ses=1 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=PAM:setcred grantors=pam_unix acct="root" exe="/usr/bin/su" hostname=? addr=? terminal=pts/5 res=success'
type=USER_START msg=audit(1447955746.427:1714): pid=24013 uid=1000 auid=1000 ses=1 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 msg='op=PAM:session_open grantors=pam_keyinit,pam_limits,pam_systemd,pam_unix,pam_xauth acct="root" exe="/usr/bin/su" hostname=? addr=? terminal=pts/5 res=success'
type=SERVICE_STOP msg=audit(1447955748.277:1715): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg=' comm="fprintd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'

相关内容