请使用本地yum源
规划节点
ip | 主机名 | 节点 |
---|---|---|
192.168.200.10 | nfs-server | nfs服务器 |
192.168.200.20 | nfs-client | nfs客户端 |
安装nfs服务
# 安装nfs必须先安装rpc
yum -y install rpcbind
# 安装nfs服务
yum -y install nfs-utils
[root@localhost ~]# yum -y install rpcbind
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 rpcbind.x86_64.0.0.2.0-32.el7 将被 安装
--> 正在处理依赖关系 libtirpc.so.1()(64bit),它被软件包 rpcbind-0.2.0-32.el7.x86_64 需要
--> 正在检查事务
---> 软件包 libtirpc.x86_64.0.0.2.4-0.6.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
====================================================================================
Package 架构 版本 源 大小
====================================================================================
正在安装:
rpcbind x86_64 0.2.0-32.el7 centos7 57 k
为依赖而安装:
libtirpc x86_64 0.2.4-0.6.el7 centos7 85 k
事务概要
====================================================================================
安装 1 软件包 (+1 依赖软件包)
总下载量:142 k
安装大小:271 k
Downloading packages:
------------------------------------------------------------------------------------
总计 528 kB/s | 142 kB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : libtirpc-0.2.4-0.6.el7.x86_64 1/2
正在安装 : rpcbind-0.2.0-32.el7.x86_64 2/2
验证中 : rpcbind-0.2.0-32.el7.x86_64 1/2
验证中 : libtirpc-0.2.4-0.6.el7.x86_64 2/2
已安装:
rpcbind.x86_64 0:0.2.0-32.el7
作为依赖被安装:
libtirpc.x86_64 0:0.2.4-0.6.el7
完毕!
[root@localhost ~]# yum -y install nfs-utils
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 nfs-utils.x86_64.1.1.3.0-0.21.el7 将被 安装
--> 正在处理依赖关系 gssproxy >= 0.3.0-0,它被软件包 1:nfs-utils-1.3.0-0.21.el7.x86_64 需要
--> 正在处理依赖关系 quota,它被软件包 1:nfs-utils-1.3.0-0.21.el7.x86_64 需要
--> 正在处理依赖关系 libnfsidmap,它被软件包 1:nfs-utils-1.3.0-0.21.el7.x86_64 需要
--> 正在处理依赖关系 libevent,它被软件包 1:nfs-utils-1.3.0-0.21.el7.x86_64 需要
--> 正在处理依赖关系 keyutils,它被软件包 1:nfs-utils-1.3.0-0.21.el7.x86_64 需要
--> 正在处理依赖关系 libnfsidmap.so.0()(64bit),它被软件包 1:nfs-utils-1.3.0-0.21.el7.x86_64 需要
--> 正在处理依赖关系 libevent-2.0.so.5()(64bit),它被软件包 1:nfs-utils-1.3.0-0.21.el7.x86_64 需要
--> 正在检查事务
---> 软件包 gssproxy.x86_64.0.0.4.1-7.el7 将被 安装
--> 正在处理依赖关系 libverto-tevent,它被软件包 gssproxy-0.4.1-7.el7.x86_64 需要
--> 正在处理依赖关系 libini_config.so.3(INI_CONFIG_1.1.0)(64bit),它被软件包 gssproxy-0.4.1-7.el7.x86_64 需要
--> 正在处理依赖关系 libref_array.so.1()(64bit),它被软件包 gssproxy-0.4.1-7.el7.x86_64 需要
--> 正在处理依赖关系 libini_config.so.3()(64bit),它被软件包 gssproxy-0.4.1-7.el7.x86_64 需要
--> 正在处理依赖关系 libcollection.so.2()(64bit),它被软件包 gssproxy-0.4.1-7.el7.x86_64 需要
--> 正在处理依赖关系 libbasicobjects.so.0()(64bit),它被软件包 gssproxy-0.4.1-7.el7.x86_64 需要
---> 软件包 keyutils.x86_64.0.1.5.8-3.el7 将被 安装
---> 软件包 libevent.x86_64.0.2.0.21-4.el7 将被 安装
---> 软件包 libnfsidmap.x86_64.0.0.25-12.el7 将被 安装
---> 软件包 quota.x86_64.1.4.01-11.el7 将被 安装
--> 正在处理依赖关系 quota-nls = 1:4.01-11.el7,它被软件包 1:quota-4.01-11.el7.x86_64 需要
--> 正在处理依赖关系 tcp_wrappers,它被软件包 1:quota-4.01-11.el7.x86_64 需要
--> 正在检查事务
---> 软件包 libbasicobjects.x86_64.0.0.1.1-25.el7 将被 安装
---> 软件包 libcollection.x86_64.0.0.6.2-25.el7 将被 安装
---> 软件包 libini_config.x86_64.0.1.2.0-25.el7 将被 安装
--> 正在处理依赖关系 libpath_utils.so.1(PATH_UTILS_0.2.1)(64bit),它被软件包 libini_config-1.2.0-25.el7.x86_64 需要
--> 正在处理依赖关系 libpath_utils.so.1()(64bit),它被软件包 libini_config-1.2.0-25.el7.x86_64 需要
---> 软件包 libref_array.x86_64.0.0.1.5-25.el7 将被 安装
---> 软件包 libverto-tevent.x86_64.0.0.2.5-4.el7 将被 安装
---> 软件包 quota-nls.noarch.1.4.01-11.el7 将被 安装
---> 软件包 tcp_wrappers.x86_64.0.7.6-77.el7 将被 安装
--> 正在检查事务
---> 软件包 libpath_utils.x86_64.0.0.2.1-25.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
===========================================================================================================================================================================================
Package 架构 版本 源 大小
===========================================================================================================================================================================================
正在安装:
nfs-utils x86_64 1:1.3.0-0.21.el7 centos7 370 k
为依赖而安装:
gssproxy x86_64 0.4.1-7.el7 centos7 84 k
keyutils x86_64 1.5.8-3.el7 centos7 54 k
libbasicobjects x86_64 0.1.1-25.el7 centos7 24 k
libcollection x86_64 0.6.2-25.el7 centos7 40 k
libevent x86_64 2.0.21-4.el7 centos7 214 k
libini_config x86_64 1.2.0-25.el7 centos7 59 k
libnfsidmap x86_64 0.25-12.el7 centos7 46 k
libpath_utils x86_64 0.2.1-25.el7 centos7 27 k
libref_array x86_64 0.1.5-25.el7 centos7 26 k
libverto-tevent x86_64 0.2.5-4.el7 centos7 9.0 k
quota x86_64 1:4.01-11.el7 centos7 176 k
quota-nls noarch 1:4.01-11.el7 centos7 89 k
tcp_wrappers x86_64 7.6-77.el7 centos7 78 k
事务概要
===========================================================================================================================================================================================
安装 1 软件包 (+13 依赖软件包)
总下载量:1.3 M
安装大小:3.9 M
Downloading packages:
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计 5.6 MB/s | 1.3 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : libbasicobjects-0.1.1-25.el7.x86_64 1/14
正在安装 : libref_array-0.1.5-25.el7.x86_64 2/14
正在安装 : libcollection-0.6.2-25.el7.x86_64 3/14
正在安装 : libnfsidmap-0.25-12.el7.x86_64 4/14
正在安装 : 1:quota-nls-4.01-11.el7.noarch 5/14
正在安装 : keyutils-1.5.8-3.el7.x86_64 6/14
正在安装 : libevent-2.0.21-4.el7.x86_64 7/14
正在安装 : libpath_utils-0.2.1-25.el7.x86_64 8/14
正在安装 : libini_config-1.2.0-25.el7.x86_64 9/14
正在安装 : libverto-tevent-0.2.5-4.el7.x86_64 10/14
正在安装 : gssproxy-0.4.1-7.el7.x86_64 11/14
正在安装 : tcp_wrappers-7.6-77.el7.x86_64 12/14
正在安装 : 1:quota-4.01-11.el7.x86_64 13/14
正在安装 : 1:nfs-utils-1.3.0-0.21.el7.x86_64 14/14
验证中 : libini_config-1.2.0-25.el7.x86_64 1/14
验证中 : tcp_wrappers-7.6-77.el7.x86_64 2/14
验证中 : libverto-tevent-0.2.5-4.el7.x86_64 3/14
验证中 : libcollection-0.6.2-25.el7.x86_64 4/14
验证中 : 1:nfs-utils-1.3.0-0.21.el7.x86_64 5/14
验证中 : libpath_utils-0.2.1-25.el7.x86_64 6/14
验证中 : libevent-2.0.21-4.el7.x86_64 7/14
验证中 : keyutils-1.5.8-3.el7.x86_64 8/14
验证中 : libref_array-0.1.5-25.el7.x86_64 9/14
验证中 : gssproxy-0.4.1-7.el7.x86_64 10/14
验证中 : 1:quota-nls-4.01-11.el7.noarch 11/14
验证中 : 1:quota-4.01-11.el7.x86_64 12/14
验证中 : libbasicobjects-0.1.1-25.el7.x86_64 13/14
验证中 : libnfsidmap-0.25-12.el7.x86_64 14/14
已安装:
nfs-utils.x86_64 1:1.3.0-0.21.el7
作为依赖被安装:
gssproxy.x86_64 0:0.4.1-7.el7 keyutils.x86_64 0:1.5.8-3.el7 libbasicobjects.x86_64 0:0.1.1-25.el7 libcollection.x86_64 0:0.6.2-25.el7 libevent.x86_64 0:2.0.21-4.el7
libini_config.x86_64 0:1.2.0-25.el7 libnfsidmap.x86_64 0:0.25-12.el7 libpath_utils.x86_64 0:0.2.1-25.el7 libref_array.x86_64 0:0.1.5-25.el7 libverto-tevent.x86_64 0:0.2.5-4.el7
quota.x86_64 1:4.01-11.el7 quota-nls.noarch 1:4.01-11.el7 tcp_wrappers.x86_64 0:7.6-77.el7
完毕!
nfs服务使用
# 创建一个共享目录
mkdir /mnt/test
# 编辑nfs配置文件
vi /etc/exports
# 添加以下内容
# /mnt/test 192.168.200.10/24(rw)
# 生效配置
exportfs -r
# server段启动nfs
systemctl start rpcbind
systemctl start nfs
# server段查看可挂载目录
showmount -e 192.168.200.10
# 客户端挂载(*最好防火墙都关掉,客户端开启nfs,记得先开启rpc)
systemctl stop firewalld *(服务端)
mount -t nfs 192.168.200.10:/mnt/test /mnt
# 检查挂载
df -h
服务端
客户端
验证nfs共享存储
# 在服务端 /mnt/test 下新建aaa.txt测试文件
touch /mnt/test/aaa.txt
# 客户端检测
# 在客户端的 /mnt/
服务端
客户端