zoukankan      html  css  js  c++  java
  • centos6.6 LVS+keepalived

    之前有写过keepalived+mysql  和lvsDR模式的分析篇。然而LVS没有写高冗余。今天来写一篇LVS+keepalived的

    LVSDR只负责转发,LVS也没有nginx后端检查功能,所以后端realserver 宕机了,LVS还是会转发到后端去的。so 我们需要一个检查后端的功能,并剔除or增加。那这个任务就交给keepalived了

    LVS安装 和keepalived 安装这里就不多说,

    keepalived 安装请看:http://www.cnblogs.com/shiyiwen/p/5045027.html

    LVSDR安装请看:http://www.cnblogs.com/shiyiwen/p/5069901.html

    上拓扑

     

    这里 37 为 master        161位backup

    37-master  keepalived.conf配置如下

    ! Configuration File for keepalived
    
    global_defs {
       notification_email {
         907765003@qq.com
       }
       notification_email_from 907765003@qq.com
       smtp_server 127.0.0.1
       smtp_connect_timeout 30
       router_id LVS_DEVEL
    }
    
    # VIP1
    vrrp_instance VI_1 {
        state MASTER
        interface eth0
        lvs_sync_daemon_inteface eth0
        virtual_router_id 51
        priority 100
        advert_int 5
      #  nopreempt
        authentication {
            auth_type PASS
            auth_pass 1111
        }
        virtual_ipaddress {
            192.168.0.36
        }
    }
    virtual_server 192.168.0.36 80 {
        delay_loop 6
        lb_algo wrr
        lb_kind DR
    #    persistence_timeout 60
        protocol TCP
    
        real_server 192.168.0.38 80 {
            weight 100
            TCP_CHECK {
            connect_timeout 10
            nb_get_retry 3
            delay_before_retry 3
            connect_port 80
            }
        }
        real_server 192.168.0.162 80 {
            weight 100
            TCP_CHECK {
            connect_timeout 10
            nb_get_retry 3
            delay_before_retry 3
            connect_port 80
    
            }
        }
    }
    

    161 BACKUP -keepalived.conf 如下

    ! Configuration Filefor keepalived
    global_defs {
      notification_email {
       907765003@qq.com
      }
      notification_email_from 907765003@qq.com
      smtp_server 127.0.0.1
      smtp_connect_timeout 30
      router_id LVS_DEVEL
    }
    # VIP1
    vrrp_instance VI_1 {
      state BACKUP
      interface eth0
      lvs_sync_daemon_inteface eth0
      virtual_router_id 51
      priority 90
      advert_int 5
      authentication {
        auth_type PASS
        auth_pass 1111
      }
      virtual_ipaddress {
        192.168.0.36
      }
    }
    #REAL_SERVER_1
    virtual_server 192.168.0.36 80 {
      delay_loop 6
      lb_algo wlc
      lb_kind DR
      persistence_timeout 60
      protocol TCP
      real_server 192.168.0.38 80 {
        weight 100
        TCP_CHECK {
        connect_timeout 10
        nb_get_retry 3
        delay_before_retry 3
        connect_port 80
        }
    }
    #REAL_SERVER_2
      real_server 192.168.0.162 80 {
        weight 100
        TCP_CHECK {
        connect_timeout 10
        nb_get_retry 3
        delay_before_retry 3
        connect_port 80
        }
      }
    }
    

    至于排错,大家有问题,可留言~

  • 相关阅读:
    新的
    曾经写过得太监小说3《缱绻修真界》
    Python的from和import用法
    python几个有意思的小技巧
    leetcode 最长回文串
    leetcode-快速排序C++自写
    leetcode 面试题 01.06. 字符串压缩
    leeetcode 剑指 Offer 29. 顺时针打印矩阵
    leetcode 70. 爬楼梯 续
    leetcode 1143. 最长公共子序列-华为
  • 原文地址:https://www.cnblogs.com/shiyiwen/p/5090873.html
Copyright © 2011-2022 走看看