运行成功后的效果:
ipvsadm -ln
IP Virtual Server version 1.2.1 (size=4194304)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 10.153.79.120:80 rr synproxy
-> 10.153.74.118:80 FullNat 1 0 0
-> 10.153.74.139:80 FullNat 1 0 0
-> 10.153.74.140:80 FullNat 1 0 0
-> 10.153.74.141:80 FullNat 1 0 0
-> 10.153.74.142:80 FullNat 1 0 0
正常的message日志:
Keepalived_healthcheckers: Enabling service [10.153.74.140]:80 to VS [qiyi]:0
Jul 30 16:13:05 10 Keepalived_healthcheckers: TCP connection to [10.153.74.141]:80 success.
Jul 30 16:13:05 10 Keepalived_healthcheckers: Enabling service [10.153.74.141]:80 to VS [qiyi]:0
Jul 30 16:13:05 10 ntpd[2688]: Deleting interface #7 eth0, 10.153.79.120#123, interface stats: received=0, sent=0, dropped=0, active_time=118 secs
Jul 30 16:13:06 10 Keepalived_vrrp: VRRP_Instance(VI_1) Entering MASTER STATE
Jul 30 16:13:06 10 Keepalived_vrrp: VRRP_Instance(VI_1) setting protocol VIPs.
Jul 30 16:13:06 10 Keepalived_healthcheckers: Netlink reflector reports IP 10.153.79.120 added
Jul 30 16:13:06 10 Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 10.153.79.120
Jul 30 16:13:07 10 ntpd[2688]: Listening on interface #8 eth0, 10.153.79.120#123 Enabled
Jul 30 16:13:11 10 Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 10.153.79.120
出错的地方在“:
real_server 10.153.74.118 80 {
weight 1
inhibit_on_failure
TCP_CHECK {
connect_timeout 4
}
}
这一段加了HTTP_GET的配置,导致FULLNAT连不上,具体的原因在于:
HTTP_GET{ HTTP_GET和后面的{ 忘记了加空格,导致脚本错误,本身FULLNAT也是支持HTTP_GET的健康检查的
lvs上面的配置文件:
gobal_defs {
notification_email {
acassen@firewall.loc
failover@firewall.loc
sysadmin@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_connect_timeout 30
router_id LVS_DEVEL
}
local_address_group laddr_g1 {
10.153.79.121
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 200
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass 123456
}
virtual_ipaddress {
10.153.79.120/21
}
}
virtual_server_group qiyi {
10.153.79.120 80 //vip1
}
virtual_server group qiyi {
delay_loop 6
lb_algo rr
lb_kind FNAT
syn_proxy
laddr_group_name laddr_g1
protocol TCP
# persistence_timeout 50
omega
quorum 1
alpha
hysteresis 0
real_server 10.153.74.142 80 {
weight 1
inhibit_on_failure
TCP_CHECK {
connect_timeout 4
}
}
real_server 10.153.74.118 80 {
weight 1
inhibit_on_failure
TCP_CHECK {
connect_timeout 4
}
}
real_server 10.153.74.139 80 {
weight 1
inhibit_on_failure
TCP_CHECK {
connect_timeout 4
}
}
real_server 10.153.74.140 80 {
weight 1
inhibit_on_failure
TCP_CHECK {
connect_timeout 4
}
}
real_server 10.153.74.141 80 {
weight 1
inhibit_on_failure
TCP_CHECK {
connect_timeout 4
}
}
}