“This is the first day of my participation in the August More Text Challenge. For details, see: August More Text Challenge.”

Linux server

The installation

  1. Centos7 comes with rpcbind, so simply run yum -y install nfs-utils

    Yum -y install nfs-utils rpcbind and install NFS + RPC.

  2. Verify that the installation is successfulrpm -qa nfs-utils

  3. View the NFS version supported by the NFS servicecat /proc/fs/nfsd/versions

configuration

  1. Create a shared directory /data/share(directory can be customized) and set permissions

    mkdir /data/share
    chmod -R 777 /data/share
    Copy the code
  2. Configure and edit the default NFS configuration file /etc/exports

    // All IP addresses in the fixed network segment can be mounted
    echo "/ data/NFS 172.18.30. * (rw, sync, no_root_squash)" >> /etc/exports
    // Fixed network segment Fixed IP address ranges can be mounted
    echo "/ data/NFS 172.18.30.0/24 (rw, sync, no_root_squash)" >> /etc/exports
    // All clients can be mounted
    echo "/data/nfs *(rw,sync,no_root_squash)" >> /etc/exports
    Copy the code

    Description of permission configuration:

    • Rw: read/write
    • Ro: read-only. Whether the file system can be read and written depends on the RWX of the file system and its identity
    • No_root_squash: If an NFS client accesses the client as a root administrator, the client is mapped as the root administrator of the NFS server
    • Root_squash: If the NFS client accesses the client as the root administrator, the client is mapped as the nobody user of the NFS server
    • All_squash: The user that logs in to NFS is mapped as an anonymous user, usually nobody(NFsnobody).
    • Insecure: Unauthorized access from the client is allowed
    • Sync: Data is synchronized to the memory and hard disk
    • Async: Data is temporarily stored in memory instead of being written directly to hard drive
    • Anonuid: Specifies the value of the UID, which must exist in /etc/passwd
    • Anongid: Specifies the gid value
  3. To make the NFS configuration take effect exportfs -r

    The parameters of exportfs are described as follows:

    • -a: mount or unmount everything in /etc/exports
    • -r: Reexport all directories: Export all directories again
    • -u: umount directory
    • -v: verbose displays details
  4. View the NFS shared directory and its statusexportfs -v

  5. Check whether the shared directory is set successfullyshowmount -e

Start & Check

  1. Starting the RPC Service
    / / start the RPC
    systemctl start rpcbind 
    // Set boot
    systemctl enable rpcbind
    Copy the code
  2. Starting the NFS Service
    // Start NFS systemctl start NFS // Set systemctl to start NFS upon startupCopy the code
  3. rpcinfo -pIf the list of ports (port: 111) registered with the RPC server is displayed, the startup is successful.

Windows & Linux client

NFS

Linux

You do not need to start the NFS service on the client to use the showmount/mount tool

  1. NFSyum -y install nfs-utils
  2. Detecting THE RPC Servicerpcinfo -p

  3. View the directories that can be mounted on the servershowmount -e 129.xxx.xx.139

Windows

For details, see Setting the data for Mounting an NFS Share on a Linux Server in Windows 7

Mount the directory

Linux

  1. Mount the server directory to the local directorymount -t nfs 129.xxx.xx.139:/data/share /data/share
  2. Validation: on the server side/data/shareAfter creating a file in the directory, go to the directory mounted on the client to check whether the file is synchronized
    • usedf -hTYou can view the usage of file system disks on the Linux operating system
Automatically mount

After the client starts, the NFS file system can be automatically loaded:

The mount command: for example: the mount -t NFS 192.168.3.172: / data/share/data/share written to the/etc/rc. The local

Note: When the /etc/fstab OS starts, it is recommended to load the file system first and then start the network. If the network is not available, NFS cannot be loaded and errors always occur. Therefore, it is recommended to put the file system in /etc/rc.local

Windows7

  1. mount \\file-system-nas.com\data\share y:

For details, see Setting the data for Mounting an NFS Share on a Linux Server in Windows 7

Automatically mount

For details, see Automatically Mounting an NFS File System in Windows

Q&A

RPC: Port mapper failure

Error message: RPC: port mapping failed. Since the problem is the port, allow the port. View the running RPC port about NFS. Rpcinfo -p;

// Release port on the firewall
firewall-cmd --zone=public --add-port=111/tcp --permanent
firewall-cmd --zone=public --add-port=20048/tcp --permanent
firewall-cmd --zone=public --add-port=111/udp --permanent
firewall-cmd --zone=public --add-port=20048/udp --permanent
// Restart the firewall
firewall-cmd --reload
// Check the firewall public ports
firewall-cmd --zone=public --list-ports
Copy the code

NET HELPMSG 53

The NFS server has an option to work in insecure mode (allowing higher incoming port numbers). Windows NFS clients usually use a higher port number. You can enable the option insecure by adding an option to the share

Example: /share *(insecure,rw)

Other commands

Viewing the NFS service version on the client:

nfsstat -c

On the server, view the NFS version

nfsstat -s

Check the local centos version:

cat /etc/redhat-release

Deleting an NFS Share

Just uninstall the command,umountUse the following

Mount Mounts additional parameters

Run the man NFS command to view the help document. The mount parameter names vary with NFS versions. Example: The mount -t NFS -o vers = 4.1, proto = TCP, timeo = 60 129.204.4.139: / data/share/data/share

Refer to the reading

Start and stop the NFS server

Common NFS mount options

Configuring an NFS Server