超详细!!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

猜你喜欢

转载自blog.csdn.net/CN_LiTianpeng/article/details/107795345