nfsサーバ
/etc/exports
cat exports # /local 172.31.0.0/255.255.0.0 (ro) /local 192.168.0.0/255.255.255.0 (ro) /local 192.168.1.0/255.255.255.0 (ro)
許すグループを「@hogehoge 」(グループ名hogehogeの場合)で指定し
/etc/netgroupでグループの指定を行うこともある
nfsクライアント
- クライアント側では mount コマンドを使って、NFS経由でファイルにアクセスできる
- 毎回 mount を発行するのも面倒なので、Linux がクライアントの場合には、autofsを利用する。
http://www.linux.or.jp/JM/html/autofs/man5/auto.master.5.html
http://www.linux.or.jp/JM/html/autofs/man5/autofs.5.html
http://www.linux.or.jp/JM/html/autofs/man8/automount.8.html
http://www.linux.or.jp/JM/html/autofs/man8/autofs.8.html (制御スクリプト、=/etc/init.d/autofs)
/etc/auto.master の設定
- auto.master は、autofs で管理されたディレクトリの管理元。
- ほとんどのディストリビューションはローカルのCD-ROMやFDをマウント用 /misc エントリを持っている。
- ネットワーク経由の自動マウントのためのエントリとして /nfs を加える。
/misc /etc/auto.misc --timeout=60 /nfs /etc/auto.nfs --timeout=300
/etc/auto.nfs の作成
/etc/auto.nfs には、マウントするNFSディレクトリを列記。
home -rw,hard,intr,rsize=8192,wsize=8192 hogehoge:/home
- 先頭:/nfs の下のマウントポイント
- 真ん中: mount に渡すオプション
- 最後:NFSサーバの指定
automount の再起動
# /etc/init.d/autofs restart
ls /nfs/home
- きちんとマウントされていれば、ファイルが見える。
- アクセスがなくなってxxx秒(auto.masterで指定したtimeoutの秒数)が経過すると自動的にアンマウントされる。
実際の設定は
pukiwiki_cat /etc/auto.master
# # $Id: auto.master,v 1.3 2003/09/29 08:22:35 raven Exp $ # # Sample auto.master file # This is an automounter map and it has the following format # key [ -mount-options-separated-by-comma ] location # For details of the format look at autofs(5). #/misc /etc/auto.misc --timeout=60 #/misc /etc/auto.misc #/net /etc/auto.net /nfs /etc/auto.nfs #<---この行を追加
pukiwiki_cat auto.nfs
www -rw,hard,intr,rsize=8192,wsize=8192 hogehoge:/hd1/www doc -rw,hard,intr,rsize=8192,wsize=8192 hogehoge:/hd1/doc
(nfsサーバ名hogehogeの場合)
で、/nfs/www , /nfs/docを、/www , /docにリンクする(ローカルでも同じディレクトリ構造にするため)
cd /nfs mkdir www mkdir doc cd / ln -s /nfs/www www ln -s /nfs/doc doc