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

You may need a large-screen digital scrolling effect like this

The large-screen digital scrolling effect comes f...

How to implement two-way binding function in vue.js with pure JS

Table of contents First, let's talk about the...

Simple web design concept color matching

(I) Basic concepts of web page color matching (1) ...

【HTML element】Detailed explanation of tag text

1. Use basic text elements to mark up content Fir...

Quick understanding and example application of Vuex state machine

Table of contents 1. Quick understanding of conce...

How to reduce the root directory of XFS partition format in Linux

Table of contents Preface System environment Curr...

XHTML three document type declarations

XHTML defines three document type declarations. T...

Web design and production test questions and reference answers

<br />Web Design and Production Test Part I ...

vue+echarts realizes the flow effect of China map (detailed steps)

@vue+echarts realizes the flow effect of China ma...

Detailed explanation of common MySQL operation commands in Linux terminal

Serve: # chkconfig --list List all system service...

Ant designing vue table to achieve a complete example of scalable columns

Perfect solution to the scalable column problem o...

How to install Nginx in CentOS7 and configure automatic startup

1. Download the installation package from the off...

Vue implements a simple shopping cart example

This article example shares the specific code of ...