安装nfs
[roo@super63 ~]# rpm -ivh /mnt/Packages/nfs-utils-1.2.3-39.el6.x86_64.rpm
配置nfs
[root@super63 ~]# vim /etc/exports
重启nfs
[root@super63 ~]# service nfs restart
查看共享文件夹:
[root@super64 opt]# showmount -e 192.168.1.63
Export list for 192.168.1.63:
/data *
挂载共享文件
[root@super64 ~]# mount 192.168.1.63:/data/ /opt
开机挂载
[root@super64 opt]# chkconfig nfs on
开机自动挂载
[root@super64 opt]# vim /etc/fstab
使用
[root@super64 opt]# touch bb
[root@super64 opt]# touch aaa
[root@super64 opt]# ls
aaa bb lost+found
特殊的共享参数:
cat /etc/exports
/tmp/a/no_root_squash *(rw,no_root_squash)
/tmp/a/sync 192.168.1.0/24(rw,sync)
/tmp/a/ro 192.168.1.64(ro)
/tmp/a/all_squash *.baidu.com(rw,all_squash,anonuid=500,anongid=500)
/tmp/a/async 192.168.3.0/255.255.255.0(async)
/tmp/a/rw 192.168.3.0/255.255.255.0(rw) 192.168.4.0/255.255.255.0(rw)
/tmp/a/root_squash *(rw,root_squash)
注意:在发布共享目录的格式中除了共享目录是必跟参数外,其他参数都是可选的。并且共享
目录与客户端之间及客户端与客户端之间需要使用空格符号,但是客户端与参数之间是不能有
空格的
sync/async:数据同步写入硬盘/不同步写入在内存中缓存
root_squash(压制):如果用root登录nfs,使其身份自动且换成nfsnobody。
no_root_squash:如果用root登录nfs,使其身份就是root。
all_squash:用户登录nfs时,指定身份为UID/GID的用户。