14.2 NFS服务端安装配置
时间:2022-04-27
本文章向大家介绍14.2 NFS服务端安装配置,主要内容包括NFS服务端安装配置目录概要、NFS服务端安装配置、基本概念、基础应用、原理机制和需要注意的事项等,并结合实例形式分析了其使用技巧,希望通过本文能帮助到大家理解应用这部分内容。
NFS服务端安装配置目录概要
- yum install -y nfs-utils rpcbind
- vim /etc/exports //加入如下内容
/home/nfstestdir 192.168.133.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000)
- 保存配置文件后,执行如下准备操作
- mkdir /home/nfstestdir
- chmod 777 /home/nfstestdir
- systemctl start rpcbind
- systemctl start nfs
- systemctl enable rpcbind
- systemctl enable nfs
NFS服务端安装配置
- 首先准备两台机器,我这里准备两台虚拟机,A机器IP分别为192.168.202.130,B机器IP为192.168.202.131
- A机器,查看IP
[root@hanfeng ~]# ifconfig
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.202.130 netmask 255.255.255.0 broadcast 192.168.202.255
inet6 fe80::20c:29ff:feff:458f prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:ff:45:8f txqueuelen 1000 (Ethernet)
RX packets 684 bytes 68341 (66.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 226 bytes 26200 (25.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eno16777736:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.202.150 netmask 255.255.255.0 broadcast 192.168.202.255
ether 00:0c:29:ff:45:8f txqueuelen 1000 (Ethernet)
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 8 bytes 536 (536.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 8 bytes 536 (536.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@hanfeng ~]#
- B机器,查看IP
[root@hf-01 ~]# ifconfig
ens32: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.202.131 netmask 255.255.255.0 broadcast 192.168.202.255
inet6 fe80::baa:c015:db72:1d5c prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:b6:4d:41 txqueuelen 1000 (Ethernet)
RX packets 63 bytes 7905 (7.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 79 bytes 11615 (11.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1 (Local Loopback)
RX packets 68 bytes 5524 (5.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 68 bytes 5524 (5.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@hf-01 ~]#
- 将A机器作为服务端,并安装两个包,分别为 nfs-utils 和 rpcbind
- yum install -y nfs-utils rpcbind
[root@hanfeng ~]# yum install -y nfs-utils rpcbind
- 将B机器作为客户端,安装 nfs-utils 包
- 每次刚开机运行yum的时候都会很慢,因为需要重新生成一个缓存文件
- 有时yum安装的时候很慢,我们可以先禁掉,进入到/etc/yum.repos.d/目录下,将目录下的epel.repo文件改个名字,重新安装即可
- yum install -y nfs-utils
[root@hf-01 ~]# yum install -y nfs-utils
- 在安装完成后,需要去A机器中 /etc/exports 编辑配置文件
- vim /etc/exports //加入如下内容
[root@hanfeng ~]# vim /etc/exports
/home/nfstestdir
要分享出去的目录是哪一个目录,这个目录是不存在的,后期还需要创建的
192.168.202.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000)
指定你要给哪个机器去分享这个目录,首先定义IP或IP段
保存退出
- 下面就可以启动服务了,启动服务前需要先创建目录,并设置权限
- 在A机器上创建分享的目录
[root@hanfeng ~]# mkdir /home/nfstestdir
[root@hanfeng ~]#
- 并设置成777的权限,这里设置777权限是为了方便接下里的实验
[root@hanfeng ~]# chmod 777 /home/nfstestdir
[root@hanfeng ~]#
- 启动 rpcbind ,再启动前查看A机器上监听的端口,就会看到启动了1/systemd,这是centos7系统的一个特性——>111端口是rpcbind服务监听的
- 用ps可以查看服务已经启动,因为有这个服务,所以监听了111端口
[root@hanfeng ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2172/master
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1115/sshd
tcp6 0 0 ::1:25 :::* LISTEN 2172/master
tcp6 0 0 :::3306 :::* LISTEN 2264/mysqld
tcp6 0 0 :::111 :::* LISTEN 1/systemd
tcp6 0 0 :::22 :::* LISTEN 1115/sshd
[root@hanfeng ~]# ps aux |grep rpc
rpc 2393 0.0 0.1 64964 1044 ? Ss 15:40 0:00 /sbin/rpcbind -w
root 2537 0.0 0.0 112680 972 pts/0 R+ 16:17 0:00 grep --color=auto rpc
- 再到B机器上查看下端口,会看到也启动了rpcbind
[root@hf-01 ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2393/rpcbind
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1334/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2146/master
tcp6 0 0 :::3306 :::* LISTEN 2029/mysqld
tcp6 0 0 :::111 :::* LISTEN 2393/rpcbind
tcp6 0 0 :::22 :::* LISTEN 1334/sshd
tcp6 0 0 ::1:25 :::* LISTEN 2146/master
[root@hf-01 ~]# ps aux |grep rpc
root 16644 0.0 0.0 112656 992 pts/2 R+ 04:46 0:00 grep --color=auto rpc
[root@hf-01 ~]#
- 在A机器启动了rpcbind,下面就可以启动nfs服务,在使用ps查看
- systemctl start rpcbind
[root@hanfeng ~]# systemctl start nfs
[root@hanfeng ~]# ps aux |grep nfs
root 4560 0.0 0.0 0 0 ? S< 04:52 0:00 [nfsd4]
root 4561 0.0 0.0 0 0 ? S< 04:52 0:00 [nfsd4_callbacks]
root 4565 0.0 0.0 0 0 ? S 04:52 0:00 [nfsd]
root 4566 0.0 0.0 0 0 ? S 04:52 0:00 [nfsd]
root 4567 0.0 0.0 0 0 ? S 04:52 0:00 [nfsd]
root 4568 0.0 0.0 0 0 ? S 04:52 0:00 [nfsd]
root 4569 0.0 0.0 0 0 ? S 04:52 0:00 [nfsd]
root 4570 0.0 0.0 0 0 ? S 04:52 0:00 [nfsd]
root 4571 0.0 0.0 0 0 ? S 04:52 0:00 [nfsd]
root 4572 0.0 0.0 0 0 ? S 04:52 0:00 [nfsd]
root 4576 0.0 0.0 112676 984 pts/0 R+ 04:52 0:00 grep --color=auto nfs
[root@hanfeng ~]#
- 同时也可以在A机器上ps aux |grep rpc查询,在启动nfs服务的时候,它会自动帮你启动rpc相关的一些服务
[root@hanfeng ~]# ps aux |grep rpc
rpc 2957 0.0 0.1 64908 1416 ? Ss 03:05 0:00 /sbin/rpcbind -w
rpcuser 4530 0.0 0.1 42380 1744 ? Ss 04:52 0:00 /usr/sbin/rpc.statd
root 4531 0.0 0.0 0 0 ? S< 04:52 0:00 [rpciod]
root 4539 0.0 0.0 19324 652 ? Ss 04:52 0:00 /usr/sbin/rpc.idmapd
root 4550 0.0 0.0 42556 948 ? Ss 04:52 0:00 /usr/sbin/rpc.mountd
root 4602 0.0 0.0 112676 984 pts/0 R+ 05:00 0:00 grep --color=auto rpc
[root@hanfeng ~]#
- 而在客户端B机器上是没有的这些服务的
[root@hf-01 ~]# ps aux |grep rpc
root 16644 0.0 0.0 112656 992 pts/2 R+ 04:46 0:00 grep --color=auto rpc
[root@hf-01 ~]#
- 如果想让nfs开机启动,还需要执行systemctl enable nfs 命令,在服务端A机器上调用
- systemctl enable nfs 开机启动nfs
- systemctl disable nfs 关闭开机启动
[root@hanfeng ~]# systemctl enable nfs
Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.
[root@hanfeng ~]#
- 专门攻击工资支付系统的网络犯罪
- Angularjs基础(五)
- DW Replace Open Sans:将WordPress 后台中的open-sans字体加载源从Google Fonts换为360 CDN
- Google Fonts 已可正常访问,相关插件可卸
- 微信支付宝完成这几个设置,别人偷不走你一毛钱!
- Angularjs基础(四)
- Google Fonts导致WordPress 速度问题的三个解决方案
- DW Replace Open Sans:将WordPress 后台中的open-sans字体加载源从Google Fonts换为360 CDN
- Angularjs基础(三)
- 低多边形(Low-Poly)简介及相关素材分享下载
- 开发者的福音:GenerateWP 自动生成WordPress 开发相关代码
- 自定义WordPress 密码文章提示文字
- 解决WordPress文章密码保护在首页(摘要)不起作用
- WordPress 3.9+的 TinyMCE 4 编辑器增强开发
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- 八种方法(实现两个数互换),绝了绝了!
- 当你触摸屏幕时手机都干了什么?你必须知道的Android事件传递
- 栈与队列:来看看栈和队列不为人知的一面
- 栈与队列:我用栈来实现队列怎么样?
- 栈与队列:用队列实现栈还有点别扭
- 短视频源码php,自动查找重复贴图
- 栈与队列:系统中处处都是栈的应用
- 长文慎入!大厂架构演进实战之手写 CAS 单点登录
- 栈与队列:匹配问题都是栈的强项
- SpringBoot源码学习(五)
- SpringBoot源码学习(六)
- SpringBoot源码学习(七)
- LeetCode52|有序数组中的单一元素
- LeetCode53|搜索二维矩阵II
- LeetCode54|二叉树的层次遍历