天天看点

centos轻松搭建NFS

首先要了解NFS是由哪两个服务带动,一个是rpcbind一个是nfs。这两个服务启动是有先后顺序的,要先启动rpcbind再启动nfs.

如图所示:

centos轻松搭建NFS

这里有一个案例:

centos轻松搭建NFS

 这道题要怎么做?

NFS服务器配置:

首先新建两个目录,一个是RW一个是RO的。

[root@NFS-svr w_shared]# cat /etc/exports

/data/r_shared 192.168.3.0/24(ro,sync,no_root_squash)

/data/w_shared 192.168.3.0/24(rw,sync,no_root_squash)

exportfs -a

使exports马上生效

设定两个权限,一个是只读的,一个是可写的

chown -R nfsnobody /data/w_shared/

chown -R nfsnobody /data/r_shared/

给nfsnobody的权限,这里类似windows的共享目录里的everyone

chmod o+w /data/w_shared/

给写的权限。

rpcinfo -p localhost

看看有没有房。

NFS客户端配置:

[root@lnmp01-svr b_r]# showmount -e 192.168.3.106

Export list for 192.168.3.106:

/data/w_shared (everyone)

/data/r_shared (everyone)

看看有没有共享资源。

mount -t nfs 192.168.3.106:/data/w_shared /data/b_w/

mount -t nfs 192.168.3.106:/data/r_shared /data/b_r/

在data下新建两个挂载点,然后把可读和可写的共享目录挂载进来。

centos轻松搭建NFS

挂载成功。然后测试可读可写。

centos轻松搭建NFS

 测试完毕!

涉及命令:mount showmount rpcinfo exportfs umount

继续阅读