Configuration and access of NFS based on Centos7


Preface

Tip: In view of the wide variety of online NFS configurations, not detailed, here is a simple and clear description


Tip: The following is the content of this article, the following cases are for reference

1. Key points

Just use a virtual machine to do it, because the virtual machine has a local loopback ip: 127.0.0.1
, use this ip as both an NFS server and an NFS client.

Two, configuration steps

1. Check rpcbind and nfs

Because Centos7 is installed directly, there is no need to install it here, just check it.
Command: rpm -aq | grep rpcbind, rpm -aq | grep nfs

2. Start rpcbind and nfs

命令:systemctl start rpcbind,systemctl start nfs

3. Create a shared directory

In the current user's home directory, create a folder hello (any name you need), such as /home/mr-zhang/hello, and then create hello.sh in the hello folder, with the content hello, world

4. Modify the configuration file

Open /etc/exports, enter the shared directory path you just created, namely /home/mr-zhang/hello, and then enter *(ro), here I set it as a read-only shared by all network clients, save and close

5. Firewall

Insert picture description here

6. Effective configuration file

Enter exports -rv, this command re-exports the NFS shared directory and makes it effective

7. Mount

Prerequisite: Use mkdir to create a local mount point directory under the /home/mr-zhang folder.
Here I create the backup
command:

Insert picture description here

If the mount is successful, enter the backup directory and see the hello.sh file, such as

Insert picture description here
You can see from here
Insert picture description here

to sum up

Under the familiar knowledge of Linux:
linux directory map

Insert picture description here
/home: The system default user home directory. When a user account is added, the user's home directory is stored in this directory, which means the current user's home directory, and edu means the user edu's home directory.
/ :Root directory

cd /: Executing this command from any user will enter the same directory, which is shared by all users
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_44686104/article/details/109340539