构建NFS远程共享存储
因为NFS有很多功能,不同的功能需要使用不同的端口。因此NFS无法固定端口。而RPC会记录NFS端口的信息,这样我们就能够通过RPC实现服务端和客户端的RPC来沟通端口信息。
那RPC和NFS之间又是如何之间相互通讯的?
首先当NFS启动后,就会随机的使用一些端口,然后NFS就会向RPC去注册这些端口。RPC就会记录下这些端口。并且RPC会开机111端口,等待客户端RPC的请求,如果客户端有请求,那服务端的RPC就会将记录的NFS端口信息告知客户端。
NFS 重要指数4星
项目名称: 为集群中的 Web Server 配置后端存储
NFS:Network File System 网络文件系统,Unix系统之间共享文件的一种协议
NFS 的客户端主要为Linux
支持多节点同时挂载以及并发写入
nfs 192.168.62.142
web1 192.168.62.136
centos7(服务端和客户端都关闭防火墙和selinux内核防火墙)
# systemctl stop firewalld
# systemctl disable firewalld
# setenforce 0
# vim /etc/hosts [可选](服务端和客户端都操作)
192.168.62.142 nfs
192.168.62.136 web1
NFS(此步为说明)
1.安装软件
yum -y install rpcbind(提供rpc协议)
yum -y install nfs-utils(主包提供文件系统)
2.启动服务------>这两个服务必须同时启用
systemctl start nfs
systemctl start rpcbind
一、nfs(存储端/服务端)
[root@nas ~]# yum -y install rpcbind
[root@nas ~]# yum -y install nfs-utils
[root@nas ~]# mkdir /zhengzhou //存储网站代码
[root@nas ~]# echo "nfs test..." > /zhengzhou/index.html
[root@nas ~]# vim /etc/exports
/zhengzhou 192.168.122.0/24(rw,no_root_squash) //不限制root(当client端使用root挂载时,也有root权限) 挂载是root ,同样保持root权限
注意:如果再次修改配置文件。记得重新启动(重新加载)服务
[root@nas ~]# systemctl restart nfs-server
[root@nas ~]# systemctl enable nfs-server
二、web1 客户端
以web1为例:
[root@web1 ~]# yum -y install rpcbind
[root@web1 ~]# yum -y install nfs-utils
手动挂载 [可选]
[root@web1 ~]# mkdir /qf
[root@web1 ~]# mount -t nfs 192.168.122.59 :/zhengzhou /qf
[root@web1 ~]# umount /qf
自动挂载到网站主目录
[root@web1 ~]# vim /etc/fstab
192.168.122.59 :/zhengzhou /qf nfs defaults 0 0
[root@web1 ~]# mount -a
查看挂载
[root@web1 ~]# df -Th
192.168.122.59:/zhengzhou 7923136 692416 6821568 10% /qf
[root@web1 ~]# ls /qf
index.html
[root@web1 qf]# cat index.html
nfs test...