Autofs(CentOS 7.4)를 사용하여 NFS 홈 디렉토리를 마운트하는 중에 문제가 발생했습니다.

Autofs(CentOS 7.4)를 사용하여 NFS 홈 디렉토리를 마운트하는 중에 문제가 발생했습니다.

NFS를 통해 사용자의 홈 디렉토리를 마운트하기 위해 autofs를 가져오는 데 문제가 있습니다. NFS 클라이언트(client.home)와 NFS 서버(server.home)가 있습니다. 두 시스템 모두 CentOS 7.4입니다. SELinux는 두 시스템 모두에서 허용 모드로 실행됩니다. 사용자의 홈 디렉토리를 자동으로 마운트할 수 있도록 올바른 방향을 알려줄 수 있는 사람이 있습니까?

서버의 NFS 내보내기 테이블

[root@server ~]# exportfs -v
/home/tim       
client.home(rw,sync,wdelay,hide,no_subtree_check,sec=sys,secure,root_squash,no_all_squash)

클라이언트는 이러한 내보내기를 볼 수 있습니다.

[root@client ~]# showmount -e server
Export list for server:
/home/tim client.home

두 명의 사용자가 있습니다. 하나는 클라이언트에, 다른 하나는 서버에 있습니다. 이름과 UID가 동일합니다. 그러나 사용자의 홈 디렉터리는 server.home.

[tim@server ~]$ id
uid=1001(tim) gid=1001(tim) groups=1001(tim) 
context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023


-bash-4.2$ hostname
client.home
-bash-4.2$ id
uid=1001(tim) gid=1001(tim) groups=1001(tim) 
context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

tim이 디렉토리는 의 사용자에 대해 자동으로 마운트 되어야 합니다 client.home. 불행히도 그런 일은 일어나지 않는 것 같습니다.

[root@client ~]# su - tim
-bash-4.2$ id
uid=1001(tim) gid=1001(tim) groups=1001(tim) 
context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
-bash-4.2$ cd /home/tim
-bash: cd: /home/tim: No such file or directory
-bash-4.2$ ls /home
vagrant

auto.master그럼에도 불구하고 나는 내 파일이 올바르게 설정되었다고 믿습니다 .

[root@client ~]# cat /etc/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/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
#
# Include /etc/auto.master.d/*.autofs
# The included files must conform to the format of this file.
#
+dir:/etc/auto.master.d
#
# 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

/home   /etc/auto.home

그리고 내 콘텐츠/etc/auto.home

[root@client /]# cat /etc/auto.home 
*   nfs4,rw     &:/home/&

나는 cd사용자의 홈 디렉토리로 간단히 들어갈 수 있기를 바라고 있습니다. autofs.service대신 실행할 때 /home.

[root@client /]# systemctl is-active autofs
active
[root@client /]# touch /home/test
touch: cannot touch ‘/home/test’: Permission denied
[root@client home]# ll -d /home
drwxr-xr-x. 2 root root 0 Sep 16 02:04 /home
[root@client /]# systemctl stop autofs
[root@client /]# systemctl is-active autofs
inactive
[root@client /]# touch /home/test
[root@client /]# ls /home
test  vagrant

편집하다:

NFS 공유를 수동으로 마운트할 수 있습니다. 또한 이전에 발생한 이상한 권한 문제는 root_squash파일에 설정한 옵션 때문이라고 확신합니다 /etc/exports.

[root@client ~]# mount -t nfs4 -o rw server.home:/home/tim /mnt
[root@client ~]# df -t nfs4
Filesystem            1K-blocks    Used Available Use% Mounted on
server.home:/home/tim  39269760 1192448  38077312   4% /mnt
[root@client ~]# ll -d /mnt
drwx------. 2 tim tim 86 Sep 16 18:51 /mnt

답변1

나는 그것에 대해 생각했다. /etc/auto.master클라이언트에서 편집해야 할 때 서버에서 편집하고 있습니다. 즉, 클라이언트측에 다음 내용을 추가합니다./etc/auto.master

/home/    /etc/auto.home

여전히 클라이언트에서 /etc/auto.home파일을 만들고 다음 내용을 추가합니다.

*    -nfs4,rw    &:/home/&

마지막으로 autofs를 다시 시작합니다(클라이언트에서).

$ systemctl restart autofs

그렇게하는 게 좋겠습니다. 클라이언트의 사용자는 서버의 사용자와 동일해야 합니다(동일한 사용자 이름, 동일한 UID). 이는 일반적으로 LDAP를 사용하여 수행됩니다. 또한 autofs가 클라이언트에 마운트 지점을 생성하므로 홈 디렉토리는 서버에만 존재해야 합니다.

관련 정보