zoukankan      html  css  js  c++  java
  • lvs+keepalived

    一)环境

    主/备_director   ip 主  192.168.0.122    备   192.168.0.123      vip 192.168.0.125  (多vip 192.168.0.126)

    source_real_server  ip  192.168.0.218  192.168.0.219  vip  lo: 192.168.0.125 192.168.0.126

    二)real_server准备(两台服务器都执行)

    #yum -y install httpd  

    # ip addr add dev lo 192.168.0.126/32

    # ip addr add dev lo 192.168.0.125/32

    # echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore 
    # echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce

    # sysctl -p

    注:测试所有的real_server服务器web的可实用行

    三)director调度器配置

    # yum -y install keepalived ipvsadm

    #  cat /etc/keepalived/keepalived.conf

    ! Configuration File for keepalived
    
    global_defs {
       router_id director2        
    }
    vrrp_script check_net {
       script "/etc/keepalived/keep.sh"
       interval 5
    }
    
    vrrp_instance VI_1 {
        state MASTER
        interface eth0        
       virtual_router_id 80
        priority 100        
        advert_int 1
        authentication {
            auth_type PASS
            auth_pass 1111
        }
        virtual_ipaddress {
            192.168.0.125
            192.168.0.126
        }
    track_script {
            check_net
        }
    }
    
    virtual_server 192.168.0.125 80 {
        delay_loop 6
        lb_algo rr
        lb_kind DR
        nat_mask 255.255.255.0
        protocol TCP
      
    
        real_server 192.168.0.218 80 {
            weight 1
            TCP_CHECK {
                connect_timeout 3
                nb_get_retry 3
                delay_before_retry 3
                connect_port 80
            }
        }
         
        real_server 192.168.0.219 80 {
            weight 1
            TCP_CHECK {
                connect_timeout 3
                nb_get_retry 3
                delay_before_retry 3
                connect_port 80
            }
         }
    }
    virtual_server 192.168.0.126 8080 {
        delay_loop 6
        lb_algo rr
        lb_kind DR
        nat_mask 255.255.255.0
        protocol TCP
      
    
        real_server 192.168.0.218 8080 {
            weight 1
            TCP_CHECK {
                connect_timeout 3
                nb_get_retry 3
                delay_before_retry 3
                connect_port 8080
            }
        }
         
    }

    注:备director只需吧 MASTER 改成 BACKUP   pricoity  100 改成 priority  50

    # service keepalived start

    # ipvsadm -Ln  

    IP Virtual Server version 1.2.1 (size=4096)
    Prot LocalAddress:Port Scheduler Flags
      -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
    TCP  192.168.0.125:80 rr
      -> 192.168.0.218:80             Route   1      0          0     
    -> 192.168.0.219:80 Route 1 0 0
    TCP 192.168.0.126:8080 rr 
    -> 192.168.0.218:8080 Route 1 0 0
  • 相关阅读:
    Excel导出到浏览器(个人备份)
    关于js性能
    关于JQuery(最后一点动画效果*)
    Python 2.7 学习笔记 内置语句、函数、标准库
    Python 2.7 学习笔记 模块和包
    Python 2.7 学习笔记 异常处理
    Python 2.7 学习笔记 字典(map)的使用
    Python 2.7 学习笔记 元组的使用
    Python 2.7 学习笔记 列表的使用
    Python 2.7 学习笔记 条件与循环语句
  • 原文地址:https://www.cnblogs.com/yangxiaochu/p/9582839.html
Copyright © 2011-2022 走看看