zoukankan      html  css  js  c++  java
  • 架构师的成长之路初片~LVS+keepalived---- and-----haproxy

    (Centos7)

    环境:
    LVS1: 192.168.4.5

    LVS2: 192.168.4.6

    web1 192.168.4.100
    192.168.4.15(虚拟IP)

    web2 192.168.4.200
    192.168.4.15(虚拟IP)

    client: 192.168.4.10

    LVS端:
    1:装包:ipvsadm、keepalived
    2:修改配置文件//etc/keepalived/keepalived.conf
    ####################################################################
    ! Configuration File for keepalived

    global_defs {
       notification_email {
         acassen@firewall.loc
         failover@firewall.loc
         sysadmin@firewall.loc
       }
       notification_email_from Alexandre.Cassen@firewall.loc
       smtp_server 192.168.200.1
       smtp_connect_timeout 30
       router_id LVS1
       vrrp_iptables
       vrrp_skip_check_adv_addr
       vrrp_strict
       vrrp_garp_interval 0
       vrrp_gna_interval 0
    }
    
    vrrp_instance VI_1 {
        state MASTER
        interface eth1
        virtual_router_id 51
        priority 100
        advert_int 1
        authentication {
            auth_type PASS
            auth_pass 1111
        }
        virtual_ipaddress {
        	192.168.4.15/24
        }
    }
    
    virtual_server 192.168.4.15 80 {
        delay_loop 6
        lb_algo rr
        lb_kind DR
    #   persistence_timeout 50
        protocol TCP
    
        real_server 192.168.4.100 80 {
            weight 1
    	TCP_CHECK {
                connect_timeout 3
                nb_get_retry 3
                delay_before_retry 3
            }
        }
        real_server 192.168.4.200 80 {
            weight 1 
    	TCP_CHECK {
                connect_timeout 3
                nb_get_retry 3
                delay_before_retry 3
            }   
        }   
    
    }
    

      

    3:启服务
    systemctl restart keepalived

    负载均衡可使用的方案:
    1:软件:开源,免费
    2:硬件:收费

    Haproxy
    Haproxy是代理服务器
    不需要网关,不需要开启路由
    可做七层与四层代理
    :应用层:httpftpdnssmtp
    :传输层:tcp/ip udp
    四层代理:可做端口代理
    七层代理:网站代理:nginxhttpdftp
    性能:LVS>haproxy>Nginx
    功能:Nginx>Haproxy>LVS

    ------------------------------------------------------------------------------------------------

    环境:
    Haproxy: 192.168.4.5
    192.168.2.5

    web1 192.168.2.100

    web2 192.168.2.200

    1)装包
    haproxy
    主配置文件:
    /etc/haproxy/haproxy.cfg
    关selinux、firewalld
    2)修改主配置文件

     73 backend static
     74     balance     roundrobin
     75     server      static 127.0.0.1:4331 check
     76 
     77 #---------------------------------------------------------------------
     78 # round robin balancing between the various backends
     79 #---------------------------------------------------------------------
     80 backend app
     81     balance     roundrobin
     82     server  app1 127.0.0.1:5001 check
     83     server  app2 127.0.0.1:5002 check
     84     server  app3 127.0.0.1:5003 check
     85     server  app4 127.0.0.1:5004 check
     86 listen abc *:80
     87     server web1 192.168.2.100 check inter 2000 rise 2 fall 5
     88     server web2 192.168.2.200 check inter 2000 rise 2 fall 5
     89 listen stats *:1080
     90     stats refresh 30s
     91     stats uri /stats
     92     stats realm Haproxy Manager
     93     stats auth admin:admin
    

      

  • 相关阅读:
    20201107
    20201024
    20201020
    20200331
    20200330
    20200320
    20200319
    20200310
    20200221
    20190926
  • 原文地址:https://www.cnblogs.com/ahaocloud/p/14588554.html
Copyright © 2011-2022 走看看