In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article focuses on "how to build a NFS server with nginx". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to build a NFS server with nginx.
Brief introduction what is a nfs server?
NFS (Network File System) is the network file system, its biggest function is that through the network, different machines, different operating systems can share each other's files, users access files elsewhere on the network as if they were using their own computers.
Why do you need a nfs server
Get the data from the same place to ensure the consistency of the website data, no matter which back-end server the load balancer allocates the request to, the content seen by the client is the same.
Whether the nfs server is the best solution
No, nfs is a relatively cheap solution 1, the general company will not use, the performance is not particularly high, it is recommended to use a dedicated storage server.
Advantages and disadvantages of nfs
Advantages: any linux server can be built, the cost is very low, and it is very easy to build
Disadvantages: the reading speed is limited, related to the network quality, disk IO,CPU, memory and other factors, and then the traditional tcp/ip network transmission.
Storage server
Advantages: good reading and writing performance, disaster preparedness
Disadvantages: high cost
RPC
NFS supports quite a lot of functions, and different functions will be started by different programs. Each time a function is started, some ports will be enabled to transfer data. Therefore, the port corresponding to the function of NFS is not fixed, so RPC binding is needed.
The main function of RPC is to specify the port corresponding to each NFS function.
Set up NFS server
Prepare a centos7.9 server (192.168.2.58)
One client (192.168.2.218)
Install nfs
Service machine
Yum install nfs-utils-yservice nfs-server start # start the nfs service ps aux | grep nfs # View the nfs process ss-anplut | grep rpcvim / etc/exports/web 192.168.2.0 Universe 24 (rw,all_squash,sync)
Rw: read and write
Sync: synchronously flush to disk when writing to memory
All_squash: UID and GID for shared files map anonymous user anonymous (normal user).
Aysnc: no real-time synchronization, the corresponding rate is high, but dangerous.
Mkdir / webvim / web/index.html# add some content, exit and save > wyt # I added wyt, exit and save exportfs-rv # refresh output (similar to refresh service)
Pay attention to turn off the firewall and selinux
Client
Yum install nfs-utils-yshowmount-e 192.168.2.58 # query the folder shared by the nfs server mkdir / web # client create a new folder mount 192.168.2.58:/web / web mount the / web directory on the nfs server to the local / web directory ls / web # you can view the index.html of the nfs server, there is no write permission after mounting, so the client's permission to give the file df-Th is required
Permissions are restricted by two kinds of permissions
File system permissions
Share permission
Share permissions are already on, so the server needs to authorize file permissions
Permission to write by the owner of chmod aquiw / web # / web
As long as the index.html of the server is mounted to the html under nginx, you can write under web.
Mount 192.168.2.58:/web / usr/local/scwangyutao99/html/
Mounting
Mount: in fact, it is equivalent to plugging in an external flash drive or removable hard drive. Umount is the equivalent of ejecting a flash drive.
Umount / usr/local/scwangyutao99/html/#umount.nfs4: / web: device is busy because it is currently under the directory
Display the previous web page after umount
Set up boot auto mount
/ etc/rc.local
Sed-I'$a mount 192.168.2.58:/web / usr/local/scwangyutao99/html/' / etc/rc.local chmod + x / etc/rc.d/rc.local # gives executable permission
Modify / etc/fstab file
/ etc/fstab is a linux system that automatically mounts disk partitions according to the contents of this file.
First column Device
The second column, Mount point, is the mount point of the device.
The third column filesystem, the format of the disk file system, including ext2, ext3, reiserfs, nfs, vfat, etc.
Fourth column: file system parameters, default defaults
Column 5: whether it can be affected by the dump backup command. 0 means do not make dump backup.
1 means to perform dump operations every day, and 2 represents indefinite dates for dump operations.
The sixth column: whether to check the sector, 0 do not check, 1 the earliest inspection (general root directory will choose)
The inspection will be carried out after the completion of level 1 inspection
Sed-I'$a 192.168.2.58:/web / usr/local/scwangyutao99/html/ nfs defaults 00' / etc/fstab here, I believe you have a deeper understanding of "nginx how to build a NFS server". You might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.