nfs

NFS 服务 : Network File system 网络文件系统
效果: 好像在本机硬盘一样
原理: 当用户去访问 映射成本地系统 // 原理 挂载
属性: vsftpd 是应用程序,(内核支持) nfs 是一个文件系统
应用: 局域网(最多用于) — 依赖网络

应用层 app httpd 80 vsftpd

传输层 tcp/ip
internet层 network
数据链路层

#locate ext4.ko — locate 查找文件或目录
locate nfs.ko —> nfs 是内核级别

client
|
|
VFS // 系统文件的翻译层相当于java的jvm
|
|
RPC/XDR
| |
| |
TCP/IP tcp/ip
| |
| |
Ethernet Ethernet
| |
|——————————————network———————|
NFS 服务介绍
软件包: nfs-utils
kernel 支持nfs.ko
端口:2049(nfsd) 其他端口由portmap(111) 分配
配置文件 /etc/exports /etc/exports.d/*.exports
相关软件包 rpcbind , tcp_wrappers
yum install rpcbind yum install nfs-utils
—————————————-
案例1:

#rpm -qi nfs-utils
rpm -ql nfs-utils

systemctl start nfs-server // centos7 –> centos6 nfs
ss -ntl —> 端口 2049 其他端口会变 –>
rpcinfo -p 查看 所有的端口(端口会变)

centos6————————————————
service nfs start —> 会产生随机端口
service rpcbind status –> 端口111 来管理随机端口
原理 :客户端先连接 rpcbind(客户端:请你告诉我nfs端口,rpcbind 会告诉端口) 在连接访问nfs

案例1(1): centos6
service rpcbind stop — 当rpcbind 停止了
service nfs restart — 启动就不行了
service rpcbind restart — 启动了
service nfs restart — nfs 启动了 –>总结: nfs 依赖 rpcbind 服务

案例1(2) :centos7
systemctl stop rpcbind — 停止 –> systemctl status rpcbind // 查看状态
systemctl restart nfs-server — 启动nfs-server
systemctl status rpcbind — 查看rpcbind 也启动了
总结: 当rpcbind 停止 , 启动nfs-server ,rpcbind 也跟着启动 –> 有依赖性 自动激活
—————————————-
案例1(3): centos7
systemctl status rpcbind.socket // 特性 rpcbind 和 rpcbind.socket
systemctl stop rpcbind.socket // 停止
systemctl status rpcbind // 查看rpcbind 也停止了
注意 : rpcbind 就是 rpcbind.server
systemctl start rpcbind // 启动 rpcbind
systemctl status rpcbind.socket // 也启动了

当 systemctl stop rpcbind –> systemctl status rpcbind.socket 还在运行
原理: rpcbind.socket 还在监听 ,当用户访问 会把 rpcbind.server 激活
———————————————–
总结:当 nfs.server 启动 <—- rpcbind 启动 <—– rpcbind.socket 启动 ——————- 案例1(4) centos7 showmount -e 192.168.100.6 // 查看远程主机的共享 Export list for 192.168.100.6: –> 说明有共享服务 ,没有共享 文件夹
—————
案例1(5) centos6
service rpcbind start — 启动了 service nfs start –启动 // 依赖rpcbind 服务启动
现在 service rpcbind stop 会怎么样 ? 用户访问 ?
service nfs status — 查看running
#showmount -e 192.168.100.6 //centos7 上查看远程主机的共享
clnt_create: RPC: Port mapper failure – Unable to receive: errno 111 (Connection refused) // 不可以
总结:表面上连接 的是 nfs 实际上 先连接 rpcbind (中间断层了)
1. service start rpcbind 2. service restart nfs –> showmount -e 192.168.100.6
—————————————–
案例1(6)
ps aux |grep rpc
nfs 服务主要进程 :
rpc.nfsd 最主要的NFS 进程 , 管理客户端是否可登陆
rpc.mountd 挂载和卸载NFS 文件系统 , 包括权限管理
rpc.lockd 非必要 管理文件锁 避免同时写出错
rpc.statd 非必要 检查文件一致性 可修复文件 日志: /var/lib/nfs
—————————————————
案例1(7) NFS 配置文件 *
rpm -ql nfs-utils
rpm -qf /etc/exports –> 创建共享,也可以放在 /etc/exports.d/ 的子目录下面

/etc]#ls |grep exports
exports
exports.d

本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/91451

(1)
百涧溪百涧溪
上一篇 2018-02-05 08:43
下一篇 2018-02-05 10:52

相关推荐

  • shell脚本的各种循环

    For循环 For循环格式      For   变量名  in    列表    ;   do         &nb…

    Linux干货 2016-08-21
  • SSH——安全的通信

    SSH ·ssh:secure shell, protocol, 22/tcp,  安全的远程登录 ·OpenSSH:ssh协议的开源实现 ·dropbear:另一个开源实现 ·SSH协议版本:          v1:基于CRC-32做MAC,不安全;man-in-m…

    Linux干货 2016-09-25
  • Linux基础学习总结(二)

    一、Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示。 常用基础命令:cd、pwd、mkdir、touch 查看:cat,more,less,tail,head,tac 复制:cp 移动:mv 删除:rm 创建:touch 元数据属性:stat 查看内容类型:file 二、bash的工作特性之命令执行状态返回值和命令行展开所涉及的内容及…

    Linux干货 2016-09-24
  • 【Linux基础】文件管理类命令

    总结下linux系统文件管理类的命令 mkdir -> make dirtctories 创建目录 语法:mkdir [OPTION]… DIRECTORY… 常用选项-p: 自动按需创建父目录;-v: verbose,显示详细过程;-m MODE:直接给定权限;注意:路径基名方为命令的作用对象;基名之前的路径必须得存在;示例:~]# mkdir -p…

    Linux干货 2018-03-11
  • 磁盘配额、阵列与逻辑卷

    一、磁盘配额 在内核中执行以文件系统为单位启用对不同组或者用户的策略不同 根据块或者节点进行限制执行软限制(soft limit)硬限制(hard limit) 步骤一:获得文件系统支持临时有效:mount -o remount,usrquota,grpquota {mount_point|device}永久有效:写入配置文件 /etc/fstab 中检查文…

    Linux干货 2016-08-29
  • 马哥教育网络班20期第3周课程练习

    答: 1、 [root@totooco ~]# who | cut -c1-9 | sort -u 2、 [totooco@totooco ~]$ who | cut -c1-9 | head -1 3、 [root@totooco ~]# cat /etc/passwd | cut -d: -f7 | grep -v /sbin/nologin | sor…

    Linux干货 2016-06-23