Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The process of configuring NFS server under centos7

2025-05-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "the process of configuring NFS server under centos7". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

What is NFS?

Recently, there is a requirement on the project that when the client uploads files, it wants to upload the files to another server.

Originally wanted to use ftp, think too much trouble, on a variety of information, consult others, later found that NFS this stuff is really good.

The NFS (Network File System) service can mount file share resources on remote Linux systems to directories on local hosts, allowing local hosts (Linux clients) to read and write shared files on remote Linux systems based on TCP/IP as if they were using resources on local hosts.

Simply put, mapping a directory on a remote server to a local directory is like manipulating a local directory to manipulate a remote directory, which completely meets my needs.

NFS is divided into server-side and client-side, remote server is the server, local server is the client, we now start to configure it.

server-side configuration

Install NFS

To see if nfs is installed, type rpm -qa| grep nfs

No results, indicating no installation.

Enter the installation command: yum install nfs-utils

Select yes until installation is complete.

Check again, it's installed.

Create shared directories and set permissions

Create upload directory as shared directory under/usr/local directory.

mkdir upload

Set sufficient permissions to ensure that other users also have write permissions

(Because below we map clients to anonymous users):

chmod -Rf 777 upload

Create a file (for testing, not necessary)

echo "welcome to install nfs" > readme

profile

The NFS server configuration file is/etc/exports, which by default has nothing in it.

We can define the directories to share and the corresponding permissions in the format "NFS clients allowed to access the path of the shared directory (sharing permission parameter)."

The parameter usage table is as follows:

Enter the command vi /etc/exports

join

/usr/local/upload 10.145.1.* (rw,sync,root_squash)

Note that there are no spaces between NFS client addresses and permissions.

start server for NFS

Before starting the NFS service, you also need to restart and enable the rpcbind service program, and add these two services to the boot entry.

Enter command:

systemctl restart rpcbindsystemctl enable rpcbindsystemctl start nfs-serversystemctl enable nfs-server

sets firewall

firewall-cmd --permanent --add-service=nfs

firewall-cmd --permanent --add-service=mountd

firewall-cmd --permanent --add-service=rpc-bind

firewall-cmd --reload

Without a firewall, clients may not be able to access the server's nfs.

Check if sharing succeeded

showmount -e localhost

So far, the server-side configuration is successful.

client configuration

Install NFS

You also need to check the installation of nfs, the same steps as the server.

Query remote share information for NFS servers

The command format is "Shared directory names allow client addresses."

showmount -e 10.145.1.36

Indicates that there is no problem with client and server connectivity.

Create a shared directory

It can be any directory, please create it on demand.

mkdir upload

Mount Server Directory

Use the mount command with the-t argument to specify the type of file system to mount, followed by the IP address of the server, the shared directory on the server, and the directory to mount to the local system (i.e., client).

Command format: mount -t nfs Server IP:/Shared directory on server Local mount directory

Enter command:

mount -t nfs 10.145.1.36:/usr/local/upload /usr/local/upload

After mounting, enter the upload directory and see the readme file created on the server, indicating that the mount was successful!

The client creates a new file readme2

echo "create by client" > readme2

Check on the server side, write successfully!

The configuration is complete!

once and for

If you want the NFS file sharing service to work all the time, you need to write it to the fstab file:

vi /etc/fstab

10.145.1.36:/usr/local/upload /usr/local/upload nfs defaults 0 0

This way, even if the server restarts, it will not lose configuration.

summary

Linux systems, sharing directory files with NFS is very convenient, there are the following advantages and disadvantages:

Advantages: The same disk of the server can be mounted to different clients to achieve file sharing and expand the storage space of the client.

Disadvantages: heavily dependent on the network, when network problems occur, the client mounted network disk will not be available.

Finally, set up NFS system, preferably in the same local area network, but also pay attention to the firewall settings.

"Centos7 under the process of configuring NFS server" content introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 291

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report