2000人QQ群 : 67842417
Join us if you will.

lvs和keepalived多VIP负载多tcp应用

概述:

因测试环境资源有限,所以决定用一个lvs负载多个tcp用用,使用多个VIP达到目的

完整的keepalived.conf的配置文件如下:

[root@lvs-M ~]# cat /etc/keepalived/keepalived.conf
 ! Configuration Fileforkeepalived
 
global_defs {
   notification_email {
         747824617@qq.com
   }
   notification_email_from 747824617@qq.com
   smtp_server 127.0.0.1
  # smtp_connect_timeout 30
   router_id LVS_DEVEL
}
 

###############################################
##   load balance for rabbitMQ       ########## 
###############################################

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        10.1.166.185
        10.1.166.30
    }
}  virtual_server 10.1.166.185 50000 {
    delay_loop 10
    lb_algo wrr
    lb_kind DR
#    persistence_timeout 5
    protocol TCP
 
    real_server 10.1.166.214 50000 {
        weight 1
        TCP_CHECK {
        connect_timeout 10
#        nb_get_retry 3
#        delay_before_retry 3
        connect_port 50000
        }
    }
    real_server 10.1.166.183 50000 {
        weight 1
        TCP_CHECK {
        connect_timeout 10
#        nb_get_retry 3
#        delay_before_retry 3
        connect_port 50000
        }
     }

}



##############################################
##load balance for rabbitMQ
##############################################


virtual_server 10.1.166.30 5672 {
    delay_loop 10
    lb_algo wrr
    lb_kind DR
#    persistence_timeout 5
    protocol TCP

    real_server 10.1.166.28 5672 {
        weight 1
        TCP_CHECK {
        connect_timeout 10
#        nb_get_retry 3
#        delay_before_retry 3
        connect_port 5672
        }
    }
    real_server 10.1.166.29 5672 {
        weight 1
        TCP_CHECK {
        connect_timeout 10
#        nb_get_retry 3
#        delay_before_retry 3
        connect_port 5672
        }
     }
}

Leave a comment

电子邮件地址不会被公开。 必填项已用*标注