做图专业软件下载网站,百度网站的目标,wordpress 上传视频,建设网站实训收获RHCE NFS 1.11. 2 NFS 主机名格式1.3 NFS 服务器配置1.3.1 /etc/exports 配置文件1.3.1.1 导出条目1.3.1.2 默认选项1.3.1.3 默认和覆盖选项 1.4 启动 NFS 服务器1.5 练习1.5.1 配置 NFS 服务器和客户端挂载1.5.2 配置autofs自动挂载#xff08;需要时才挂载#xff09; 1.6 … RHCE NFS 1.11. 2 NFS 主机名格式1.3 NFS 服务器配置1.3.1 /etc/exports 配置文件1.3.1.1 导出条目1.3.1.2 默认选项1.3.1.3 默认和覆盖选项 1.4 启动 NFS 服务器1.5 练习1.5.1 配置 NFS 服务器和客户端挂载1.5.2 配置autofs自动挂载需要时才挂载 1.6 废弃实验 linux 到 linux 之间的东西 不需要安装软件包系统系统自己支持 挂载 mount vim 编辑文件 1.1
1. 2 NFS 主机名格式
在挂载或导出 NFS 共享时用来指定主机的不同格式
使用以下格式指定主机
单台机器 以下任意一种完全限定域名可由服务器解析主机名可由服务器解析IP 地址。IP网络 以下格式之一有效 a.b.c.d/z 其中 a.b.c.d 是网络 z 是子网掩码中的位数例如 192.168.0.0/24 。 a.b.c.d/netmask 其中 a.b.c.d 是网络 netmask 是子网掩码例如 192.168.100.8/255.255.255.0 。
1.3 NFS 服务器配置
在 NFS 服务器中配置导出的语法和选项
手动编辑 /etc/exports 配置文件在命令行上使用 exportfs 工具
1.3.1 /etc/exports 配置文件 /etc/exports 文件控制哪些文件系统被导出到远程主机并指定选项 空白行将被忽略。要添加注释以井号(#)开始一行。可以使用反斜杠\换行长行。每个导出的文件系统都应该独立。所有在导出的文件系统后放置的授权主机列表都必须用空格分开。每个主机的选项必须在主机标识符后直接放在括号中没有空格分离主机和第一个括号。
1.3.1.1 导出条目
导出的文件系统的每个条目都有以下结构export host(options) 没有空格 可以指定多个主机以及每个主机的特定选项。
主机之间空格分开
export host1(options1) host2(options2) host3(options3)export: 导出的目录 主机: 导出要共享的主机或网络 选项: 用于主机的选项(共享的时候有些特殊的选项自己写) 示例一个简单的 /etc/exports 文件
/exported/directory bob.example.comexport 主机host (option)
目录/exported/directory导出给bob.example.com主机没有选项按默认选项1.3.1.2 默认选项
导出条目的默认选项有
ro 导出的文件系统是只读的。远程主机无法更改文件系统中共享的数据。要允许主机更改文件系统 即读写指定 rw 选项。sync同步的 在将之前的请求所做的更改写入磁盘前NFS 服务器不会回复请求。要启用异步写请指定 async 选项。异步建议用同步wdelay 如果 NFS 服务器预期另外一个写入请求即将发生则 NFS 服务器会延迟写入磁盘。这可以提高性能因为它可减少不同的写命令访问磁盘的次数从而减少写开销。要禁用此功能请指定 no_wdelay 选项该选项仅在指定了默认 sync 选项时才可用。root_squash 这可以防止远程连接的 root 用户与本地连接相反具有 root 特权相反NFS 服务器为他们分 配用户 ID nobody 。这可以有效地将远程 root 用户的权限挤压成最低的本地用户从而防止在远程服务器上可能的未经授权的写操作。要禁用 root 挤压请指定 no_root_squash 选项。要挤压每个远程用户包括 root 用户请使用 all_squash 选项。要指定 NFS 服务器应该分配给来自特定主机的远程用户的用户和组 ID请分别使用 anonuid 和 anongid 选项如下所示export host(anonuiduid,anongidgid) 这里uid 和 gid 分别是用户 ID 号和组 ID 号。 anonuid 和 anongid 选项允许您为要共享的远程 NFS 用户创建特殊的用户和组帐户。
一台主机host1IP192.168.74.128
[roothost1 ~]# vim /etc/exports
[rootlocalhost ~]# cat /etc/exports
/nfs *(rw)
导出的文件系统 *表示任意主机 rw 读写 [roothost3 ~]# showmount -e 192.168.74.128 #查看主机1的导出
#没法收到对方RPC的消息
clnt_create: RPC: Unable to receive
#对方主机要放行防火墙[roothost1 ~]# systemctl status firewalld #查看防火墙
[roothost1 ~]# systemctl stop firewalld #关闭防火墙[roothost3 ~]# showmount -e 192.168.74.128
clnt_create: RPC: Program not registered #程序未注册
systemctl start nfs-server#对方没有启动nfs服务[roothost3 ~]# systemctl status nfs-server #查看nfs服务状态
○ nfs-server.service - NFS server and servicesLoaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled; preset: disabled)Active: inactive (dead)
[roothost1 ~]# systemctl start nfs-server #启动nfs服务[roothost3 ~]# showmount -e 192.168.74.128
Export list for 192.168.74.128:
/nfs *[roothost1 ~]# ll /nfs
ls: cannot access /nfs: No such file or directory
[roothost1 ~]# mkdir /nfs
[roothost1 ~]# exportfs -r # 重新加载/etc/exports 文件[roothost3 ~]# showmount -e 192.168.74.另一台主机IP
Export list for 192.168.74.128:
/nfs *
对面导出来的文件系统host1 匹配的客户端[roothost3 ~]# ll /mnt
total 0
drwxr-xr-x. 2 root root 6 Nov 27 22:57 hgfs
[roothost3 ~]# mount 192.168.74.128:/nfs /mnt
[roothost3 ~]# df -h /mnt
Filesystem Size Used Avail Use% Mounted on
192.168.74.128:/nfs 26G 4.5G 22G 18% /mnt[roothost3 ~]# ll /mnt
total 0
[roothost3 ~]# touch /mnt/roottest
touch: cannot touch /mnt/roottest: Permission denied #无权限作为root账号权限被拒绝[roothost1 ~]# ll /nfs -d
drwxr-xr-x. 2 root root 6 Nov 17 10:19 /nfs #root账户对这个目录有写的权限
在本地是有的在网络上面的其他主机上面的root是没有权限写的
因为nfs自动的将其他主机的root用户换成了另外的账号叫nobody
[roothost1 ~]# id nobody
uid65534(nobody) gid65534(nobody) groups65534(nobody
#65534(nobody)很大65535是最大值
#所以nobody对/nfs没有写的权限[roothost1 ~]# chmod ow /nfs
[roothost1 ~]# ll /nfs -d
drwxr-xrwx. 2 root root 6 Nov 27 10:18 /nfs
#加的权限rw[roothost3 ~]# touch /mnt/roottest #成功创建[roothost1 ~]# ll /nfs
total 0
-rw-r--r--. 1 nobody nobody 0 Nov 27 10:30 roottest
#默认会把 root 用户创建的文件的所有者和所属组转换 nobody (也就是uid、gid 为 65534的用户 ) 主机3的root账号在/mnt挂载底下写的东西在主机1上会被自动转换成nobody
为什么转换
因为主机2是root账号写的文件如果不转换的话在主机1看的时候也是root
在主机1看主机2写的文件仍然是root但此文件不是主机1写的
另一台主机host3IP192.168.74.130
[roothost3 ~]# showmount -e 192.168.74.128 #查看主机1的导出
#没法收到对方RPC的消息
clnt_create: RPC: Unable to receive
#对方主机要放行防火墙[roothost3 ~]# showmount -e 192.168.74.128
clnt_create: RPC: Program not registered #程序未注册
systemctl start nfs-server#对方没有启动nfs服务[roothost3 ~]# showmount 192.168.74.另一台主机IP
host on 192.168.74.另一台主机IP无内容无意义exportfs -r
[roothost3 ~]# showmount -e 192.168.74.另一台主机IP
Export list for 192.168.74.128:
/nfs *
对面导出来的文件系统host1 匹配的客户端[roothost3 ~]# ll /mnt
total 0
drwxr-xr-x. 2 root root 6 Nov 27 22:57 hgfs
[roothost3 ~]# mount 192.168.74.128:/nfs /mnt #挂载主机1的nfs导出[roothost3 ~]# df -h /mnt
Filesystem Size Used Avail Use% Mounted on
192.168.74.128:/nfs 26G 4.5G 22G 18% /mnt[roothost3 ~]# ll /mnt
total 0
[roothost3 ~]# touch /mnt/roottest
touch: cannot touch /mnt/roottest: Permission denied #无权限作为root账号权限被拒绝
在本地是有的在网络上面的其他主机上面的root是没有权限写的
因为nfs自动的将其他主机的root用户换成了另外的账号叫nobody
# 原因
#65534(nobody)很大65535是最大值
#所以nobody对/nfs没有写的权限[roothost3 ~]# touch /mnt/roottest #成功创建主机3的root账号在/mnt挂载底下写的东西在主机1上会被自动转换成nobody 为什么转换 因为主机2是root账号写的文件如果不转换的话在主机1看的时候也是root 在主机1看主机2写的文件仍然是root但此文件不是主机1写的 主机1分享一个nfs的目录在这个目录里面写文件的时候由其他任意主机写 其他任意主机上面的root账号在/mnt这个目录底下写东西的时候刚开始时没有权限Permission denied 因为主机1在写文件的时候会被/nfs文件系统自动转换为nobody这个账号nobody这个账号对于/nfs这个目录来讲没有权限所以需要赋予权限chcon ow /nfs然后就可以写这个文件touch /mnt/roottestroottest这个文件的所属者所属组都是nobody 主机1
[roothost1 ~]# systemctl restart firewalld #启动防火墙[roothost1 ~]# firewall-cmd --permanent --add-service nfs #只需放行nfs即可查看内容NFSv4版本
[roothost1 ~]# firewall-cmd --reload #重新载入防火墙配置[roothost1 ~]# ll /nfs
total 0
-rw-r--r--. 1 nobody nobody 0 Nov 17 10:28 roottest
-rw-r--r--. 1 nobody nobody 0 Nov 17 10:58 xixitest主机2
[roothost2 ~]# df -h /mnt
命令输入后无输出[roothost2 ~]# df -h /mnt
192.168.197.主机1IP:/nfs 44G 4.7G 39G 11% /mnt
能正常刷新出信息[roothost2 ~]# touch /mnt/xixitest
[roothost2 ~]# ll /mnt
total 0
-rw-r--r--. 1 nobody nobody 0 Nov 17 10:28 roottest
-rw-r--r--. 1 nobody nobody 0 Nov 17 10:58 xixitest1.3.1.3 默认和覆盖选项
每个导出的文件系统的默认值都必须被显式覆盖。 例如如果没有指定 rw 选项则导出的文件系统将以只读形式共享。以下是 /etc/exports 中的示例行其覆盖两个默认选项 /another/exported/directory 192.168.0.3(rw,async)
在此示例中 192.168.0.3 可以以读写形式挂载 /another/exported/directory/ 并且所有对磁盘的写入都是异步的。
1.4 启动 NFS 服务器
启动 NFS 服务器并使其在引导时自动启动
# systemctl enable --now nfs-server配置 NFSv4 服务器以在防火墙后面运行
firewall-cmd --permanent --add-service nfs #配置防火墙
firewall-cmd --reload #重新载入防火墙配置
systemctl restart nfs-server # 重启 nfs-server 主机1
[roothost1 ~]# systemctl restart firewalld #启动防火墙[roothost1 ~]# firewall-cmd --permanent --add-service nfs #只需放行nfs即可查看内容NFSv4版本
[roothost1 ~]# firewall-cmd --reload #重新载入防火墙配置[roothost1 ~]# ll /nfs
total 0
-rw-r--r--. 1 nobody nobody 0 Nov 17 10:28 roottest
-rw-r--r--. 1 nobody nobody 0 Nov 17 10:58 xixitest主机2
[roothost2 ~]# df -h /mnt
命令输入后无输出[roothost2 ~]# df -h /mnt
192.168.197.主机1IP:/nfs 44G 4.7G 39G 11% /mnt
能正常刷新出信息[roothost2 ~]# touch /mnt/xixitest
[roothost2 ~]# ll /mnt
total 0
-rw-r--r--. 1 nobody nobody 0 Nov 17 10:28 roottest
-rw-r--r--. 1 nobody nobody 0 Nov 17 10:58 xixitestNFSv3版本还要放行这两个命令
firewall-cmd --permanent --add-servicerpc-bind --add-servicemountd1.5 练习
1.5.1 配置 NFS 服务器和客户端挂载
一台主机host1IP192.168.74.128
[roothost1 ~]# vim /etc/exports
[rootlocalhost ~]# cat /etc/exports
/nfs *(rw)
导出的文件系统 *表示任意主机 rw 读写 [roothost3 ~]# showmount -e 192.168.74.128 #查看主机1的导出
#没法收到对方RPC的消息
clnt_create: RPC: Unable to receive
#对方主机要放行防火墙[roothost1 ~]# systemctl status firewalld #查看防火墙
[roothost1 ~]# systemctl stop firewalld #关闭防火墙[roothost3 ~]# showmount -e 192.168.74.128
clnt_create: RPC: Program not registered #程序未注册
systemctl start nfs-server#对方没有启动nfs服务[roothost3 ~]# systemctl status nfs-server #查看nfs服务状态
○ nfs-server.service - NFS server and servicesLoaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled; preset: disabled)Active: inactive (dead)
[roothost1 ~]# systemctl start nfs-server #启动nfs服务[roothost3 ~]# showmount -e 192.168.74.128
Export list for 192.168.74.128:
/nfs *[roothost1 ~]# ll /nfs
ls: cannot access /nfs: No such file or directory
[roothost1 ~]# mkdir /nfs
[roothost1 ~]# exportfs -r # 重新加载/etc/exports 文件[roothost3 ~]# showmount -e 192.168.74.另一台主机IP
Export list for 192.168.74.128:
/nfs *
对面导出来的文件系统host1 匹配的客户端[roothost3 ~]# ll /mnt
total 0
drwxr-xr-x. 2 root root 6 Nov 27 22:57 hgfs
[roothost3 ~]# mount 192.168.74.128:/nfs /mnt
[roothost3 ~]# df -h /mnt
Filesystem Size Used Avail Use% Mounted on
192.168.74.128:/nfs 26G 4.5G 22G 18% /mnt[roothost3 ~]# ll /mnt
total 0
[roothost3 ~]# touch /mnt/roottest
touch: cannot touch /mnt/roottest: Permission denied #无权限作为root账号权限被拒绝[roothost1 ~]# ll /nfs -d
drwxr-xr-x. 2 root root 6 Nov 17 10:19 /nfs #root账户对这个目录有写的权限
在本地是有的在网络上面的其他主机上面的root是没有权限写的
因为nfs自动的将其他主机的root用户换成了另外的账号叫nobody
[roothost1 ~]# id nobody
uid65534(nobody) gid65534(nobody) groups65534(nobody
#65534(nobody)很大65535是最大值
#所以nobody对/nfs没有写的权限[roothost1 ~]# chmod ow /nfs
[roothost1 ~]# ll /nfs -d
drwxr-xrwx. 2 root root 6 Nov 27 10:18 /nfs
#加的权限rw[roothost3 ~]# touch /mnt/roottest #成功创建[roothost1 ~]# ll /nfs
total 0
-rw-r--r--. 1 nobody nobody 0 Nov 27 10:30 roottest
#默认会把 root 用户创建的文件的所有者和所属组转换 nobody (也就是uid、gid 为 65534的用户 ) 主机3的root账号在/mnt挂载底下写的东西在主机1上会被自动转换成nobody
为什么转换
因为主机2是root账号写的文件如果不转换的话在主机1看的时候也是root
在主机1看主机2写的文件仍然是root但此文件不是主机1写的
另一台主机host3IP192.168.74.130
[roothost3 ~]# showmount -e 192.168.74.128 #查看主机1的导出
#没法收到对方RPC的消息
clnt_create: RPC: Unable to receive
#对方主机要放行防火墙[roothost3 ~]# showmount -e 192.168.74.128
clnt_create: RPC: Program not registered #程序未注册
systemctl start nfs-server#对方没有启动nfs服务[roothost3 ~]# showmount 192.168.74.另一台主机IP
host on 192.168.74.另一台主机IP无内容无意义exportfs -r
[roothost3 ~]# showmount -e 192.168.74.另一台主机IP
Export list for 192.168.74.128:
/nfs *
对面导出来的文件系统host1 匹配的客户端[roothost3 ~]# ll /mnt
total 0
drwxr-xr-x. 2 root root 6 Nov 27 22:57 hgfs
[roothost3 ~]# mount 192.168.74.128:/nfs /mnt #挂载主机1的nfs导出[roothost3 ~]# df -h /mnt
Filesystem Size Used Avail Use% Mounted on
192.168.74.128:/nfs 26G 4.5G 22G 18% /mnt[roothost3 ~]# ll /mnt
total 0
[roothost3 ~]# touch /mnt/roottest
touch: cannot touch /mnt/roottest: Permission denied #无权限作为root账号权限被拒绝
在本地是有的在网络上面的其他主机上面的root是没有权限写的
因为nfs自动的将其他主机的root用户换成了另外的账号叫nobody
# 原因
#65534(nobody)很大65535是最大值
#所以nobody对/nfs没有写的权限[roothost3 ~]# touch /mnt/roottest #成功创建主机3的root账号在/mnt挂载底下写的东西在主机1上会被自动转换成nobody 为什么转换 因为主机2是root账号写的文件如果不转换的话在主机1看的时候也是root 在主机1看主机2写的文件仍然是root但此文件不是主机1写的 主机1分享一个nfs的目录在这个目录里面写文件的时候由其他任意主机写 其他任意主机上面的root账号在/mnt这个目录底下写东西的时候刚开始时没有权限Permission denied 因为主机1在写文件的时候会被/nfs文件系统自动转换为nobody这个账号nobody这个账号对于/nfs这个目录来讲没有权限所以需要赋予权限chcon ow /nfs然后就可以写这个文件touch /mnt/roottestroottest这个文件的所属者所属组都是nobody 主机1
[roothost1 ~]# systemctl restart firewalld #启动防火墙[roothost1 ~]# firewall-cmd --permanent --add-service nfs #只需放行nfs即可查看内容NFSv4版本
[roothost1 ~]# firewall-cmd --reload #重新载入防火墙配置[roothost1 ~]# ll /nfs
total 0
-rw-r--r--. 1 nobody nobody 0 Nov 17 10:28 roottest
-rw-r--r--. 1 nobody nobody 0 Nov 17 10:58 xixitest主机2
[roothost2 ~]# df -h /mnt
命令输入后无输出[roothost2 ~]# df -h /mnt
192.168.197.主机1IP:/nfs 44G 4.7G 39G 11% /mnt
能正常刷新出信息[roothost2 ~]# touch /mnt/xixitest
[roothost2 ~]# ll /mnt
total 0
-rw-r--r--. 1 nobody nobody 0 Nov 17 10:28 roottest
-rw-r--r--. 1 nobody nobody 0 Nov 17 10:58 xixitest开机自动挂载 /etc/fstab配置文件中自动挂载
[root141 ~]# vim /etc/fstab
192.168.74.128:/nfs /mnt/ nfs defaults 0 0挂载路径 挂载点 文件系统 挂载选项没有defaults 0 0
[root141 ~]# reboot #保存配置后重启主机
重启后挂载路径下面还有刚刚的两个文件则说明自动挂载已成功
[roothost3 ~]# df -h /mnt
Filesystem Size Used Avail Use% Mounted on
192.168.74.128:/nfs 26G 4.5G 22G 18% /mnt
[roothost3 ~]# ll /mnt
total 0
-rw-r--r--. 1 nobody nobody 0 Nov 27 23:30 roottest
-rw-r--r--. 1 nobody nobody 0 Nov 28 12:37 xixitest 将刚刚的操作清理
删除自动挂载
[roothost3 ~]# vim /etc/fstab
dd删除[roothost3 ~]# umount /mnt
[roothost3 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 1.7G 0 1.7G 0% /dev/shm
tmpfs 682M 12M 671M 2% /run
/dev/mapper/rhel-root 17G 4.5G 12G 27% /
/dev/nvme0n1p2 960M 293M 668M 31% /boot
/dev/nvme0n1p1 599M 7.0M 592M 2% /boot/efi
tmpfs 341M 56K 341M 1% /run/user/42
tmpfs 341M 40K 341M 1% /run/user/0[roothost3 ~]# ll /mnt
total 0
drwxr-xr-x. 2 root root 6 Nov 27 22:57 hgfs
/etc/rc.d/rc.local配置文件中自动挂载尽量不在这里面写
/etc/rc.d/rc.local是遗留下来的方法
[roothost3 ~]# vim /etc/rc.d/rc.local
[roothost3 ~]# chmod ax /etc/rc.d/rc.local
[roothost3 ~]# cat /etc/fstab #fstab里面没有自动挂载#
# /etc/fstab
# Created by anaconda on Wed Nov 27 14:55:48 2024
#
# Accessible filesystems, by reference, are maintained under /dev/disk/.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run systemctl daemon-reload to update systemd
# units generated from this file.
#
/dev/mapper/rhel-root / xfs defaults 0 0
UUID0e089631-01b3-4f03-8fa3-c1575ef255e5 /boot xfs defaults 0 0
UUID2F1B-C01E /boot/efi vfat umask0077,shortnamewinnt 0 2
/dev/mapper/rhel-swap none swap defaults 0 0
[roothost3 ~]# reboot[roothost3 ~]# df -h /mnt
Filesystem Size Used Avail Use% Mounted on
192.168.74.128:/nfs 26G 4.5G 22G 18% /mnt
开机自动挂载成功
[roothost3 ~]# ll /etc/rc.d/rc.local
-rwxr-xr-x. 1 root root 506 Nov 28 13:04 /etc/rc.d/rc.local
做完删除自动挂载权限也删除
[roothost3 ~]# chmod a-x /etc/rc.d/rc.local
[roothost3 ~]# ll /etc/rc.d/rc.local
-rw-r--r--. 1 root root 473 Nov 28 13:11 /etc/rc.d/rc.local 为了确保服务在开机后一定可以挂载确定自动挂载在多个地方出现则可以在fstab写了后再到/etc/rc.d/rc.local中写挂载
1.5.2 配置autofs自动挂载需要时才挂载
在一般NFS文件系统的使用过程中如果客户端要使用服务端所提供的文件系统可以在 /etc/rc.d/rc.local 中设置开机时自动挂载 /etc/rc.d/rc.local 文件中写入的命令在每次启动系统用户登录之前都会执行一次;也可以在登录系统后手动利用mount来挂载。 当客户端在有使用NFS文件系统的需求时才让系统自动挂载。 当NFS文件系统使用完毕后让NFS自动卸载。 客户端安装autofs软件
dnf install autofs -yautofs 主配置文件
ll /etc/auto.master #软件包安装完成后多了一个这个文件[roothost1 ~]# vim /etc/auto.master
/mnt/ /etc/auto.nfs
挂载地方 怎么挂载我们自己单独创建的一个文件在这个文件中写具体挂载内容
#要去把nfs服务上面导出的文件系统挂载到mnt目录#具体挂载内容
[roothost3 ~]# vim /etc/auto.nfs
[roothehe ~]# cat /etc/auto.nfs
guazai 192.168.197.136:/nfs
挂载点(目标) 挂载源挂载什么东西
#要去把nfs服务上面导出的文件系统挂载到mnt目录[roothost3 ~]# grep nfs /etc/auto.master
/mnt/ /etc/auto.nfs
#/nfs4 /usr/sbin/fedfs-map-nfs4 nobind
/mnt/ /etc/auto.nfs
检测挂载点主挂载点 具体挂载信息 [roothost3 ~]# systemctl restart autofs
[roothost3 ~]# ll /mnt
total 0
[roothost3 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 1.7G 0 1.7G 0% /dev/shm
tmpfs 682M 9.6M 673M 2% /run
/dev/mapper/rhel-root 17G 4.5G 12G 28% /
/dev/nvme0n1p2 960M 293M 668M 31% /boot
/dev/nvme0n1p1 599M 7.0M 592M 2% /boot/efi
tmpfs 341M 56K 341M 1% /run/user/42
tmpfs 341M 40K 341M 1% /run/user/0[roothost3 ~]# cd /mnt/guazai
#再查看挂载的时候就有 /mnt 了
[rootguazai ~]# df -h [rootguazai ~]# cd[roothost3 ~]# ll /mnt
total 0
drwxr-xrwx.2 rootroot 38 Nov 17 10:58 guazai
#按需要挂载重启后自动消失一般存在五分钟1.6 废弃实验
配置导出目录
[root128 ~]# mkdir /data #创建一个data文件
[root128 ~]# chmod 777 /data/
[root128 ~]# touch /data/testfile
[root128 ~]# vim /etc/exports #设置导出
[root128 ~]# cat /etc/exports
/data 192.168.115.141(rw)
指定导出到192.168.115.141配置防火墙放行规则 放行几个服务
[root128 ~]# firewall-cmd --permanent --add-servicenfs
success
[root128 ~]# firewall-cmd --permanent --add-servicemountd NFSv3
success
[root128 ~]# firewall-cmd --permanent --add-servicerpc-bind NFSv3
success
[root128 ~]# firewall-cmd --reload
success
[root128 ~]# firewall-cmd --list-services
cockpit dhcpv6-client mountd nfs rpc-bind ssh在客户端查看导出的目录
[root141 ~]# showmount -e 192.168.115.128
Export list for 192.168.115.128:
/data 192.168.115.141
[root141 ~]# mkdir /nfsclient/client-data/ -p
[root141 ~]# mount 192.168.115.128:/data /nfsclient/client-data/
[root141 ~]# df -h /nfsclient/client-data/
Filesystem Size Used Avail Use% Mounted on
192.168.115.128:/data 45G 4.5G 41G 11% /nfsclient/client-data
[root141 ~]# cd /nfsclient/client-data/
[root141 client-data]# ll
total 0
-rw-r--r--. 1 root root 0 Mar 17 16:40 testfile
[root141 client-data]# touch caicaikan
[root141 client-data]# ll
total 0
-rw-r--r--. 1 nobody nobody 0 Mar 17 17:05 caicaikan #远程root
-rw-r--r--. 1 root root 0 Mar 17 16:40 testfile #本地root