1.服务端安装NFS
[root@192 ~]# yum -y install nfs-utils
CentOS-8.5.2111 - Base - mirrors.aliyun.com 57 kB/s | 3.9 kB 00:00
CentOS-8.5.2111 - Extras - mirrors.aliyun.com 33 kB/s | 1.5 kB 00:00
CentOS-8.5.2111 - AppStream - mirrors.aliyun.com 206 kB/s | 4.3 kB 00:00
Extra Packages for Enterprise Linux 8 - x86_64 40 kB/s | 4.7 kB 00:00
Extra Packages for Enterprise Linux 8 - x86_64 3.0 MB/s | 13 MB 00:04
Dependencies resolved.
=======================================================================================
Package Architecture Version Repository Size
=======================================================================================
Installing:
nfs-utils x86_64 1:2.3.3-46.el8 base 500 k
Installing dependencies:
gssproxy x86_64 0.8.0-19.el8 base 119 k
keyutils x86_64 1.5.10-9.el8 base 66 k
libverto-libevent x86_64 0.3.0-5.el8 base 16 k
python3-pyyaml x86_64 3.12-12.el8 base 193 k
quota x86_64 1:4.04-14.el8 base 214 k
quota-nls noarch 1:4.04-14.el8 base 95 k
rpcbind x86_64 1.2.5-8.el8 base 70 k
Downgrading:
libverto x86_64 0.3.0-5.el8 base 24 k
Transaction Summary
=======================================================================================
Install 8 Packages
Downgrade 1 Package
Total download size: 1.3 M
Downloading Packages:
(1/9): keyutils-1.5.10-9.el8.x86_64.rpm 1.1 MB/s | 66 kB 00:00
(2/9): libverto-libevent-0.3.0-5.el8.x86_64.rpm 664 kB/s | 16 kB 00:00
(3/9): gssproxy-0.8.0-19.el8.x86_64.rpm 1.0 MB/s | 119 kB 00:00
(4/9): libverto-0.3.0-5.el8.x86_64.rpm 113 kB/s | 24 kB 00:00
(5/9): python3-pyyaml-3.12-12.el8.x86_64.rpm 1.4 MB/s | 193 kB 00:00
(6/9): quota-nls-4.04-14.el8.noarch.rpm 1.5 MB/s | 95 kB 00:00
(7/9): quota-4.04-14.el8.x86_64.rpm 1.7 MB/s | 214 kB 00:00
(8/9): nfs-utils-2.3.3-46.el8.x86_64.rpm 1.8 MB/s | 500 kB 00:00
(9/9): rpcbind-1.2.5-8.el8.x86_64.rpm 799 kB/s | 70 kB 00:00
---------------------------------------------------------------------------------------
Total 3.2 MB/s | 1.3 MB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Downgrading : libverto-0.3.0-5.el8.x86_64 1/10
Installing : libverto-libevent-0.3.0-5.el8.x86_64 2/10
Installing : gssproxy-0.8.0-19.el8.x86_64 3/10
Running scriptlet: gssproxy-0.8.0-19.el8.x86_64 3/10
Running scriptlet: rpcbind-1.2.5-8.el8.x86_64 4/10
Installing : rpcbind-1.2.5-8.el8.x86_64 4/10
Running scriptlet: rpcbind-1.2.5-8.el8.x86_64 4/10
Installing : quota-nls-1:4.04-14.el8.noarch 5/10
Installing : quota-1:4.04-14.el8.x86_64 6/10
Installing : python3-pyyaml-3.12-12.el8.x86_64 7/10
Installing : keyutils-1.5.10-9.el8.x86_64 8/10
Running scriptlet: nfs-utils-1:2.3.3-46.el8.x86_64 9/10
Installing : nfs-utils-1:2.3.3-46.el8.x86_64 9/10
Running scriptlet: nfs-utils-1:2.3.3-46.el8.x86_64 9/10
Cleanup : libverto-0.3.2-2.el8.x86_64 10/10
Running scriptlet: libverto-0.3.2-2.el8.x86_64 10/10
[/usr/lib/tmpfiles.d/httpd.conf:1] Unknown group 'apache'.
[/usr/lib/tmpfiles.d/httpd.conf:2] Unknown user 'apache'.
warning: %transfiletriggerin(systemd-239-69.el8.x86_64) scriptlet failed, exit status 65
Error in <unknown> scriptlet in rpm package libverto
Verifying : libverto-0.3.0-5.el8.x86_64 1/10
Verifying : libverto-0.3.2-2.el8.x86_64 2/10
Verifying : gssproxy-0.8.0-19.el8.x86_64 3/10
Verifying : keyutils-1.5.10-9.el8.x86_64 4/10
Verifying : libverto-libevent-0.3.0-5.el8.x86_64 5/10
Verifying : nfs-utils-1:2.3.3-46.el8.x86_64 6/10
Verifying : python3-pyyaml-3.12-12.el8.x86_64 7/10
Verifying : quota-1:4.04-14.el8.x86_64 8/10
Verifying : quota-nls-1:4.04-14.el8.noarch 9/10
Verifying : rpcbind-1.2.5-8.el8.x86_64 10/10
Downgraded:
libverto-0.3.0-5.el8.x86_64
Installed:
gssproxy-0.8.0-19.el8.x86_64 keyutils-1.5.10-9.el8.x86_64
libverto-libevent-0.3.0-5.el8.x86_64 nfs-utils-1:2.3.3-46.el8.x86_64
python3-pyyaml-3.12-12.el8.x86_64 quota-1:4.04-14.el8.x86_64
quota-nls-1:4.04-14.el8.noarch rpcbind-1.2.5-8.el8.x86_64
Complete!
2.创建目录,共享文件
[root@192 ~]# mkdir /nfs
[root@192 ~]# ls /nfs
[root@192 ~]# vi /etc/exports
[root@192 ~]# cat /etc/exports
该文件权限为能读能写
/nfs 192.168.154.128
启动服务
[root@192 ~]# systemctl enable --now nfs-server
Created symlink /etc/systemd/system/multi-user.target.wants/nfs-server.service → /usr/lib/systemd/system/nfs-server.service.
rpcbind已经启动
[root@nfsserver ~]# systemctl status rpcbind
● rpcbind.service - RPC Bind
Loaded: loaded (/usr/lib/systemd/system/rpcbind.service; enabled;>
Active: active (running) since Fri 2022-12-23 07:52:35 CST; 1min >
Docs: man:rpcbind(8)
Main PID: 22841 (rpcbind)
Tasks: 1 (limit: 5790)
Memory: 1.5M
CGroup: /system.slice/rpcbind.service
└─22841 /usr/bin/rpcbind -w -f
客户端安装nfs服务器
[root@nfsserver yum.repos.d]# yum -y install nfs-utils
Last metadata expiration check: 0:04:51 ago on Fri 23 Dec 2022 07:38:14 AM CST.
Dependencies resolved.
=====================================================================
Package Arch Version Repo Size
=====================================================================
Installing:
nfs-utils x86_64 1:2.3.3-46.el8 baseos 500 k
Installing dependencies:
gssproxy x86_64 0.8.0-19.el8 baseos 119 k
keyutils x86_64 1.5.10-9.el8 baseos 66 k
libverto-libevent x86_64 0.3.0-5.el8 baseos 16 k
python3-pyyaml x86_64 3.12-12.el8 baseos 193 k
quota x86_64 1:4.04-14.el8 baseos 214 k
quota-nls noarch 1:4.04-14.el8 baseos 95 k
rpcbind x86_64 1.2.5-8.el8 baseos 70 k
Transaction Summary
=====================================================================
Install 8 Packages
Total download size: 1.2 M
Installed size: 3.8 M
Downloading Packages:
(1/8): keyutils-1.5.10-9.el8.x86_64. 113 kB/s | 66 kB 00:00
(2/8): gssproxy-0.8.0-19.el8.x86_64. 178 kB/s | 119 kB 00:00
(3/8): python3-pyyaml-3.12-12.el8.x8 785 kB/s | 193 kB 00:00
(4/8): nfs-utils-2.3.3-46.el8.x86_64 1.1 MB/s | 500 kB 00:00
(5/8): quota-4.04-14.el8.x86_64.rpm 1.0 MB/s | 214 kB 00:00
(6/8): quota-nls-4.04-14.el8.noarch. 570 kB/s | 95 kB 00:00
(7/8): rpcbind-1.2.5-8.el8.x86_64.rp 542 kB/s | 70 kB 00:00
(8/8): libverto-libevent-0.3.0-5.el8 13 kB/s | 16 kB 00:01
---------------------------------------------------------------------
Total 1.0 MB/s | 1.2 MB 00:01
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: rpcbind-1.2.5-8.el8.x86_64 1/8
Installing : rpcbind-1.2.5-8.el8.x86_64 1/8
Running scriptlet: rpcbind-1.2.5-8.el8.x86_64 1/8
Installing : quota-nls-1:4.04-14.el8.noarch 2/8
Installing : quota-1:4.04-14.el8.x86_64 3/8
Installing : python3-pyyaml-3.12-12.el8.x86_64 4/8
Installing : libverto-libevent-0.3.0-5.el8.x86_64 5/8
Installing : gssproxy-0.8.0-19.el8.x86_64 6/8
Running scriptlet: gssproxy-0.8.0-19.el8.x86_64 6/8
Installing : keyutils-1.5.10-9.el8.x86_64 7/8
Running scriptlet: nfs-utils-1:2.3.3-46.el8.x86_64 8/8
Installing : nfs-utils-1:2.3.3-46.el8.x86_64 8/8
Running scriptlet: nfs-utils-1:2.3.3-46.el8.x86_64 8/8
Verifying : gssproxy-0.8.0-19.el8.x86_64 1/8
Verifying : keyutils-1.5.10-9.el8.x86_64 2/8
Verifying : libverto-libevent-0.3.0-5.el8.x86_64 3/8
Verifying : nfs-utils-1:2.3.3-46.el8.x86_64 4/8
Verifying : python3-pyyaml-3.12-12.el8.x86_64 5/8
Verifying : quota-1:4.04-14.el8.x86_64 6/8
Verifying : quota-nls-1:4.04-14.el8.noarch 7/8
Verifying : rpcbind-1.2.5-8.el8.x86_64 8/8
Installed:
gssproxy-0.8.0-19.el8.x86_64
keyutils-1.5.10-9.el8.x86_64
libverto-libevent-0.3.0-5.el8.x86_64
nfs-utils-1:2.3.3-46.el8.x86_64
python3-pyyaml-3.12-12.el8.x86_64
quota-1:4.04-14.el8.x86_64
quota-nls-1:4.04-14.el8.noarch
rpcbind-1.2.5-8.el8.x86_64
Complete!
ps:客户端不用启用其服务,不用配置文件
关闭防火墙
[root@192 ~]# systemctl stop firewalld
[root@192 ~]# setenforce 0
客户端查看能否使用
[root@192 ~]# showmount -e 192.168.154.129
Export list for 192.168.154.129:
/nfs 192.168.154.128
客户端挂载
[root@192 ~]# mount -t nfs 192.168.154.129:/nfs /media/
[root@192 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 453M 0 453M 0% /dev
tmpfs 472M 0 472M 0% /dev/shm
tmpfs 472M 6.6M 465M 2% /run
tmpfs 472M 0 472M 0% /sys/fs/cgroup
/dev/mapper/cl-root 17G 1.8G 16G 11% /
/dev/sda1 1014M 226M 789M 23% /boot
tmpfs 95M 0 95M 0% /run/user/0
192.168.154.129:/nfs 17G 1.8G 16G 11% /media
查看创建的文件
[root@192 ~]# cd /media/
[root@192 media]# ls
[root@192 media]# touch abc
[root@192 media]# ll
total 0
-rw-r--r--. 1 nobody nobody 0 Dec 23 08:23 abc