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

Linux's NFS shared storage service

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

NFS (Network File System) is a file system supported by FreeBSD that allows sharing resources between computers on a network. In NFS applications, client applications for local NFS can transparently read and write files located on remote NFS servers as if they were accessing local files.

This blog post gives a general overview of how NFS Shared Storage Services can be set up.

The experimental target server provides NFS service storage directory, while the client builds Apache service. The site of the website is that the server provides shared directory.

First, on Linux, enabling this service requires installing two packages. One is nfs-utils and rpcbind. The two packages share a configuration file: /etc/exports

Lab Environment: VMware System Version: Centos 7

First prepare two Linux virtual machines and connect them with xshell.

One IP address is 192.168.220.144 and the host name is Linux01.

One IP address is 192.168.220.146 and the host name is Linux02.

After the Linux system is ready, first add a disk of 5G size to the server as a single disk to provide services, and then restart the system.

After the restart is complete, create a new shared directory file under the opt directory.

Then partition and format the second disk, and finally mount it into the newly created directory.

Next open the configuration file modification using the vim /etc/exports command. The following comments are some system options. The first line I wrote is to provide the host of the 192.168.220.0 segment with read-write permissions to access the directory provided by the server.

Next, turn off the firewall and enhanced security features, and then start the service.

Next, go to the client to test whether you can see the shared folder provided by the server. Here, you have successfully seen the shared folder.

Next, install the Apache package, httpd, on the client using yum -y install httpd.

After installation, use the mount command to mount the shared folder provided by the remote service to the Apache site directory. If the mount succeeds, you will see that the capacity of this directory is the capacity of the 5 G disks newly added by the server.

Then create a URL in the middle of the site, write a little "this is nfs web" in the title, and then turn off the client firewall and enhance security features.

Next, open the Apache service and check the startup status. This shows that it has been successfully activated.

Then use the host browser to access this web page, and have successfully seen the content just written.

Since it is a shared directory provided by the remote server, you can also see such a file to the server.

One thing to note is that when the server suddenly does not mention the service, or when the server fails, it will be stuck when the client uses umount to unmount. Let's experiment.

First use the systemctl stop nfs command to forcibly terminate the service.

Next, the client uses df -hT command to check the mount status. The entire xshll connection will be stuck.

The solution here is to enter another xshell terminal and use umount -lf /var/www/html to forcibly unmount it. Note that when forcibly unmounting, you cannot use TAB key completion, otherwise you will die.

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: 0

*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

Servers

Wechat

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

12
Report