NFSv3サーバを作る
NIS/NFSサーバにユーザをログインさせる必要がないのならNIS/NFSサーバ共に ypbind は不要である
NISサーバで作成したユーザの設定値確認として ypbind を使うのはあるだろうが、その際はユーザに
ログインさせないような手立てが必要なのかも。
例えば
- ssh経由のみ許可
- /etc/ssh/sshd_configでAllowUsersを使用してログインユーザを限定
- netgroupを定義して、nsswitch.confでcompatを使用してユーザ限定
らを行う。NFSサーバにも有効かと
NFSv3構築 †
NFSv3で公開する場所は /export とします。
[root@nfs ~]# yum install nfs-utils
[root@nfs ~]# chkconfig nfs on
[root@nfs ~]# cat << _EOF_ > /etc/exports
/export *.chaperone.jp(rw)
_EOF_
[root@nfs ~]# exportfs -av
exporting *.chaperone.jp:/export
[root@nfs ~]#
簡単には再起動、もしくは
[root@nfs ~]# /etc/init.d/rpcbind start
[root@nfs ~]# /etc/init.d/nfs start
にて構築は完了である
ホームディレクトリ作成 †
authconfigの「--enablemkhomedir」は静的にNFSマウントした箇所でないとホームディレクトリは作ってくれないみたい。
autofsとかの動的にNFSマウント先が決まる形式だと無理だった
その場合、手動でホームディレクトリを用意するしかなく、saber(UID:1003, GID:2001)のホームディレクトリなら
[root@nfs ~]# rm -rf /export/saber && cp -r /etc/skel /export/saber && chown -R 2001:2000 /export/saber
として作る。NISのauto.homeに従い他のユーザのホームディレクトリも作る
saber -rw nfs:/export/saber
illya -rw nfs:/export/illya
ypcat passwdとypcat -k auto.homeからホームディレクトリを作るスクリプトなんかあれば楽かと。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| -
!
-
|
|
|
!
-
-
|
|
!
!
| use strict;
my @v=();
my (%u, %g) = ();
open(USR, "ypcat passwd |");
while(<USR>){
@v = split(/:/);
$u{$v[0]}=$v[2];
$g{$v[0]}=$v[3];
}
close(USR);
@v=();
open(HOME,"ypcat -k auto.home |sort |");
while(<HOME>){
if(/^(\S+)\s+(\S+)\s+(\S+)$/){
@v=split(/:/,$3);
print "cp -r /etc/skel ".$v[1]." && chown -R ".$u{$1}.":".$g{$1}." ".$v[1]."\n";
}
}
close(HOME);
|
autofs †
auto.master、auto.homeが定義されていれば、クライアントのautofsデーモンからNFSv3が利用できる
[root@client ~]# /etc/init.d/autofs start
[root@client ~]# cd /home/saber
[root@client saber]# df -Th |grep nfs
nfs:/export/saber nfs 5.5G 859M 4.3G 17% /home/saber
[root@client saber]#
_netdev †
NFSとかをmountするなら、この「_netdev」を付けるとnetworkが開始するまでnfs操作を待ってくれるみたい
nfs:/export/home /home nfs defaults,_netdev 0 0