NFS環境が整ったのでNISユーザがログインしたらNFSサーバでhomeを自動マウントするようにautofsを設定します。
CentOS 7 NIS+NFS+autofsでhomeの共有 – NFSサーバの設定
https://www.rootlinks.net/2016/03/28/centos-7-nisnfsautofsでhomeの共有-nfsサーバの設定/
CentOS 7 NIS+NFS+autofsでhomeの共有 – NFSクライアントの設定
https://www.rootlinks.net/2016/03/29/centos-7-nisnfsautofsでhomeの共有-nfsクライアントの設定/
環境
- host01
- host02
NISサーバ,NFSサーバ
CentOS Linux release 7.2.1511 (Core)
Linux host01.rootlinks.net 3.10.0-327.10.1.el7.x86_64
NISクライアント,NFSクライアント
CentOS Linux release 7.2.1511 (Core)
Linux host02.rootlinks.net 3.10.0-327.10.1.el7.x86_64
- host01(NIS,NFSサーバ)側の設定
- auto.master,auto.homeの作成
- NISでauto.master,auto.homeの提供
- NISの更新
- ypserv再起動
- host02(NIS,NFSクライアント)側設定
- autofsのインストール
- /etc/nsswitch.confの設定
- autofsの自動起動設定
- autofsの起動
NISサーバ経由でクライアントに提供するautofs関連の設定ファイルを作成します。
1 2 3 |
[root@host01 ~]# vi /etc/auto.master [root@host01 ~]# cat /etc/auto.master /nishome yp:auto.home |
1 2 3 |
[root@host01 ~]# vi /etc/auto.home [root@host01 ~]# cat /etc/auto.home * -fstype=nfs,rw,soft,rsize=8192,wsize=8192 host01:/nishome/& |
NISでauto.master,auto.homeの提供をするように追加します。
1 2 3 4 5 6 7 8 9 10 11 |
[root@host01 ~]# cat /var/yp/Makefile all: passwd group hosts rpc services netid protocols mail \ # netgrp shadow publickey networks ethers bootparams printcap \ # amd.home auto.master auto.home auto.local passwd.adjunct \ # timezone locale netmasks ######################################################################## # # # DON'T EDIT ANYTHING BELOW IF YOU DON'T KNOW WHAT YOU ARE DOING !!! # # # ######################################################################## |
↓
1 2 3 4 5 6 7 8 9 10 11 12 |
[root@host01 ~]# vi /var/yp/Makefile all: passwd group hosts rpc services netid protocols mail \ auto.master auto.home # netgrp shadow publickey networks ethers bootparams printcap \ # amd.home auto.master auto.home auto.local passwd.adjunct \ # timezone locale netmasks ######################################################################## # # # DON'T EDIT ANYTHING BELOW IF YOU DON'T KNOW WHAT YOU ARE DOING !!! # # # ######################################################################## |
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 29 30 31 32 33 34 35 36 37 38 39 40 41 |
[root@host01 ~]# /usr/lib64/yp/ypinit -m At this point, we have to construct a list of the hosts which will run NIS servers. host01.rootlinks.net is in the list of NIS server hosts. Please continue to add the names for the other hosts, one per line. When you are done with the list, type a <control D>. next host to add: host01.rootlinks.net next host to add: The current list of NIS servers looks like this: host01.rootlinks.net Is this correct? [y/n: y] We need a few minutes to build the databases... Building /var/yp/rootlinks.net/ypservers... Running /var/yp/Makefile... gmake[1]: Entering directory `/var/yp/rootlinks.net' Updating passwd.byname... Updating passwd.byuid... Updating group.byname... Updating group.bygid... Updating hosts.byname... Updating hosts.byaddr... Updating rpc.byname... Updating rpc.bynumber... Updating services.byname... Updating services.byservicename... Updating netid.byname... Updating protocols.bynumber... Updating protocols.byname... Updating mail.aliases... Updating auto.master... Updating auto.home... # netgrp shadow publickey networks ethers bootparams printcap \ # amd.home auto.master auto.home auto.local passwd.adjunct \ # timezone locale netmasks gmake[1]: Leaving directory `/var/yp/rootlinks.net' host01.rootlinks.net has been set up as a NIS master server. Now you can run ypinit -s host01.rootlinks.net on all slave server. |
1 |
[root@host01 ~]# systemctl restart ypserv |
1 2 3 4 5 6 7 8 9 |
[root@host02 ~]# yum -y install autofs (snip) Installed: autofs.x86_64 1:5.0.7-54.el7 Dependency Installed: hesiod.x86_64 0:3.2.1-3.el7 Complete! |
/etc/nsswitch.confを編集します。
1 |
automount: files nis |
↓
1 |
automount: nis files |
1 2 |
[root@host02 ~]# systemctl enable autofs Created symlink from /etc/systemd/system/multi-user.target.wants/autofs.service to /usr/lib/systemd/system/autofs.service. |
1 2 3 4 5 6 7 8 9 10 11 12 |
[root@host02 ~]# systemctl start autofs [root@host02 ~]# systemctl -l status autofs * autofs.service - Automounts filesystems on demand Loaded: loaded (/usr/lib/systemd/system/autofs.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2016-03-30 16:01:41 JST; 3s ago Process: 9289 ExecStart=/usr/sbin/automount $OPTIONS --pid-file /run/autofs.pid (code=exited, status=0/SUCCESS) Main PID: 9291 (automount) CGroup: /system.slice/autofs.service `-9291 /usr/sbin/automount --pid-file /run/autofs.pid Mar 30 16:01:41 host02.rootlinks.net systemd[1]: Starting Automounts filesystems on demand... Mar 30 16:01:41 host02.rootlinks.net systemd[1]: Started Automounts filesystems on demand. |