天天看点

将linux文件 共享给客户机的权限和降低客户机的权限

将/usr/src 共享给192.168.10.20读写访问,同步

192.168.10.21只读访问,异步,访问权限均降为nfsnobody用户

将/root共享通过fstab实现开机自动挂载在

将/usr/src共享通过autofs实现触发挂载

一、查看有没有安装软件包

[root@localhost ~]# rpm -q nfs-utils portmap

nfs-utils-1.0.9-66.el5

portmap-4.0-65.2.2.1

二、修改主配置文件

[root@localhost ~]# cat /etc/exports

/root 192.168.10.20/24(rw,sync,no_root_squash)

/usr/src 192.168.10.20(rw,sync) 192.168.10.30(ro,async,all_squash)

[root@localhost ~]# setfacl -m u:nfsnobody:rwx /usr/src

三、启动服务

[root@localhost ~]# exportfs -rv

exporting 192.168.10.20:/usr/src

exporting 192.168.10.30:/usr/src

exporting 192.168.10.20/24:/root

四、客户端测试

[root@localhost root]# mkdir -p /data/src

[root@localhost root]# showmount -e 192.168.10.10

Export list for 192.168.10.10:

/root    192.168.10.20/24

/usr/src 192.168.10.30,192.168.10.20

[root@localhost root]# mount -t nfs 192.168.10.10:/usr/src/ /data/src/

五、将/root共享通过fstab实现开机自动挂载

在客户端操作:

[root@localhost root]# cat /etc/fstab

LABEL=/                 /                       ext3    defaults        1 1

LABEL=/boot             /boot                   ext3    defaults        1 2

tmpfs                   /dev/shm                tmpfs   defaults        0 0

devpts                  /dev/pts                devpts  gid=5,mode=620  0 0

sysfs                   /sys                    sysfs   defaults        0 0

proc                    /proc                   proc    defaults        0 0

LABEL=SWAP-sda3         swap                    swap    defaults        0 0

192.168.10.10:/root    /nfs/src                 nfs     defaults        0 0

[root@localhost root]# mkdir -p /nfs/src

[root@localhost root]# tail -n 1 /etc/fstab

[root@localhost root]# mount -a

[root@localhost root]# df -h | grep nfs

192.168.10.10:/root    76G  2.9G   69G   4% /nfs/root

六、将/usr/src共享通过autofs实现触发挂载

[root@localhost ~]# rm -rf /data

[root@localhost ~]# mkdir /data

[root@localhost ~]# cat /etc/auto.master

/data   /etc/auto.data

[root@localhost ~]# cat /etc/auto.data

src     -fstype=nfs,rw  192.168.10.10:/usr/src

[root@localhost ~]# service autofs restart

停止 automount:                                           [确定]

启动 automount:                                           [确定]

[root@localhost ~]# cd /data/src

[root@localhost src]# ls

debug  kernels

继续阅读