1.实验平台:Ubuntu11.10
2.用到的软件:
server端:sudo apt-get install portmap nfs-kernel-server
client端 : sudo apt-get install portmap nfs-common
sudo apt-get install autofs
3.模拟环境:
server IP :192.168.2.4
client IP :192.168.2.5
/home/lyang 该目录仅供给192.168.2.5这台主机的lyang用户
/home/nfs-share 该目录共享为可读写,不限制用户身份,供给192.168.2.0/24这个网段中的所有PC
/home/nfs 该目录共享属性为只读,向所有用户开放包括internet
4.服务器端设置
mkdir -p /home/lyang
chmod 700 -R /home/lyang
mkdir -p /home/nfs
chmod 755 -R /home/nfs
mkdir -p /home/nfs-share
chmod 777 -R /home/nfs-share
/etc/init.d/nfs-kernel-server restart(确保rpcbind已经启动)
showmount -e 192.168.2.4
5.客户端设置
showmount -e 192.168.2.4
vim /etc/auto.master
/home/nfsfile /etc/auto.nfs (确保/home/nfsfile在此前不存在)
vim /etc/auto.nfs
lyang -rw,bg,soft,rsize=32768,wsize=32768,nosuid,noexec,nodev 192.168.2.4:/home/lyang
nfs -rw,bg,soft,rsize=32768,wsize=32768,nosuid,noexec,nodev 192.168.2.4:/home/nfs
nfs-share -rw,bg,soft,rsize=32768,wsize=32768,nosuid,noexec,nodev 192.168.2.4: /home/nfs-share
ls -ld /home/nfsfile
cd /home/nfsfile/lyang
mount | grep nfsfile
df /home/nfsfile/lyang
chkconfig autofs on