Working principle and example analysis of Linux NFS mechanism

Working principle and example analysis of Linux NFS mechanism

What is NFS?

network file system

A method or mechanism for storing and organizing files over a network.

Why use NFS?

All front-end application servers receive pictures, files, and videos uploaded by users and put them into the back-end storage.

The advantages of shared storage: convenient data search and retrieval; the disadvantages: high pressure on the storage server, and all data will be lost if it fails.

How NFS works

NFS functions have many services, each of which has its own port and changes frequently.

When the client looks for these ports, it needs an intermediary - the RPC service (default port number 111).

Workflow:

1. Start the RPC service

2. Start the NFS service (and register the startup port with the RPC service)

3. The client requests NFS service from RPC

4.RPC return port to the client

5. The client uses the returned port address to request NFS to transfer data.

Install NFS Service

Installation: yum install nfs-utils rpcbind

View: rpm -qa nfs-utils rpcbind

Start the service and set it to start automatically at boot: systemctl start rpcbind.service systemctl enable rpcbind.service

systemctl start nfs systemctl enable nfs

Configuring NFS

nfs configuration file /etc/exports

Run the command man exports to find:

The format of the configuration file is:

Hosts (permissions) to access the shared directory

①Directory to be shared: Directory for accessing data

②Host to access: Single host: 172.16.1.7 or host name segment: 172.16.1.0/24 or 172.16.1.*

③Permissions: rw readable ro read-only sync write to remote disk (slow, safe) async asynchronously write to remote buffer (fast, unsafe)

root_squash anonuid=anonymous user's UID anongid=anonymous user's GID

all_squash No matter what user the client is, it will be treated as nfsnobody on the server

[root@nfs01 ~]# vim /etc/exports

Note: A directory can be shared with multiple hosts at the same time, as shown in the test figure above. Note that there is no space between the parentheses and the preceding character.

Create a directory: [root@nfs01 ~]# mkdir -p /data

The default user of nfs is nfsnobody, so you need to authorize the directory: [root@nfs01 ~]# chown -R nfsnobody.nfsnobody /data

Restart NFS: [root@nfs01 ~]# systemctl reload nfs or exportfs -r (smooth restart)

examine:

Open the web01 virtual machine and install the rpc and nfs services (in principle, the client only needs to install rpc, but we are testing the showmount command here)

Mount the shared directory and create a file test

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
  • In-depth analysis of Linux NFS mechanism through cases
  • 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

<<:  Three ways to copy MySQL tables (summary)

>>:  How to configure path alias for react scaffolding

Recommend

js canvas realizes slider verification

This article example shares the specific code of ...

Seven Principles of a Skilled Designer (1): Font Design

Well, you may be a design guru, or maybe that'...

A few experiences in self-cultivation of artists

As the company's influence grows and its prod...

Detailed graphic tutorial on how to enable remote secure access with Docker

1. Edit the docker.service file vi /usr/lib/syste...

How to use vw+rem for mobile layout

Are you still using rem flexible layout? Does it ...

Two ways to correctly clean up mysql binlog logs

mysql correctly cleans up binlog logs Preface: Th...

Detailed explanation of HTML basic tags and structures

1. HTML Overview 1.HTML: Hypertext Markup Languag...

CSS3 timeline animation

Achieve results html <h2>CSS3 Timeline</...

Getting Started Tutorial for Beginners: Domain Name Resolution and Binding

So after registering a domain name and purchasing...

Use label tag to select the radio button by clicking the text

The <label> tag defines a label (tag) for an...

Architecture and component description of docker private library Harbor

This article will explain the composition of the ...

FlashFXP ftp client software registration cracking method

The download address of FlashFXP is: https://www....

Vue implements the countdown component for second kills

This article shares the specific code of Vue to i...