Introduction nfs

NFS network file system is often used to share static resources such as audio, video, pictures and so on. Shared resources will be placed in the shared directory of NFS and accessed through server mount.

Server installation:

yum install -y nfs-utils rpcbind

perhaps

yum install -y nfs-utils
yum install -y rpcbind

Client installation:

yum install -y nfs-utils

Set up boot-up self-startup

systemctl enable nfs
systemctl enable rpcbind

Server configuration:

1. Create shared directories

mkdir -p /data/nfs-share

2. After installing the nfs service, the configuration file exports will be automatically generated. If not, create a / etc/exports by yourself.

cat /etc/exports

3. Editing Shared Profile

vi /etc/exports
/data/nfs-share *(rw,sync,no_root_squash)


#/home/nfs *(rw,sync,no_root_squash)
#/data/nfs-share *

The first column: directories to be shared, that is, file systems to be shared in the network;

Column 2: Accessible hosts
 192.168.152.13 Host with specified IP address
 nfsclient.test.com specifies the host of the domain name
 192.168.1.0/24 All hosts in the specified segment
 * test.com specifies all hosts in the domain
 * All hosts

Column 3: Shared parameters
Here are some common parameters shared by NFS:

 ro                      read-only access
 rw                      Read write access
 sync                    All data is written to share on request
 async                   NFS Requests can be made before data is written
 secure                  NFS Through security below 1024 TCP/IP Port send
 insecure                NFS Send over 1024 ports
 wdelay                  If multiple users want to write NFS Catalog, then group write (default)
 no_wdelay               If multiple users want to write NFS The directory is immediately written when used async This setting is not required.
 Hide                    stay NFS Shared directories do not share their subdirectories
 no_hide                 Share NFS Subdirectories of directories
 subtree_check           If share/usr/bin When subdirectories like this are mandatory NFS Check the permissions of the parent directory (default)
 no_subtree_check        As opposed to the above, the parent directory permissions are not checked
 all_squash              Shared file UID and GID Mapping anonymous users anonymous,Suitable for public catalogs.
 no_all_squash           Keeping Shared Files UID and GID(Default)
 root_squash             root All user requests are mapped to the following anonymous User-like privileges (default)
 no_root_squas           root Users have full administrative access to the root directory
 anonuid=xxx             

Specify UID for anonymous users in NFS server/etc/passwd file
For example, you can edit / etc/exports as follows:

/tmp         *(rw,no_root_squash)
/home/public     192.168.0.*(rw)   *(ro)
/home/test      192.168.0.100(rw)
/home/linux      *.the9.com(rw,all_squash,anonuid=40,anongid=40)

4. start nfs

service rpcbind start
# Tip: Redirecting to/bin/system CTL start rpcbind.service
service nfs start
# Tip: Redirecting to / bin / system CTL start nfs. service

5. View mounts

showmount -e 127.0.0.1
Return content
# Export list for 127.0.0.1:
# /data/nfs-share *

Client Configuration:

1. create

# / kubernetes is a locally mounted directory
mkdir -p /kubernetes

2. mount

mount [Server side ip]:/data/nfs-share /kubernetes
# for example
mount 10.1.1.99:/home/nfs /kubernetes

Other

Configuration effective

# Modify Shared Profile Execution
exportfs -r