NFS 共享存储原理+安装部署

NFS简介

NFS就是Network File System的缩写,它最大的功能就是可以通过网络,让不同的机器、不同的操作系统可以共享彼此的文件。
NFS服务器可以让PC将网络中的NFS服务器共享的目录挂载到本地端的文件系统中,而在本地端的系统中来看,那个远程主机的目录就好像是自己的一个磁盘分区一样,在使用上相当便利

在这里插入图片描述

linux下搭建NFS服务 (centos7版本)

准备环境

1.准备三台centos7的虚拟机

192.168.27.136 NFS服务端
192.168.27.137 NFS客户端
192.168.27.138 NFS客户端
在这里插入图片描述

2.关掉防火墙 setenforce

[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0

安装配置nfs 服务

一.先在服务端(136)安装配置

[root@localhost ~]# yum -y install rpcbind nfs-utils

1.创建个共享的目录 加权限

[root@localhost ~]# mkdir -p /opt/share
[root@localhost ~]# chmod  777 /opt/share/

2.修改exports文件设置共享资源

[root@localhost ~]# vim /etc/exports
/opt/share/ 192.168.27.0/24(rw,sync,no_root_squash)
                   网段    读写 同步 当NFS客户端以root管理员访问时,映射为NFS服务器的root管理员        

3.按顺序启动rpcbind nfs 并查看

[root@localhost ~]# systemctl start rpcbind
[root@localhost ~]# systemctl start nfs
[root@localhost ~]# showmount -e
Export list for localhost.localdomain:
/opt/share 192.168.27.0/24

二.在NFS客户端安装、查看并挂载

[root@localhost ~]# yum -y install nfs-utils rpcbind

[root@localhost ~]# showmount -e 192.168.27.136
Export list for 192.168.27.136:
/opt/share 192.168.27.0/24
[root@localhost ~]# mount -t nfs 192.168.27.136:/opt/share /mnt/

三.测试

1.在NFS服务端 共享目录里创建文件

[root@localhost ~]# cd /opt/share/
[root@localhost share]# touch a
[root@localhost share]# ls
a

2.在NFS客户端查看有没有共享过来

[root@localhost ~]# cd /mnt/
[root@localhost mnt]# ls
a

NFS服务搭建完成 666

猜你喜欢

转载自blog.csdn.net/Q274948451/article/details/109109418