我已经使用 Piranha 为 httpd 设置故障转移。我将服务器设置为相同,但一个显示 VIPS 而另一个不显示。这是正常的吗?
服务器 A) [主要]
[root@titania ~]# ipvsadm -L
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 172.16.28.231:http lblc
-> 172.16.28.229:http Route 1 0 0
-> 172.16.28.230:http Route 1 0 0
[root@titania ~]
[root@titania ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:15:5D:1C:D4:04
inet addr:172.16.28.233 Bcast:172.16.28.255 Mask:255.255.255.0
inet6 addr: fe80::215:5dff:fe1c:d404/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1115300 errors:0 dropped:0 overruns:0 frame:0
TX packets:686246 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:115178238 (109.8 MiB) TX bytes:50225507 (47.8 MiB)
eth0:1 Link encap:Ethernet HWaddr 00:15:5D:1C:D4:04
inet addr:172.16.28.231 Bcast:172.16.28.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:838 (838.0 b) TX bytes:838 (838.0 b)
[root@titania ~]#
[root@titania ~]# cat /etc/sysconfig/ha/lvs.cf
serial_no = 53
primary = 172.16.28.233
service = lvs
backup_active = 1
backup = 172.16.28.232
heartbeat = 1
heartbeat_port = 539
keepalive = 6
deadtime = 18
network = direct
debug_level = NONE
monitor_links = 1
syncdaemon = 1
syncd_iface = eth0
syncd_id = 0
virtual http {
active = 1
address = 172.16.28.231 eth0:1
vip_nmask = 255.255.255.0
port = 80
send = "GET / HTTP/1.0\r\n\r\n"
expect = "HTTP"
use_regex = 0
load_monitor = none
scheduler = lblc
protocol = tcp
timeout = 6
reentry = 15
quiesce_server = 1
server deimos {
address = 172.16.28.229
active = 1
weight = 1
}
server phobos {
address = 172.16.28.230
active = 1
weight = 1
}
}
[root@titania ~]#
服务器 B) [次要]
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
[root@titan ~]#
[root@titan ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:15:5D:1C:34:01
inet addr:172.16.28.232 Bcast:172.16.28.255 Mask:255.255.255.0
inet6 addr: fe80::215:5dff:fe1c:3401/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:529515 errors:0 dropped:0 overruns:0 frame:0
TX packets:81242 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:31911311 (30.4 MiB) TX bytes:4919228 (4.6 MiB)
Interrupt:9 Base address:0x2000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:236 errors:0 dropped:0 overruns:0 frame:0
TX packets:236 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:22532 (22.0 KiB) TX bytes:22532 (22.0 KiB)
[root@titan ~]#
[root@titan ~]# cat /etc/sysconfig/ha/lvs.cf
serial_no = 51
primary = 172.16.28.233
service = lvs
backup_active = 1
backup = 172.16.28.232
heartbeat = 1
heartbeat_port = 539
keepalive = 6
deadtime = 18
network = direct
debug_level = NONE
monitor_links = 1
syncdaemon = 1
syncd_iface = eth0
syncd_id = 0
virtual http {
active = 1
address = 172.16.28.231 eth0:1
vip_nmask = 255.255.255.0
port = 80
send = "GET / HTTP/1.0\r\n\r\n"
expect = "HTTP"
use_regex = 0
load_monitor = none
scheduler = lblc
protocol = tcp
timeout = 6
reentry = 15
quiesce_server = 1
server deimos {
address = 172.16.28.229
active = 1
weight = 1
}
server phobos {
address = 172.16.28.230
active = 1
weight = 1
}
}
[root@titan ~]#
是的,这是 LVS 的正常和预期行为。
由于这是一个高可用性设置,负载平衡 IP(本例中为 172.16.28.231)将仅驻留在活动节点上。如果您要停止服务器 A 上的脉冲守护进程,负载平衡 IP 到服务器 B 的故障转移将自动发生(假设脉冲守护进程正在运行并且服务器 B 处于健康状态)。故障转移应该几乎是瞬时的,一旦发生,重新启动服务器 A 上的脉冲守护进程。
此工作流和故障转移验证的命令如下:
您将能够使用此方法在节点之间来回进行故障转移。