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

Linux operation and maintenance basics httpd static web page tutorial

Table of contents 1. Use the warehouse to create ...

JavaScript code to achieve a simple calendar effect

This article shares the specific code for JavaScr...

JS interview question: Can forEach jump out of the loop?

When I was asked this question, I was ignorant an...

Implementation of Docker Compose multi-container deployment

Table of contents 1. WordPress deployment 1. Prep...

10 Tips to Improve Website Usability

Whether it is a corporate website, a personal blo...

How to use ss command instead of netstat in Linux operation and maintenance

Preface When operating and managing Linux servers...

A brief understanding of the difference between MySQL union all and union

Union is a union operation on the data, excluding...

DIV background semi-transparent text non-translucent style

DIV background is semi-transparent, but the words ...

CSS screen size adaptive implementation example

To achieve CSS screen size adaptation, we must fi...