0%

RHCSA (EX200) - 配置 autofs

配置 autofs

配置 autofs,以按照如下所述自动挂载远程用户的主目录:

materials.example.com (172.25.254.254) NFS 导出 /rhome 到您的系统。此文件系统包含为用户 remoteuser1 预配置的主目录

remoteuser1 的主目录是 materials.example.com:/rhome/remoteuser1

remoteuser1 的主目录应自动挂载到本地 /rhome 下的 /rhome/remoteuser1

主目录必须可供其用户 写入

remoteuser1 的密码是 flectrag

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
[root@node1 ~]# showmount -e materials.example.com
Export list for materials.example.com:
/rhome/remoteuser1 *
[root@node1 ~]# cat /etc/passwd | grep "remoteuser1"
remoteuser1:x:1002:1002::/rhome/remoteuser1:/bin/bash
[root@node1 ~]# yum list autofs
Installed Packages
autofs.x86_64 1:5.1.4-40.el8 @rhel-8.2-for-x86_64-baseos-rpms
[root@node1 ~]# systemctl is-active autofs.service
inactive
[root@node1 ~]# mount -t nfs materials.example.com:/rhome/remoteuser1 /mnt/
[root@node1 ~]# umount /mnt
[root@node1 ~]# vim /etc/auto.master.d/direct.autofs
# /etc/auto.master.d/direct.autofs
/- /etc/auto.direct
[root@node1 ~]# vim /etc/auto.direct
# /etc/auto.direct
/rhome/remoteuser1 -rw,sync materials.example.com:/rhome/remoteuser1
[root@node1 ~]# systemctl enable --now autofs.service
Created symlink /etc/systemd/system/multi-user.target.wants/autofs.service → /usr/lib/systemd/system/autofs.service.
[root@node1 ~]# ls -l /rhome/remoteuser1/
total 0
[root@node1 remoteuser1]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
...
materials.example.com:/rhome/remoteuser1 nfs4 50G 1.9G 49G 4% /rhome/remoteuser1
[root@node1 ~]# mount | grep "/rhome"
materials.example.com:/rhome/remoteuser1 on /rhome/remoteuser1 type nfs4 (rw,relatime,sync,vers=4.2,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=172.25.250.100,local_lock=none,addr=172.25.254.254)
1
2
3
4
5
[kiosk@foundation0 ~]$ ssh remoteuser1@172.25.250.100
remoteuser1@172.25.250.100's password:
[remoteuser1@node1 ~]$ pwd
/rhome/remoteuser1
[remoteuser1@node1 ~]$ touch tmpfile