如果一台real server宕机,如何让负载自动全部转至另一台?
新人求助一下。
用LVS搭建SSH服务的负载均衡。
目前采用NAT方式,一台服务器做router,运行lvs服务,另外两台是real server,暂且叫做a和b。
我尝试了rr、wcl、wrr策略,可以实现均衡的负载。但是,如果我手动重启其中一台,比如重启a,然后ssh vip的时候,如果恰巧轮转到a,那么就会卡住,直到报ssh time out。然后再ssh vip,由于轮询到了b,这时就正常登陆了。
我看lvs文档中写的,应该是具备这种容错机制的。但不知道哪里设置的不对。请各位帮忙看下。
着急~~~~!还请各位前辈指点!
配置如下:
------------------lvs.cf-------------------------
serial_no = 22
primary = 192.168.118.9
service = lvs
rsh_command = ssh
backup_active = 1
backup = 0.0.0.0
heartbeat = 1
heartbeat_port = 539
keepalive = 6
deadtime = 18
network = nat
nat_router = 11.11.10.72 eth2
nat_nmask = 255.255.0.0
debug_level = NONE
virtual server1 {
active = 1
address = 192.168.118.11 eth1:1
vip_nmask = 255.255.255.0
fwmark = 100
port = 22
persistent = 60
pmask = 255.255.255.255
send = "quit" ///////////这里的send和expect不是很了解语法,这种写法是在网上找的,不知道对不?
expect = ".*SSH.*"
load_monitor = none
scheduler = wlc
protocol = tcp
timeout = 5
reentry = 10
quiesce_server = 1
server server1 {
address = 11.11.10.73
active = 1
weight = 1
}
server server2 {
address = 11.11.10.74
active = 1
weight = 1
}
}
----------------------添加的路由策略------------------------------
ipvsadm -A -t 192.168.118.11:22 -s wlc
ipvsadm -a -t 192.168.118.11:22 -r 11.11.10.73:22 -m
ipvsadm -a -t 192.168.118.11:22 -r 11.11.10.74:22 -m
----------------重启一台后的/var/log/message日志-------------------
Dec 23 16:04:51 lb nanny[431]: CONNECT to 11.11.10.73:22 timed out
Dec 23 16:05:01 lb nanny[431]: CONNECT to 11.11.10.73:22 timed out
Dec 23 16:05:11 lb nanny[431]: CONNECT to 11.11.10.73:22 timed out
----------------------重启一台后的路由表----------------------
[root@lb ~]# ipvsadm -L
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.118.11:ssh wlc
-> login1:ssh Masq 1 0 2
-> login2:ssh Masq 1 1 2
-------------------------SSH连接报错-----------------------------
(其中连接了一台,另一台连不上,直到报
[root@manager ~]# ssh 192.168.118.11
ssh: connect to host 192.168.118.11 port 22: Connection timed out)
-------------------real server a的网络配置-----------------------
DEVICE="eth2"
BOOTPROTO="static"
HWADDR="00:E0:ED:27:8A:EA"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
IPADDR="11.11.10.73"
NETMASK="255.255.0.0"
USERCTL="no"
GATEWAY="11.11.10.72"
-------------------real server b的网络配置-----------------------
DEVICE="eth2"
BOOTPROTO="static"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
USERCTL=no
IPADDR="11.11.10.74"
NETMASK="255.255.0.0"
GATEWAY="11.11.10.72"