负载均衡器
|
Vip
|
Vrrp_instance
|
角色
|
Lvs-1
|
61.135.93.99
60.135.93.100
|
VI_WEB
VI_CTCP
|
VI_WEB -à MASTER
VI_CTCP-à BACKUP
|
Lvs-2
|
61.135.93.99
60.135.93.100
|
VI_WEB
VI_CTCP
|
VI_WEB--à BACKUP
VI_CTCP-à MASTER
|
项目
|
Vip
|
转发端口(TCP)
|
转发规则
|
Web(bbs、blog、www)
|
61.135.93.99
|
80
|
61.135.93.99:80à 61.135.93.x:80
|
自定义服务1
|
61.135.99.100
|
3000
|
61.135.93.100:3000à61.135.93.y:
3000
|
自定义服务2
|
61.135.93.100
|
4000
|
61.135.93.100:4000->61.135.93.z:
4000
|
负载均衡器lvs_1配置文件/etc/keepalived/keepalived.conf
|
负载均衡器lvs_2配置文件/etc/keepalived/keepalived.conf
|
#guration File for keepalived,writed by sery
#global define
global_defs {
router_id lvs_1
}
vrrp_sync_group VGM {
group {
VI_WEB
}
}
vrrp_sync_group VGB {
group {
VI_CTCP
}
}
vrrp_instance VI_WEB{
state MASTER
interface eth0
lvs_sync_daemon_inteface eth0
virtual_router_id 51
priority 180
advert_int 5
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
61.135.93.99
}
}
# setting port 80 forward
virtual_server 61.135.93.99 80 {
delay_loop 6
lb_algo wlc
lb_kind DR
persistence_timeout 10
protocol TCP
real_server 61.135.99.80 80 {
weight 100
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 61.135.93.81 80 {
weight 100
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 61.135.93.82 80 {
weight 90
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 61.135.93.83 80 {
weight 90
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
}
vrrp_instance VI_CTCP {
state BACKUP
interface eth0
lvs_sync_daemon_inteface eth0
virtual_router_id 52
priority 150
advert_int 5
authentication {
auth_type PASS
auth_pass 2222
}
virtual_ipaddress {
61.135.93.100
}
}
virtual_server 61.135.93.100 3000 {
delay_loop 6
lb_algo wlc
lb_kind DR
persistence_timeout 50
protocol TCP
real_server 61.135.93.84 3000{
weight 100
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 3000
}
}
real_server 61.135.93.85 3000{
weight 100
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 3000
}
}
real_server 61.135.93.86 3000{
weight 100
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 3000
}
}
real_server 61.135.93.87 3000{
weight 100
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 3000
}
}
}
virtual_server 61.135.93.100 4000 {
delay_loop 6
lb_algo wlc
lb_kind DR
persistence_timeout 50
protocol TCP
real_server 61.135.93.88 4000{
weight 100
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 4000
}
}
real_server 61.135.93.89 4000{
weight 100
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 4000
}
}
real_server 61.135.93.90 4000{
weight 100
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 4000
}
}
real_server 61.135.93.91 4000{
weight 100
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 4000
}
}
}
|
#guration File for keepalived,writed by sery
#global define
global_defs {
router_id lvs_2
}
vrrp_sync_group VGM {
group {
VI_CTCP
}
}
vrrp_sync_group VGB {
group {
VI_WEB
}
}
vrrp_instance VI_WEB{
state BACKUP
interface eth0
lvs_sync_daemon_inteface eth0
virtual_router_id 51
priority 150
advert_int 5
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
61.135.93.99
}
}
# setting port 80 forward
virtual_server 61.135.93.99 80 {
delay_loop 6
lb_algo wlc
lb_kind DR
persistence_timeout 10
protocol TCP
real_server 61.135.99.80 80 {
weight 100
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 61.135.93.81 80 {
weight 100
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 61.135.93.82 80 {
weight 90
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 61.135.93.83 80 {
weight 90
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
}
vrrp_instance VI_CTCP {
state MASTER
interface eth0
lvs_sync_daemon_inteface eth0
virtual_router_id 52
priority 180
advert_int 5
authentication {
auth_type PASS
auth_pass 2222
}
virtual_ipaddress {
61.135.93.100
}
}
virtual_server 61.135.93.100 3000 {
delay_loop 6
lb_algo wlc
lb_kind DR
persistence_timeout 50
protocol TCP
real_server 61.135.93.84 3000{
weight 100
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 3000
}
}
real_server 61.135.93.85 3000{
weight 100
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 3000
}
}
real_server 61.135.93.86 3000{
weight 100
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 3000
}
}
real_server 61.135.93.87 3000{
weight 100
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 3000
}
}
}
virtual_server 61.135.93.100 4000 {
delay_loop 6
lb_algo wlc
lb_kind DR
persistence_timeout 50
protocol TCP
real_server 61.135.93.88 4000{
weight 100
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 4000
}
}
real_server 61.135.93.89 4000{
weight 100
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 4000
}
}
real_server 61.135.93.90 4000{
weight 100
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 4000
}
}
real_server 61.135.93.91 4000{
weight 100
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 4000
}
}
}
|
Lvs_1 的ipvsadm输出(部分)
|
Lvs_2 的ipvsadm输出(部分)
|
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 61.128.10.4:9000 wlc persistent 50
-> 61.128.10.16:9000 Route 200 4607 139
-> 61.128.10.17:9000 Route 200 4611 154
-> 61.128.10.5:9000 Route 100 2306 65
-> 61.128.10.8:9000 Route 100 2307 89
………………………………
TCP 61.128.20.124:http wlc persistent 30
-> 61.128.20.98:http Route 100 0 0
-> 61.128.20.93:http Route 100 0 0
-> 61.128.20.81:http Route 100 0 0
-> 61.128.20.82:http Route 100 0 0
|
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 61.128.10.4:9000 wlc persistent 50
-> 61.128.10.16:9000 Route 100 0 0
-> 61.128.10.17:9000 Route 100 0 0
-> 61.128.10.5:9000 Route 100 0 0
-> 61.128.10.8:9000 Route 100 0 0
……………………………
TCP 61.128.20.124:http wlc persistent 20
-> 61.128.20.98:http Route 100 821 1437
-> 61.128.20.93:http Route 100 823 1562
-> 61.128.20.82:http Route 100 823 1336
-> 61.128.20.81:http Route 100 825 1033
|