File sharing: NFS server and client
Sign in to read this lesson
When there are several web servers, uploaded files must be the same on all of them, and users' home directories must not depend on which server they log in to. On RHEL the standard solution is NFS. In this lesson we build an NFS server on srv-db01 and attach it on srv-web01 both with fstab and with autofs.
What you will learn
- Server:
dnf install nfs-utils, a share in/etc/exports,systemctl enable --now nfs-server,exportfs -rav. - exports syntax:
/srv/uploads 10.20.0.0/24(rw,sync,root_squash)— there must be no space between the network and the parenthesis. - firewalld:
nfsfor NFSv4; alsomountdandrpc-bindsoshowmountworks. - Client:
showmount -e srv-db01, in fstabsrv-db01:/srv/uploads /mnt/uploads nfs defaults,_netdev 0 0, or autofs (6.5). - SELinux: the
nfs_export_all_rwboolean for shared directories is on by default on RHEL; if httpd reads from NFS,httpd_use_nfs.
The lesson has 5 key points, an explanation and 5 questions. It opens with a package.