36-2、NFS (网络文件服务)

NFS (网络文件服务)

NFS是一种基于TCP/IP传输的网络文件系统协议,最初由 sun公司开发。通过使用NFS协议,客户机可以像访问本地目录一样访问远程服务器中的共享资源
NFS 也是NAs 存储设备必然支持的一种协议
NAs存储:

​ NFS 服务的实现依赖于RPC ( Remote Processcall,远端过程调用)机制,以完成远程到本地的映射过程。在centos 7系统中,需要安装nfs-utils、rpcbind软件包来提供NES共享服务,前者用于NFS共享发布和访问,后者用于RPC支持。
手动加载NFS共享服务时,应该先启动rpcbind,再启动nfs。nfs瑞口号2049
RPC端口号111
特点:

采用TCP/IP传输网络文件安全性低
简单易操作
适合局域网环境
实验步骤:
安装nfs和rpcbind软件修改配置文件设置共享创建共享目录
开启服务
容广端验证共享目录可访问

具体配置

服务端

rpm -q rpcbind nfs-utils

yum install -y nfs-utils rpcbind

vim /etc/exports 配置文件NFS

/opt/web 192.168.10.0/24 (rw,sync,no_root_squash) 网段

sync 表示同步写入到内存与硬盘中

no_root_squash 表示用户以root身份访问时赋予本地root权限

如果不加,那么客户端无法在里面编辑或写入文件,默认nfsnobody

root-squash 将root用户匿名

subtree_check 检查子目录的父目录权限
创建web目录
mkdir -p /opt/web
ls /opt

netstat -anpu | grep rpc
netstat -anou|gerp nfs

systemctl start rpcbind

systemctl start nfs

systemctl enable rpcbind

systemctl enabled nfs

systemctl stop firewalld

rpcinfo -p localhost

exportfs -v 验证结果

exportfs -r 刷新结果

showmount -e localhost /本机地址 192.168.10.17 验证共享

客户端

yum install -y nfs-utils rpcbind

showmount -e 192.168.10.17 (服务器地址)

yum -y install httpd

mount -t nfs 192.168.10.17:/opt/web /var/www/html

df -h

systemctl stop firewalld

systemctl start httpd

curl 127.0.0.1 本机
浏览器访问 192.168.10.14 客户端本地IP地址

echo “this is kgc”>>/var/www.html/index.html 14机器坏了 数据还在17服务器上

cat index.html

df -TH

永久性挂载
192.168.10.17:/opt/web /var/www.html nfs defaults,_netdev(网络设备) 0 0

systemctl stop nfs

umount /var/www.html

umount -lf /var/www.html

netdev(网络设备) 0 0

systemctl stop nfs

umount /var/www.html

umount -lf /var/www.html

在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值