Nginx High-availability cluster combat

Source: Internet
Author: User

First, Introduction

on a blog post on the keepalived high-availability cluster, in fact, using Nginx to do the front-end agent, load balancing can also achieve dual-master or main standby mode of high-availability cluster than keepalived based on the Dr configuration of LVs is easier to learn, Below are the Nginx high availability clusters that I understand. This experimental topology diagram is similar to the keepalived topology, the keepalived words in the diagram can be replaced with nginx, I do not draw, interested people can redraw.

Experimental topology diagram:

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/89/91/wKioL1gXUAiQfCThAADihRpSRO4336.png "title=" Keepalivedha.png "alt=" Wkiol1gxuaiqfcthaadihrpsro4336.png "/>

Second, Nginx main standby mode high availability

Configure the Nginx upstream module so that it can be reversed to the backend host, the backend host configuration and the keepalived are identical.

Upstream Websrvs {server 10.1.10.5:80;     #后端主机real Server01 server 10.1.10.6:80; #后端主机real SERVER02 server 10.1.10.2:80 backup; #当后端主机均不能响应时此主机响应应急页面}

Configure keepalived configuration file for VIP address Drift

! configuration file for keepalivedglobal_defs {notification_email {[email  Protected]}notification_email_from [email protected]smtp_server 127.0.0.1smtp_connect_timeout  30router_id node1vrrp_mcast_group4 224.0.100.18}vrrp_script chk_down {script  "[ [ -f /etc/keepalived/down ]]  && exit 1 | |  exit 0 "interval 1weight -5}vrrp_script chk_nginx {script " killall -0  nginx && exit 0 | |  exit 1 "interval 1weight -5}vrrp_instance vi_1 {state masterinterface  eno16777736virtual_router_id 57priority 100advert_int 1authentication {auth_type  passauth_pass 98181111}virtual_ipaddress {10.1.10.7/16 dev eno16777736}track_script { chk_downchk_httpd}notify_master  "/etc/keepalived/notify.sh master" notify_backup  "/etc/Keepalived/notify.sh backup "notify_fault "/etc/keepalived/notify.sh fault "} 


Implementation diagram:

Simulates a single back-end host that cannot provide services and all of its downtime experimental results are as follows:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/89/94/wKiom1gXUXnw0U-3AABDTIyfNt8550.png "title=" Nnnnn.png "alt=" Wkiom1gxuxnw0u-3aabdtiyfnt8550.png "/>

The results of the appeal show that this experiment successfully demonstrated the Nginx inversion in the main standby mode for high availability. This lab class detects the health status of Nginx and the switch of its main standby mode to send an email to the administrator.


Three,nginx main main mode high availability

      configuration keepalived configuration file, implement VIP address drift, and appeal main preparation similar to

! configuration file for keepalivedglobal_defs {notification_email {[email  Protected]}notification_email_from [email protected]smtp_server 127.0.0.1smtp_connect_timeout  30router_id node1vrrp_mcast_group4 224.0.120.18}vrrp_script chk_down { # Detects if a down file exists under this file, this script  can be used when the grayscale mode is online "[[ -f /etc/keepalived/down ]] &&  exit 1 | |  exit 0 "interval 1weight -5}vrrp_script chk_nginx {  #检测nginx的健康状态信息script   "killall -0 nginx && exit 0 | |  exit 1 "interval 1weight -5}vrrp_instance vi_1 {state masterinterface  eno16777736virtual_router_id 53priority 100advert_int 1authentication {auth_type  passauth_pass 9818sss1}virtual_ipaddress {10.1.10.7/16 dev eno16777736}track_script { chk_downchk_nginx}notify_master  "/etc/keepalived/notify.sh master "notify_backup "/etc/keepalived/notify.sh backup "notify_fault  "/etc/keepalived/notify.sh fault"}vrrp_instance vi_2 {state backupinterface  eno16777736virtual_router_id 54priority 98advert_int 1authentication {auth_type  passauth_pass 9818rss1}virtual_ipaddress {10.1.10.77/16 dev eno16777736}track_script  {chk_downchk_nginx}notify_master  "/etc/keepalived/notify.sh master" notify_backup  "/etc/ Keepalived/notify.sh backup "notify_fault "/etc/keepalived/notify.sh fault "}

At this time, Nginx on keepalived all start results

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/89/95/wKiom1gXWHjQQjrZAACWiViHvhM098.png "title=" Cdgd.png "alt=" Wkiom1gxwhjqqjrzaacwivihvhm098.png "/>

Simulating back-end host outages and their return to normal results similar to keepalived:

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/89/93/wKioL1gXWMWDyyWfAABCFHQMR3U704.png "title=" Dfdfdfdfd.png "alt=" Wkiol1gxwmwdyywfaabcfhqmr3u704.png "/>


To this, nginx high-availability clusters have been implemented, the method of doing experiments and keepalived have many similarities.



This article is from the "Small Ears" blog, please be sure to keep this source http://purify.blog.51cto.com/10572011/1867871

Nginx High-availability cluster combat

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.