NFS共享存储服务

1.NFS(网络文件服务)

NFS 是一种基于 TCP/IP 传输的网络文件系统协议
NFS 服务的实现依赖于 RPC(Remote Process Call,远端过程调用)机制,以完成远 程到本地的映射过程。在 CentOS 7 系统中,需要安装 nfs-utils、rpcbind 软件包来提供 NFS 共享服务,前者用于 NFS 共享发布和访问,后者用于 RPC 支持。NFS端口号2049,RPC端口号111
但是,NFC没有用户认证机制,而且数据在网络上明文传输,所以安全性很差,一般只能在局域网内使用

2.配置案例

2.1 安装nfs-utils、rpcbind 软件包

[root@localhost ~]# yum -y install nfs-utils.x86_64 rpcbind.x86_64 
。。。
  nfs-utils.x86_64 1:1.3.0-0.68.el7                          rpcbind.x86_64 0:0.2.0-49.el7                         

完毕!
[root@localhost ~]# 

2.2 设置共享目录

NFS的配置文件为/etc/exports,文件内容默认为空(无任何共享)。在exports文件中的记录格式为

<目录位置>   <客户机地址>(权限选项)
[root@localhost ~]# mkdir -p /www/html    //创建共享目录
[root@localhost ~]# vi  /etc/exports    //编辑配置文件

/www/html 192.168.30.5(rw,sync,no_root_squash)    //将/www/html共享给主机192.168.30.5(允许读写,同步写入,赋予root权限)
~                                           

2.3 启动服务

[root@localhost ~]# systemctl start rpcbind   //先启动rpcbind
[root@localhost ~]# systemctl start nfs      //再启动nfs
[root@localhost ~]# netstat -anpt |grep 111   //监听rpcbind端口
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      72854/rpcbind       
tcp        0      0 192.168.30.5:22         192.168.30.254:62433    ESTABLISHED 9111/sshd: root@not 
tcp6       0      0 :::111                  :::*                    LISTEN      72854/rpcbind       
[root@localhost ~]# showmount -e    //查看本机发布的nfs共享目录
Export list for localhost.localdomain:
/www/html 192.168.30.5

2.4 客户机安装启动服务

[root@localhost ~]# systemctl start rpcbind    //先启动rpcbind
[root@localhost ~]# systemctl start nfs           //再启动nfs
[root@localhost ~]# showmount -e 192.168.30.4          //查看该服务器共享目录
Export list for 192.168.30.4:
/www/html 192.168.30.5
[root@localhost ~]# 

2.5 客户机创建挂载点并挂载共享目录

[root@localhost etc]# mount -t nfs 192.168.30.4:/www/html /var/www/html   //挂载网络节点
[root@localhost etc]# cd /var/www/html/     //进入挂载点
[root@localhost html]# ls                       //查看文件(在nfs服务器上新建的1)
1

2.6 客户机尝试创建文件

在这里插入图片描述

2.7 模拟nfs服务器挂掉

在这里插入图片描述
在这里插入图片描述

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值