LDAPでユーザ認証を統合したが、ホームディレクトリも統合しないと意味がない。NFSは従来(バージョン3までは)udpの不定ポートを使っていてファイやウォールやiptablesがらみの設定が厄介だったが、NFSバージョン4からは2049/tcpのみでよい。
なおサーバ側、クライアント側ともに自ホスト、相手ホストのホスト名とFQDNが解決できなければいけない。/etc/hostsにちゃんと書いておく。
【サーバ側設定】
①パッケージをインストール。もともと入っていた。
[root@storage1 ~]# yum install nfs-utils [root@storage1 ~]# yum install nfs-utils-lib
②NFSで共有するディレクトリを設定し、NFSを再起動。
[root@storage1 ~]# vi /etc/exports /home 192.168.0.0/24(rw,sync,fsid=0) [root@storage1 ~]# service nfs restart
ここでnfsd=0を入れ忘れていて何度やっても
[root@ns1 ~]# mount -t nfs4 storage1:/ /home/ mount.nfs4: Operation not permitted
となってしまった。
③idmapd(NFSv4のユーザ認証で使用?)の設定。
[root@storage1 ~]# vi /etc/idmapd.conf [General] Verbosity = 0 Pipefs-Directory = /var/lib/nfs/rpc_pipefs Domain = grandarbre.net [Mapping] Nobody-User = nfsnobody Nobody-Group = nfsnobody [Translation] Method = nsswitch④iptablesの設定
[root@storage1 ~]# vi /etc/sysconfig/iptables ... -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 2049 -j ACCEPT ... [root@storage1 ~]# service iptables restart
⑤ちゃんとエクスポートしているか確認
[root@storage1 ~]# showmount -e Export list for storage1.grandarbre.net: /home 192.168.0.0/24 [root@storage1 ~]# exportfs -v /home 192.168.0.0/24(rw,wdelay,root_squash,no_subtree_check,fsid=0,anonuid=65534,anongid=65534)
⑥うまくいったらnfsを自動起動するようにする
[root@storage1 ~]# chkconfig nfs on
【クライアント側設定】
①パッケージをインストール。もともと入っていた。
[root@ns1 ~]# yum install nfs-utils [root@storage1 ~]# yum install nfs-utils-lib
②idmapd(NFSv4のユーザ認証で使用?)の設定。
[root@ns1 ~]# vi /etc/idmapd.conf [General] Verbosity = 0 Pipefs-Directory = /var/lib/nfs/rpc_pipefs Domain = grandarbre.net [Mapping] Nobody-User = nfsnobody Nobody-Group = nfsnobody [Translation] Method = nsswitch
③/etc/fstabに設定
[root@ns1 ~]# vi /etc/fstab ... storage1:/ /home nfs4 rw,hard,noauto 0 0 ...
④マウントしてみる
[root@ns1 ~]# mount /home [root@ns1 /]# mount /dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) /dev/xvda1 on /boot type ext3 (rw) tmpfs on /dev/shm type tmpfs (rw) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw) nfsd on /proc/fs/nfsd type nfsd (rw) storage1:/ on /home type nfs4 (rw,hard,addr=192.168.0.24) [root@ns1 /]# ls /home/ This_is_Shared_Directory.txt [root@ns1 /]#