最新消息: 关于Git&GitHub 版本控制你了解多少?
您现在的位置是:群英 > 服务器 > 系统运维 >
如何实现NFS共享存储服务?
CSDN发表于 2020-09-08 18:04 次浏览

NFS共享存储服务,简单的来说:它就是是可以透过网络,让不同的主机、不同的操作系统可以共享存储。

NFS (Network File System) 网络文件系统

●依赖于RPC (远端过程调用)
●需安装nfs-utils、rpcbind软件包
●系统服务: nfs、 rpcbind
●共享配置文件: /etc/exports

配置NFS共享储存实验

一、服务器端设置NFS共享目录(假定服务器ip:20.0.0.11)

[root@localhost other]# yum -y install nfs-utils
[root@localhost other]# yum -y install rpcbind
[root@localhost other]# mkdir /opt/wwwroot/
[root@localhost other]# vi /etc/exports

/opt/wwwroot 20.0.0.0/24(rw,sync,no_root_squash)
/opt/ftp/pub 20.0.0.12(ro) 20.0.0.13(rw)

在这里插入图片描述
[root@localhost other]# systemctl start nfs
[root@localhost other]# systemctl start rpcbind
[root@localhost other]# systemctl enable rpcbind
[root@localhost other]# systemctl enable nfs
[root@localhost other]# showmount -e
在这里插入图片描述

二、去客户端挂载共享目录(假定客户机ip:20.0.0.12)

[root@localhost ~]# yum -y install rpcbind ##访问需要安装RPC工具
[root@localhost ~]# yum -y install showmount ##安装showmount工具用于查看共享目录
[root@localhost ~]# showmount -e 20.0.0.11
在这里插入图片描述
[root@localhost ~]# mkdir /var/www
设置临时挂载
[root@localhost ~]# mount 20.0.0.11:/opt/wwwroot /var/www/(临时挂载)
[root@localhost ~]# tail -1 /etc/mtab

三、写入数据进行测试

(1)服务器端写入数据
[root@localhost other]# cd /opt/wwwroot
[root@localhost wwwroot]# ll

total 0

[root@localhost wwwroot]# touch 1.txt
[root@localhost wwwroot]# echo 158313213456123 > 1.txt
[root@localhost wwwroot]# cat 1.txt

158313213456123

客户端查看(测试无误,能看到完整数据)
[root@localhost ~]# cd //var/www
[root@localhost www]# ll

total 4
-rw-r–r-- 1 root root 16 Aug 2 16:13 1.txt

[root@localhost www]# cat 1.txt

158313213456123

(2)客户端写入数据
[root@localhost www]# cd /var/www
[root@localhost www]# touch 2.txt
[root@localhost www]# echo 2222222222 > 2.txt
[root@localhost www]# cat 2.txt

2222222222

服务器端查看(数据无误,测试成功)
[root@localhost wwwroot]# cd /opt/wwwroot
[root@localhost wwwroot]# ll

total 8
-rw-r–r--. 1 root root 16 Aug 2 16:13 1.txt
-rw-r–r--. 1 root root 11 Aug 2 16:16 2.txt

[root@localhost wwwroot]# cat 2.txt

2222222222

标签:NFS共享
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
相关信息推荐