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

Details of Centos7 NFS shared Storage Service

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

Share

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

Summary: NFS (Network File System), the network file system, is one of the file systems supported by FreeBSD, which allows computers in the network to share resources. In the application of NFS, the client application of the local NFS can read and write files located on the remote NFS server transparently, just like accessing the local file. Advantages: save local storage space, store commonly used data on a NFS server and be accessible through the network, then the local terminal will be able to reduce the use of its own storage space. Users do not need to have a Home directory on every machine in the network, the Home directory can be placed on the NFS server and can be accessed and used on the network. Some storage devices such as floppy drives, CDROM and Zip (disk drives and disks with high storage density) can be used by other machines on the network. This can reduce the number of removable media devices on the entire network.

Needless to say, we use experiments to further understand the role of NFS.

In order to prevent the experiment from damaging the contents of our disk, let's first add a new hard disk to experiment.

Here, we will use two Linux virtual machines, one as the server and the other as the client, so we first modify the hostname to make it easy to distinguish in the experiment.

Let's partition, format, and mount the newly added disk.

Fdisk / dev/sdb (partition disk sdb)

N (create primary partition)

W (save exit)

Mkfs.xfs / dev/sdb1 (format disk sdb1)

Vim / etc/fstab (enter the fstab file and make the following modifications)

/ dev/sdb1 / mnt xfs defaults 0 0

Mount-a (mount sdb1)

Df-hT (view the mount result)

The following two installation packages are also required for the use of the NFS server.

Yum install nfs-utils rpcbind-y (install packages nfs-utils and rpcbind)

After the package installation is complete, the shared service profile is configured.

Vim / etc/exports (enter the shared configuration file)

/ mnt 192.168.131.0 Universe 24 (rw,sysy,squash): configure shared configuration files

"/ mnt" provides a shared disk mount point, and "192.168.52.0 Universe 24" is a shared network segment. In parentheses, rw means to allow read and write (ro is read-only), sync means to write synchronously, and no_root_squash means to grant local root permission when the current client is accessed as root.

After the configuration is complete, we have just installed the software package.

Systemctl start nfs (start nfs service)

Systemctl start rpcbind (start rcpbind service)

Netstat-ntap | grep rpc (check whether the rpc service is running)

Systemctl stop firewall.service (turn off the firewall)

Setenforce 0 (turn off enhanced security features)

Now switch to the client.

Systemctl stop firewall.service (turn off the firewall)

Setenforce 0 (turn off enhanced security features)

Yum install httpd-y (install httpd package)

There are two ways to mount a shared directory to the httpd directory

First, it will be temporarily mounted and will fail once it is rebooted.

Mount 192.168.131.129:/mnt / var/www/html

Df-hT

The other is permanent mount, which will not fail even if you restart the mount.

Umount / var/www/html

Df-hT

Vim / etc/fastab

Mount-a

Df-hT

We go to the site directory of the httpd service, create a new html home page file in it, and edit a piece of content in it with the vim editor.

"this is nfs web"

Enable the httpd service

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