热门IT资讯网

nfs之限定导出属性实例等

发表于:2024-11-24 作者:热门IT资讯网编辑
编辑最后更新 2024年11月24日,实例:nfs服务器:172.16.100.1客户端:172.16.100.31.创建挂载点并在客户端上挂载:S#vim /etc/exports/data 172.16.100.3/16(rw)/re

实例:

nfs服务器:172.16.100.1

客户端:172.16.100.3


1.创建挂载点并在客户端上挂载:

S#vim /etc/exports

/data 172.16.100.3/16(rw)

/read 172.16.100.3/16(ro)


C#mount -t nfs 172.16.100.1:/data /sqld/mdata


C#showmount -a 172.16.100.1

C#showmount -e 172.16.100.1

C#showmount -d 172.16.100.1


2.不重启服务重新导出

S#S#vim /etc/exports

/data 172.16.100.3/16(rw)

#/read 172.16.100.3/16(ro)


S#exprotnfs -rav 重新导出


C#showmount -e 172.16.100.1


3.限定导出属性

nfs的权限认证是基于账号的uid和gid的。


S#id hadoop

uid=502 gid=502

S#setfacl -m u:hadoop:rwx /read

S#su -hadoop

S$cd /data

S$touch a.hadoop



C#groupadd -g 502 openstack

C#useradd -u 502 -g 502 openstack


S#exportfs -ra


C#mount -t nfs 172.16.100.1:/data /sqld/mdata

C#ll /sqld/mdata

a.hadoop openstack openstack


C#su - openstackl

C$cd /sqld/mdata

C$touch b.openstack


S#ll /read


此时会发现b.openstack的属主属组为hadoop。


S#useradd -u 510 nfstest

S#cd /data

S#touch c.nfstest

S#chown nfstest:nfstest c.nfstest

S#vim /etc/exprots

/data 172.16.100.3/16(rw,all_squash,anonuid=510,nanogid=510) 限定导出属性

#/read 172.16.100.3/16(ro)


S#exportfs -rav


C#umount /sqld/mdata

C#mount -t nfs 172.16.100.1:/data /sqld/mdata

C#ll /sqld/mdata


4.客户端开机挂载:

C#vim /etc/fstab

172.16.100.1:/data /sqld/mdata nfs defaults,_netdev 0 0


5.服务器进程使用固定端口:

S#vim /etc/sysconfig/nfs

MOUNTD_PORT=892

RQUOTAD_PROT=875

LOCKD_TCPPORT=32083

LOCKD_UDPPORT=32769


0