Home >Operation and Maintenance >Nginx >Example analysis of nginx load function + nfs server function

Example analysis of nginx load function + nfs server function

王林
王林forward
2023-05-14 18:31:131412browse

Use nfs server to make the web page content of three server servers consistent

#The contos system used in this article

Example analysis of nginx load function + nfs server function

1. Install nfs-utils on the nfs server and 3 server servers

[root@nfs-server ~]# yum install nfs-utils -y

2. Start the nfs function on the nfs server

Example analysis of nginx load function + nfs server function

There is no response when checking the nfs process. This is because nfs does not listen to the external port number, but outsources it to rpc. rpc helps nfs to listen to the port, and then tells the client to contact the corresponding port of the machine.

Example analysis of nginx load function + nfs server function

3. Shared files

①. Created a shared file web under the root, which contains a web page and 2 files for download

#The download function needs to be configured in 3 servers, otherwise it cannot be downloaded

Example analysis of nginx load function + nfs server function

②.Add a line of configuration in the file /etc/exports

Example analysis of nginx load function + nfs server function

/web The folder to be shared is the web folder I just created under the root

192.168.83.0/24 shared network segment

rw Yes Read and write

all_squash is used to indicate that all users accessing are restricted to anonymous users

sync writes data to the memory and disk at the same time to ensure no data loss

The parameters in #() can be modified. This article will not explain it in more detail. You can check the official website or other blogs for details.

4. Refresh the output list

Output the content just written to the configuration file /etc/exports to the specified network segment

Example analysis of nginx load function + nfs server function

5. It is recommended to turn off the firewall and selinux

Selinux is a mechanism to protect the security of the Linux system. It is not applicable for the time being. It is recommended to turn off

setenforece 0Temporarily turn off selinux

vim /etc/sysconfig/selinux SELINUX=disabled 永久关闭selinux

Turn off the firewall

service firewalld stop --》Close the firewalld service immediately--》Temporarily shut down

systemctl disable firewalld --》Set the firewalld service not to start at boot--》Permanently shut down

6. Mount on the server server

The server also needs to install the nfs-utils package

Use the showmount -e command on the server to view the shared output on the nfs server Which folders are

Example analysis of nginx load function + nfs server function

#If the path is unreachable, consider whether the firewall is not closed

Use the command to mount to the specified folder

Example analysis of nginx load function + nfs server function

#Syntax: mount nfs server directory local directory

If you want to unmount, use umout and add the mounted directory, here it is umount /usr/local/ nginx1/html/

If you don’t remember the mounting directory, you can use the df command to view it

Example analysis of nginx load function + nfs server function

7. Verify the effect

Client access Load balancer 192.168.83.160, the data is the same every time it is accessed. If a certain server modifies the data, then the data of all servers will also be modified. This is what we call data consistency

Example analysis of nginx load function + nfs server function

8. How to modify the data on the server server

Although the data of the nfs server is mounted on three servers, the server cannot operate the data, including creating files, etc.

Example analysis of nginx load function + nfs server function

#Whether the server has write permissions depends on two permissions

1. Sharing permissions--"Permissions in the /etc/exports file , such as ro, rw

2. Permissions in the file system--》Permissions of /web in Linux--》Authorization in nfs server

We have given sharing permissions , so you only need to authorize the shared files in the file system of the nfs server

Example analysis of nginx load function + nfs server function

We have write permissions on the server side

Example analysis of nginx load function + nfs server function

9. Automatically mount at startup

Because the mount will fail every time you shut down, we need to allow the server to automatically mount at startup

1./etc/rc.local

vim /etc/rc.local
mount 192.168.83.100:/web /usr/local/nginx1/html --》在文件内加上一行
chmod +x /etc/rc.d/rc.local --》授权文件

Example analysis of nginx load function + nfs server function

2/etc/fstab

vim /etc/fstab --》加上这一行

Example analysis of nginx load function + nfs server function

192.168.83.22:/web /usr/local/nginx1/html nfs defaults 0 0

192.168.83.22:/web 挂载的分区 --》nfs的文件系统

/usr/local/nginx1/html 在本地的挂载点

nfs 文件系统类型

0 是否支持demp命令进行备份

0 是否开机的时候进行分区的文件检查

Example analysis of nginx load function + nfs server function

Example analysis of nginx load function + nfs server function

The above is the detailed content of Example analysis of nginx load function + nfs server function. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete