Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Server \ CentOS Nginx achieve 3 virtual machine load balancing     - Ubuntu 14.04 / 14.10 how to install FFmpeg 2.5.1 (Linux)

- Linux initialization init systems - Systemd (Linux)

- To install Git on Ubuntu systems (Server)

- AngularJS - Getting Started with Routing (Programming)

- DB2 Version SQLJ to access Oracle Server (Database)

- Security: Unix operating system intrusion tracking Strikes Back (Linux)

- MongoDB fragmentation (Cluster) (Database)

- Hibernate4 The Hello World (basic environmental structures) (Programming)

- Memcached and Redis (Linux)

- Unable to solve the official version of Android Studio online update problem (Linux)

- Compare several ways to transfer files between Linux hosts (Linux)

- How to create a remote (Linux)

- Getting CentOS Learning Notes (Linux)

- How to customize your Linux desktop: Gnome 3 (Linux)

- Flask deploy applications using Nginx on Ubuntu (Server)

- Let OS X support NTFS write file (Linux)

- How to install Zephyr Test Management Tools on CentOS 7.x (Server)

- The traffic monitoring system: cacti (Linux)

- MySQL partition table Comments (Database)

- Fedora 20, Fedora 19, CentOS 6 and RHEL6 users how to install Wine 1.7.15 (Linux)

 
         
  CentOS Nginx achieve 3 virtual machine load balancing
     
  Add Date : 2018-11-21      
         
       
         
  Load Balancing

First take a brief look at what is load balancing, just from the literal meaning can be interpreted to understand the average N servers share the load, the situation will not be a high server load down a server while idle. So the premise is to load balancing multiple servers can be achieved, that is, two or more.

test environment
In VMware was installed three CentOS.

A server IP: 192.168.0.219 (Main)

B Server IP: 192.168.0.119

C Server IP: 192.168.0.109

Deployment Ideas
A server to do the main server, the domain name resolves to direct the A server (192.168.0.219), from A to B server load balancing server (192.168.0.119) and C server (192.168.0.109) on.

On A server, upstream command - load distribution

vi /etc/nginx/conf.d/default.conf

 


upstream 192.168.0.219 {
      server 192.168.0.119:80;
      server 192.168.0.109:80;
}


server {
    listen 80;
    server_name 192.168.0.219;
    charset utf8;
    
    location / {
        proxy_pass http://192.168.0.219;
        proxy_set_header Host $ host;
        proxy_set_header X-Real-IP $ remote_addr;
        proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;
    }
}

Save restart nginx

 


In the B, C servers,

vi /etc/nginx/conf.d/default.conf

 


server {
    listen 80;
    server_name 192.168.0.219;
    index index.html;
    root / usr / share / nginx / html;

}

Save restart nginx

test
When access http://192.168.0.219, in order to distinguish which server process is turning me were written in a different content of B, C server index.html file to distinguish.

Open a browser to access a.com result, the refresh will find all of the requests are respectively the primary server (192.168.5.149) assigned to the B server (192.168.0.119) and C server (192.168.0.109) on the realization of load balancing effect.

Master server can not provide services?
The above example, we are all applied to the primary server load balancing to other servers, the primary server itself can also add in the server list, so you do not waste a single server to get as pure forwarding function, but is also involved in to provide services in the past.

How to solve this problem? 80 because the port is already used to monitor the load balancing process, so on this server can not use port 80 to handle access requests 192.168.0.219, and starting a new one.

So we edit /etc/nginx/conf.d/default.conf the primary server, add the following

server {
    listen 8080;
    server_name 192.168.0.219;
    index index.html;
    root / usr / share / nginx / html;
  }

Restart nginx

Then, re-crossing the load balancing.
     
         
       
         
  More:      
 
- CentOS 6.5 opens the Xmanager Remote Desktop login (Linux)
- MySQL log from the library than the main library (Database)
- Linux Network Programming - raw socket Example: sending a UDP packet (Programming)
- Install GAMIT / GLOBK 10.50 software under Ubuntu 14.04 (Linux)
- The basic principles for the protection of a good linux server security (Linux)
- On event processing browser compatibility notes (Programming)
- Oracle11g Trigger Debugging Record Error: PLS-00201: identifier SYS.DBMS_SYSTEM 'must be declared (Database)
- ADSL router to defend their own network security methods (Linux)
- Ubuntu install VMware Workstation 11 tutorials at 14.04 / 14.10 (Linux)
- SSH port forwarding application (Server)
- Inxi: Get Linux system and hardware information (Linux)
- MongoDB query statistics grouping remove duplicate records (Database)
- Android Studio simple setup (Linux)
- Efficient Linux Shell - Shell special characters Summary (Linux)
- Use PuTTY key authentication mechanism for remote login Linux (Linux)
- To build PHP environment (Nginx + MariaDB + PHP7) under CentOS 6.5 (Server)
- 127.0.0.1 and localhost difference (Server)
- Percona MySQL 5.6 semi-synchronous replication (Database)
- System with Windows Remote Desktop to connect Ubuntu 15.04 (Linux)
- YUM install desktop environment in CentOS (Linux)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.