In-depth analysis of Linux NFS mechanism through cases

In-depth analysis of Linux NFS mechanism through cases

Continuing from the previous article, we will create a web02 server, mount the /data directory of the web01 and web02 servers to the shared directory /data of the nfs01 server, and enable automatic startup in different ways.

web01:

Add the following line to /etc/rc.local:

Reboot and check:

web02:

Clone the template machine, create the web02 virtual machine, change the host name and IP address

Install the rpc service: yum install rpcbind Enable and set it to start at boot

Add a line at the end:

Because disk mounting is faster than network card loading in the system startup sequence, and RPC requires networking, we need to enable delayed mounting:

Reboot and check:

Note: When mounting at startup, make sure that the nfs01 server and its nfs service are both enabled.

View shared directory information on the nfs01 server

You can specify user access by setting uid and gid (add the same user on the server and client --- the uid and gid are the same):

useradd -u 1111 test

Test on web01 server:

Summarize:

① The shared directory in the nfs configuration file of the nfs server needs to have write permissions

②The local permissions of the nfs server shared directory should be set to w permissions

③When specifying a user, ensure that the uid and gid of the user on the server and client are the same (the user name can be different)

Client Mount In-depth

View the client mount information:

Two mounting modes: hard and soft

If the mount is in soft mode, when a network or service problem occurs, the client will consistently try to mount until the timeout (timeo) stops.

If the hard mount is used, the system will keep trying until the mount succeeds. You cannot umount or kill the mount at this time. It is often used with intr.

Note: soft may cause data loss after timeout, so it is not recommended.

rsize/wsize is the block size for writing/reading, which affects the buffer storage capacity for data transmission between the client and the server. If you are in a local area network and the memory on both sides is relatively large, this value can be set larger to increase the transmission speed.

Detailed explanation of the mount command: https://www.runoob.com/linux/linux-comm-mount.html

CentOS7.6 optimization recommends using the following mount command:

mount -t nfs -o noatime,nodiratime,nosuid,noexec,nodev,rsize=131072,wsize=131072 172.16.1.31:/data /mnt

NFS Kernel Optimization Suggestions

  • /proc/sys/net/core/rmem_default: This file specifies the default value of the receive socket buffer size, which defaults to 124928 (bytes)
  • /proc/sys/net/core/rmem_max: This file specifies the maximum size of the receive socket buffer, the default is 124928 (bytes)
  • /proc/sys/net/core/wmem_default: This file specifies the default value of the send socket buffer size, which defaults to 124928 (bytes)
  • /proc/sys/net/core/wmem_max: This file specifies the maximum send socket buffer size, the default is 124928 (bytes)

The specific commands corresponding to the above files are as follows:

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Implementing Python to monitor USB device signals under Linux
  • Detailed explanation of Linux USB host driver writing
  • arm linux uses alsa driver and uses usb audio device
  • How to use USB mobile storage in Linux
  • Using USB storage in Linux environment
  • Working principle and example analysis of Linux NFS mechanism
  • IntelliJ IDEA remote debugging Linux Java program, find the problem do not just look at the log (recommended)
  • Use of Linux bzip2 command
  • How to use libudev in Linux to get USB device VID and PID

<<:  How to configure path alias for react scaffolding

>>:  Detailed explanation of pure SQL statement method based on JPQL

Recommend

Detailed instructions for installing SuPHP on CentOS 7.2

By default, PHP on CentOS 7 runs as apache or nob...

How to implement the builder pattern in Javascript

Overview The builder pattern is a relatively simp...

MySQL 5.7.21 installation and configuration tutorial

The simple installation configuration of mysql5.7...

htm beginner notes (must read for beginners)

1. What is HTML HTML (HyperText Markup Language):...

Using jQuery to implement the carousel effect

This article shares the specific code for impleme...

Resolving MySQL implicit conversion issues

1. Problem Description root@mysqldb 22:12: [xucl]...

Vue3 manual encapsulation pop-up box component message method

This article shares the specific code of Vue3 man...

How to install Docker on Windows 10 Home Edition

I recently used Docker to upgrade a project. I ha...

Native JavaScript to achieve skinning

The specific code for implementing skinning with ...

Summary of using the exclamation mark command (!) in Linux

Preface Recently, our company has configured mbp,...

How to implement insert if none and update if yes in MySql

summary In some scenarios, there may be such a re...

CSS syntax for table borders

<br /> CSS syntax for table borders The spec...

Implementation of docker redis5.0 cluster cluster construction

System environment: Ubuntu 16.04LTS This article ...