Nginx cluster load balancer
Experimental environment:
10.10.204.62 Load Balancing
10.10.204.63 Nginx Web server
10.10.204.64 Nginx Web server
10.10.204.65 File Storage
1.File Storage server installation
yum -y install nfs-utils
2. Configure NFS and create a shared directory
# mkdir -p /Data/webapp # vim /etc/exports /Data/webapp 10.10.204.0/24(rw,sync,no_subtree_check,no_root_squash)
3. Turn on auto-start
# systemctl enable rpcbind # systemctl enable nfs-server # systemctl start rpcbind # systemctl start nfs
4.Related parameters:
rw:read-write:可读写; ro:read-only,只读; sync:文件同时写入硬盘和内存。 no_root_squash:来访的root用户保持root帐号权限;显然开启这项是不安全的。 root_squash:将来访的root用户映射为匿名用户或用户组;通常它将使用nobody或nfsnobody身份。 all_squash:所有访问用户都映射为匿名用户或用户组; anonuid:匿名用户的UID值,可以在此处自行设定。 anongid:匿名用户的GID值。 sync:将数据同步写入内存缓冲区与磁盘中,效率低,但可以保证数据的一致性。 async:文件暂存于内存,而不是直接写入内存。 no_subtree_check :即使输出目录是一个子目录,nfs服务器也不检查其父目录的权限,这样可以提高效率。
5.File Storage server firewall configuration
# firewall-cmd --permanent --add-service=rpc-bind # firewall-cmd --permanent --add-service=nfs # firewall-cmd --reload
6.Nginx Web server server installation and mounting
# yum -y install nfs-utils # mkdir -p /Data/webapp # mount -t nfs 10.10.204.65:/Data/webapp /Data/webapp
7. If you need to automatically mount it at boot, just add a line at the bottom of the file
# vim /etc/fstab 10.10.204.65:/Data/webapp /Data/webapp nfs auto,rw,vers=3,hard,intr,tcp,rsize=32768,wsize=32768 0 0
8.Nginx Web server server test
Continuously write 16384 16KB blocks to the testfile file in the nfs directory
# time dd if=/dev/zero of=/Data/webapp/testfile bs=16k count=16384 16384+0 records in 16384+0 records out 268435456 bytes (268 MB) copied, 2.89525 s, 92.7 MB/s real 0m2.944s user 0m0.015s sys 0m0.579s 测试读的性能 # time dd if=/nfsfolder/testfile of=/dev/null bs=16k 16384+0 records in 16384+0 records out 268435456 bytes (268 MB) copied, 0.132925 s, 2.0 GB/s real 0m0.138s user 0m0.003s sys 0m0.127s
Generally speaking, the speed of NFS is quite ideal. If you feel that the speed is slow, add relevant parameters, mount and uninstall repeatedly, and test reading and writing to find a configuration solution that suits you.
The above is the detailed content of Nginx cluster load balancer. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

There are six ways to run code in Sublime: through hotkeys, menus, build systems, command lines, set default build systems, and custom build commands, and run individual files/projects by right-clicking on projects/files. The build system availability depends on the installation of Sublime Text.

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

To install Laravel, follow these steps in sequence: Install Composer (for macOS/Linux and Windows) Install Laravel Installer Create a new project Start Service Access Application (URL: http://127.0.0.1:8000) Set up the database connection (if required)

Installing Git software includes the following steps: Download the installation package and run the installation package to verify the installation configuration Git installation Git Bash (Windows only)

Sublime Text provides shortcuts to improve development efficiency, including commonly used (save, copy, cut, etc.), editing (indentation, formatting, etc.), navigation (project panel, file browsing, etc.), and finding and replacing shortcuts. Proficiency in using these shortcut keys can significantly improve Sublime's efficiency.
