#author("2021-02-10T14:35:43+00:00","default:sysosa","sysosa") NFSv3サーバを作る NIS/NFSサーバにユーザをログインさせる必要がないのならNIS/NFSサーバ共に ypbind は不要である NISサーバで作成したユーザの設定値確認として ypbind を使うのはあるだろうが、その際はユーザに ログインさせないような手立てが必要なのかも。 例えば -ssh経由のみ許可 -/etc/ssh/sshd_configでAllowUsersを使用してログインユーザを限定 -netgroupを定義して、nsswitch.confでcompatを使用してユーザ限定 らを行う。NFSサーバにも有効かと ***NFSv3構築 [#td3b2463] NFSv3で公開する場所は /export とします。 #code(nonumber){{ [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 ~]# }} 簡単には再起動、もしくは #code(nonumber){{ [root@nfs ~]# /etc/init.d/rpcbind start [root@nfs ~]# /etc/init.d/nfs start }} にて構築は完了である ***ホームディレクトリ作成 [#ac249112] authconfigの「&color(magenta){--enablemkhomedir};」は静的にNFSマウントした箇所でないとホームディレクトリは作ってくれないみたい。 autofsとかの動的にNFSマウント先が決まる形式だと無理だった その場合、手動でホームディレクトリを用意するしかなく、saber(UID:1003, GID:2001)のホームディレクトリなら #code(nonumber){{ [root@nfs ~]# rm -rf /export/saber && cp -r /etc/skel /export/saber && chown -R 2001:2000 /export/saber }} として作る。NISのauto.homeに従い他のユーザのホームディレクトリも作る #code(nonumber){{ saber -rw nfs:/export/saber illya -rw nfs:/export/illya }} &color(magenta){ypcat passwd};と&color(magenta){ypcat -k auto.home};からホームディレクトリを作るスクリプトなんかあれば楽かと。 #code(perl){{ #!/usr/bin/perl 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 [#s52f2f81] auto.master、auto.homeが定義されていれば、クライアントのautofsデーモンからNFSv3が利用できる #code(nonumber){{ [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 [#v3775fb1] NFSとかをmountするなら、この「_netdev」を付けるとnetworkが開始するまでnfs操作を待ってくれるみたい #code(nonumber){{ nfs:/export/home /home nfs defaults,_netdev 0 0 }}