Introduction to the process of using NFS remote directory mounting in CentOS environment

Introduction to the process of using NFS remote directory mounting in CentOS environment

1. Introduction to NFS

In the previous article, we explained that K8s mentioned NFS to uniformly store files generated by different Pods. The data volume in K8s directly supports NFS. You can directly specify the IP and directory of the NFS server. In this article, we will learn how to mount the NFS remote directory and mount the specified directories on different servers to the NFS server, which is similar to the shared folder in Windows, so that data can be shared between different servers. Let's experience NFS together.

NFS is the abbreviation of Network File System, which means network file system in Chinese. Its main function is to allow different host systems to share files or directories through a network (usually a local area network). The NFS client (usually an application server, such as a web server) can mount the data directory shared by the NFS server to the local system of the NFS client (that is, under a certain mount point) by mounting. From the client's local perspective, the directory shared by the NFS server looks like the client's own disk partition or directory, but in fact it is a directory on the remote NFS server.

2. NFS Construction

Overall architecture:

Host Role
192.168.40.160 NFS Server
192.168.40.161 NFS Client 1
192.168.40.162 NFS Client 2

The purpose of this article is to ensure that files modified in 161 can be viewed or modified in 162 in a timely manner.

1. NFS server construction

Install nfs and rpcbind

yum -y install nfs-utils rpcbind

Set up automatic startup

chkconfig nfs on
Or systemctl enable nfs.service
chkconfig rpcbind on
Or systemctl enable rpcbind.service

Start the service

service rpcbind start
service nfs start

Create a server-side shared directory and grant permissions

mkdir -p /nfs/data && chmod -R 777 /nfs/data

Configure exports file

vi /etc/exports

Add the following content, and pay attention to fill in the server's IP.

/nfs/data 192.168.40.160(rw)
/nfs/data/ *(insecure,rw,async,no_root_squash)
Refresh configuration takes effect immediately
exportfs -a

View the mount directory

showmount -e 192.168.40.160

insert image description here

At this point the server has been built.

2. NFS client construction

Install nfs-utils

yum install nfs-utils

Create a directory and grant permissions

mkdir -p /nfs/data && chmod -R 777 /nfs/data

Hang in directory

mount 192.168.40.160:/nfs/data /nfs/data

If no error is reported at this point, it will hang on success.

3. Testing

Create the test.txt file on 161 and write some random content:

insert image description here

Let's look at the data in 160 or 162:

insert image description here

At this point, the NFS remote directory mount is successfully set up!

This is the end of this article about the process of using NFS remote directory mounting in CentOS environment. For more relevant content about using NFS directory mounting in CentOS, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Centos8 builds nfs based on kdc encryption
  • Complete steps to build NFS file sharing storage service in CentOS 7
  • How to set up NFS file sharing in CentOS 6.8
  • Tutorial on installation and configuration of NFS service under CentOS6.9
  • Centos7 installation and configuration of NFS service and mounting tutorial (recommended)
  • Steps for using and configuring NFS under centos7
  • Introduction to NFS service construction under Centos7

<<:  CSS to achieve the first row and first column of the table fixed and adaptive window example code

>>:  PHP-HTMLhtml important knowledge points notes (must read)

Recommend

Centos7.5 configuration java environment installation tomcat explanation

Tomcat is a web server software based on Java lan...

Gearman + MySQL to achieve persistence operation example

This article uses the gearman+mysql method to imp...

MariaDB under Linux starts with the root user (recommended)

Recently, due to the need to test security produc...

MySQL database deletes duplicate data and only retains one method instance

1. Problem introduction Assume a scenario where a...

Usage and scenario analysis of npx command in Node.js

npx usage tutorial Tonight, when I was learning V...

MySQL data loss troubleshooting case

Table of contents Preface On-site investigation C...

How to introduce pictures more elegantly in Vue pages

Table of contents Error demonstration By computed...

A brief analysis of the difference between ref and toRef in Vue3

1. ref is copied, the view will be updated If you...

Detailed explanation of TypeScript's basic types

Table of contents Boolean Type Number Types Strin...

JS implements the dragging and placeholder functions of elements

This blog post is about a difficulty encountered ...

How to realize vertical arrangement of text using CSS3

In a recent project, I wanted to align text verti...

Example steps for using AntV X6 with Vue.js

Table of contents 0x0 Introduction 0x1 Installati...

js implements a simple calculator

Use native js to implement a simple calculator (w...

Div nested html without iframe

Recently, when doing homework, I needed to nest a ...