1.准备两台服务器,一台客户端,一台服务端
[root@afei ~]# hostnamectl set-hostname client
[root@afei ~]# bash
[root@client ~]#
[root@clocalhost ~]# hostnamectl set-hostname server
[root@client ~]# bash
[root@server ~]#
2.两台主机安装NFS
[root@client ~]# yum -y install nfs-utils
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repository AppStream is listed more than once in the configuration
Repository BaseOS is listed more than once in the configuration
Repository AppStream is listed more than once in the configuration
Warning: failed loading '/etc/yum.repos.d/local.repo', skipping.
baseos 2.7 MB/s | 2.8 kB 00:00
aliyun 11 kB/s | 4.7 kB 00:00
aliyun 1.7 MB/s | 16 MB 00:09
Package nfs-utils-1:2.3.3-31.el8.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
[root@server ~]# yum -y install nfs-utils
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 2:06:58 ago on Mon 12 Oct 2020 09:42:47 PM CST.
Package nfs-utils-1:2.3.3-31.el8.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
4.开放/nfs/shared目录
[root@server ~]# mkdir /nfs
[root@server ~]# cd /nfs
[root@server nfs]# mkdir /shared
[root@server nfs]# vim /etc/exports
5.查看端口号
[root@server ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 32 192.168.122.1:53 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 128 0.0.0.0:52665 0.0.0.0:*
LISTEN 0 128 127.0.0.1:6010 0.0.0.0:*
LISTEN 0 128 [::]:46663 [::]:*
LISTEN 0 128 [::]:111 [::]:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
LISTEN
6.在客户端上挂载nfs目录
[root@client ~]# mount -t nfs 192.168.240.134:/nfs /media/