zoukankan      html  css  js  c++  java
  • keepalived+nginx实现高可用

    测试环境:

    系统版本:CentOS Linux release 8.2.2004 (Core)

    VIP IP 主机名 NGINX端口 主从
    10.133.1.180 10.133.1.130 Node-1 80
      10.133.1.140 Node-2 80
    10.133.1.190 10.133.1.140 Node-2 80
      10.133.1.130 Node-1 80

     

     

     

     

     

     

     

    Node-1的keepalive配置:

    ==================================================

    vrrp_instance wp-1 {
    state MASTER
    interface eth0
    virtual_router_id 10
    priority 110
    advert_int 1
    authentication {
    auth_type PASS
    auth_pass cisco
    }
    virtual_ipaddress {
    10.133.1.180
    }
    }
    vrrp_instance wp-2 {
    state BACKUP
    interface eth0
    virtual_router_id 20
    priority 90
    advert_int 1
    authentication {
    auth_type PASS
    auth_pass cisco
    }
    virtual_ipaddress {
    10.133.1.190
    }
    }

    Node-2的keepalive配置:

    ==================================================

    vrrp_instance wp-1 {
    state BACKUP
    interface eth0
    virtual_router_id 10
    priority 90
    advert_int 1
    authentication {
    auth_type PASS
    auth_pass cisco
    }
    virtual_ipaddress {
    10.133.1.180
    }
    }
    vrrp_instance wp-2 {
    state MASTER
    interface eth0
    virtual_router_id 20
    priority 110
    advert_int 1
    authentication {
    auth_type PASS
    auth_pass cisco
    }
    virtual_ipaddress {
    10.133.1.190
    }
    }

    Node-1的NGINX配置:

    ==================================================

    upstream wp {
    ip_hash;
    server 10.133.1.130;
    server 10.133.1.140;
    }

    location / {
    proxy_pass http://wp;

    Node-2的NGINX配置:

    ==================================================

    upstream wp {
    ip_hash;
    server 10.133.1.140;
    server 10.133.1.130;
    }

    location / {
    proxy_pass http://wp;

    在Node-1上查看VIP地址

    ==================================================

    在Node-2上查看VIP地址

    ==================================================

    在浏览器上测试

    ==================================================

    http://10.133.1.180

    http://10.133.1.190

  • 相关阅读:
    互质与欧拉函数学习笔记
    Luogu P4588 [TJOI2018]数学计算 题解
    Luogu P1072 Hankson 的趣味题 题解
    Luogu [POI2002][HAOI2007]反素数 题解
    Luogu P2986 [USACO10MAR]伟大的奶牛聚集Great Cow Gat… 题解
    JavaScript 实现简易版贪吃蛇(Day_13)
    IDEA 配置 Tomcat(详细)(Day_12)
    常用数据库连接池配置及使用(Day_11)
    大对象数据LOB的应用(Day_10)
    IDEA中配置maven 全解析教程(Day_08)
  • 原文地址:https://www.cnblogs.com/networking/p/13544621.html
Copyright © 2011-2022 走看看