mycpen

Mycpen

记录学习历程与受益知识
github
telegram
bilibili

25_Linux Basics - NFS Service

Log Rotation:

https://blog.csdn.net/weixin_43265596/article/details/85469405

https://www.cnblogs.com/liangyuxing/p/11962863.html

https://blog.csdn.net/dhxaohei/article/details/8014764


1. Introduction to NFS#

NFS (Network File System) allows different machines and operating systems to share files over a network. NFS can mount remote computer disks locally, allowing file read and write operations as if accessing local disks.

Prerequisites: Disable selinux
Disable iptables


2. rpcbind and nfs#

Before starting nfs, ensure that the rpcbind service is already started.
When nfs starts, it will register a port with the rpcbind service, which will return a port for nfs to use.
You can use
rpcinfo -p command to check if the nfs port has been registered successfully.
rpcbind is like a landlord, and nfs is a tenant.

Note: NFS cannot start its own port; rpcbind registers the port for nfs.#

Note: Ensure rpcbind is up before nfs starts.#

[root@cPen_A www]# rpcinfo -p # Note: rpcbind starts port 2049 for nfs.
100003 3 tcp 2049 nfs


3. Experiment: Using nfs and nginx for load balancing and file sharing#

A: 192.168.0.73 nfs Real Machine
B: 192.168.0.79 Proxy Machine + Real Machine
C: 192.168.0.53 Real Machine

Prerequisites:
All three hosts have nginx installed, and one of them has the nfs service enabled.
The nfs service is enabled on machine A, and the website directory is stored in /opt/www. B and C can mount A's /opt/www directory locally.
After configuring the nfs service on machine A, enable the nfs service, and then execute on machines A and C:
[root@cPen_B ~]# mount -t nfs 192.168.0.73:/opt/www /opt/www
[root@cPen_C ~]# mount -t nfs 192.168.0.73:/opt/www /opt/www

image-20221011191610524

Note: You can use killall nginx to kill all.#

Note: 404 Not Found, 403 Forbidden.#

Note: Swap A and B to B and A.#

nginx proxy machine + real machine

A

nginx real machine

B nfs

nginx real machine

C

Client accesses www.sc.com to access the 80 port of machine A nginx proxy (proxy means forwarding).
Machine A returns to handle its own 8080 or the 8080 of machine B, or the 8080 of machine C.
Load balancing: 20,000 people access the 80 port of machine A, the 80 port will not handle requests, just proxy forwarding, hand over to its own 8080 for processing, or the 8080 of machine B, or the 8080 of machine C. The pages returned by machines A, B, and C must remain consistent.
Mount the /opt/www directory of machine B to A and C (to maintain file consistency, all changes are made to the nfs of machine B).

image-20221011191803355

Note: Network issues#

Bridge mode VMnet0 Same subnet

NAT mode VMnet8 Same subnet

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.