案例:
1.假设服务器的IP为10.106.48.200。
2./tmp共享为可读写,并且不限制用户身份的方式,共享给10.106.48..0/24网段的所有计算机。
3./home/nfs共享的属性为只读,可提供除了网段内的工作站外,向Internet亦提供数据内容。
4./home/upload作为10.106.48.0/24这个网段的数据上传目录,其中,/home/upload的用户及所属组为nfs-upload这个名字,它的UID与GID均为210。
5./home/andy这个目录仅共享给10.106.48.206这台主机,以供该主机上面andy这个用户使用,也就是说,xin在10.106.48.200及10.106.48.206上均有账号,且账号均为andy。
服务器端配置:
#yum install rpcbind //安装rpcbind和nfs-utils
#yum install nfs-utils
vim /etc/exports
/tmp 10.106.48.0/24(rw,no_root_squash)
/home/nfs 10.106.48.0/24(ro) *(ro,all_squash)
/home/upload 10.106.48.0/24(ro,all_squash,anonuid=210,anongid=210)
/home/any 10.106.48.200(rw)
# mkdir /home/nfs
# chmod 755 -R /home/nfs
# groupadd -g 210 nfs-upload
# useradd -g 210 -u 210 -M nfs-upload
# mkdir /home/upload
# chown -R nfs-upload.nfs-upload /home/upload
# useradd xin
# passwd xin
# service rpcbind start
Starting rpcbind: [ OK ]
# service nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS mountd: [ OK ]
Starting NFS daemon: [ OK ]
# hostname xin.com
# vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=xin.com
客户端:
# yum install rpcbind //安装rpcbind和nfs-utils
# yum install nfs-utils //仅使用nfs的工具命令,不启动服务
# service rpcbind start //启动RPC服务
# ping nuo.com //需ping通
# cd /mnt
# mkdir tmp nfs upload xin //创建挂载点
# mount -t nfs xin.com:/tmp /mnt/tmp //手动挂载
# mount -t nfs xin.com:/home/nfs /mnt/nfs
# mount -t nfs xin.com:/home/upload /mnt/upload
# mount -t nfs xin.com:/home/xin /mnt/xin
# vim /etc/fstab
测试
客户端(10.106.48.206,root身份登录)
# cd /mnt/tmp/
# touch 1.txt
# cd /mnt/nfs/
# touch 2.txt //只读权限
touch: cannot touch `2.txt': Read-only file system
# cd /mnt/upload/
# touch 3.txt
#useradd xin
#passwd xin
# su - xin
$ cd /mnt/xin/
$ touch 4.txt