Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

1.3. LVS 调​​​​​​​度​​​​​​​总​​​​​​​览​​​​​​​

使​​​​​​​用​​​​​​​ LVS 的​​​​​​​优​​​​​​​点​​​​​​​之​​​​​​​一​​​​​​​就​​​​​​​是​​​​​​​它​​​​​​​的​​​​​​​灵​​​​​​​活​​​​​​​性​​​​​​​,即​​​​​​​可​​​​​​​将​​​​​​​ IP 级​​​​​​​别​​​​​​​负​​​​​​​载​​​​​​​均​​​​​​​衡​​​​​​​到​​​​​​​真​​​​​​​实​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​中​​​​​​​。​​​​​​​这​​​​​​​种​​​​​​​灵​​​​​​​活​​​​​​​性​​​​​​​是​​​​​​​因​​​​​​​为​​​​​​​配​​​​​​​置​​​​​​​ LVS 时​​​​​​​管​​​​​​​理​​​​​​​员​​​​​​​可​​​​​​​以​​​​​​​选​​​​​​​择​​​​​​​各​​​​​​​种​​​​​​​调​​​​​​​度​​​​​​​算​​​​​​​法​​​​​​​。​​​​​​​LVS 负​​​​​​​载​​​​​​​平​​​​​​​衡​​​​​​​相​​​​​​​对​​​​​​​较​​​​​​​少​​​​​​​灵​​​​​​​活​​​​​​​性​​​​​​​的​​​​​​​方​​​​​​​法​​​​​​​来​​​​​​​说​​​​​​​更​​​​​​​高​​​​​​​级​​​​​​​一​​​​​​​些​​​​​​​,比​​​​​​​如​​​​​​​轮​​​​​​​叫​​​​​​​ DNS,使​​​​​​​用​​​​​​​这​​​​​​​种​​​​​​​方​​​​​​​法​​​​​​​引​​​​​​​起​​​​​​​的​​​​​​​ DNS 层​​​​​​​级​​​​​​​性​​​​​​​和​​​​​​​客​​​​​​​户​​​​​​​端​​​​​​​机​​​​​​​器​​​​​​​缓​​​​​​​存​​​​​​​会​​​​​​​导​​​​​​​致​​​​​​​负​​​​​​​载​​​​​​​失​​​​​​​衡​​​​​​​。​​​​​​​另​​​​​​​外​​​​​​​,LVS 使​​​​​​​用​​​​​​​的​​​​​​​底​​​​​​​层​​​​​​​过​​​​​​​滤​​​​​​​比​​​​​​​应​​​​​​​用​​​​​​​程​​​​​​​序​​​​​​​层​​​​​​​请​​​​​​​求​​​​​​​转​​​​​​​发​​​​​​​更​​​​​​​有​​​​​​​利​​​​​​​,因​​​​​​​为​​​​​​​在​​​​​​​网​​​​​​​络​​​​​​​数​​​​​​​据​​​​​​​包​​​​​​​级​​​​​​​别​​​​​​​的​​​​​​​平​​​​​​​衡​​​​​​​负​​​​​​​载​​​​​​​引​​​​​​​起​​​​​​​的​​​​​​​计​​​​​​​算​​​​​​​超​​​​​​​载​​​​​​​最​​​​​​​小​​​​​​​,并​​​​​​​可​​​​​​​允​​​​​​​许​​​​​​​更​​​​​​​大​​​​​​​的​​​​​​​可​​​​​​​伸​​​​​​​缩​​​​​​​性​​​​​​​。​​​​​​​
Using scheduling, the active router can take into account the real servers' activity and, optionally, an administrator-assigned weight factor when routing service requests. Using assigned weights gives arbitrary priorities to individual machines. Using this form of scheduling, it is possible to create a group of real servers using a variety of hardware and software combinations and the active router can evenly load each real server.
用​​​​​​​于​​​​​​​ LVS 的​​​​​​​调​​​​​​​度​​​​​​​机​​​​​​​制​​​​​​​是​​​​​​​由​​​​​​​名​​​​​​​为​​​​​​​ IP 虚​​​​​​​拟​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​或​​​​​​​者​​​​​​​ IPVS 模​​​​​​​块​​​​​​​的​​​​​​​内​​​​​​​核​​​​​​​补​​​​​​​丁​​​​​​​集​​​​​​​合​​​​​​​提​​​​​​​供​​​​​​​的​​​​​​​。​​​​​​​这​​​​​​​些​​​​​​​模​​​​​​​块​​​​​​​启​​​​​​​用​​​​​​​了​​​​​​​ layer 4L4)传​​​​​​​输​​​​​​​层​​​​​​​选​​​​​​​项​​​​​​​,该​​​​​​​选​​​​​​​项​​​​​​​是​​​​​​​设​​​​​​​计​​​​​​​用​​​​​​​来​​​​​​​在​​​​​​​单​​​​​​​一​​​​​​​ IP 地​​​​​​​址​​​​​​​中​​​​​​​更​​​​​​​好​​​​​​​地​​​​​​​使​​​​​​​用​​​​​​​多​​​​​​​个​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​。​​​​​​​
要​​​​​​​追​​​​​​​踪​​​​​​​数​​​​​​​据​​​​​​​包​​​​​​​并​​​​​​​将​​​​​​​其​​​​​​​有​​​​​​​效​​​​​​​路​​​​​​​由​​​​​​​到​​​​​​​真​​​​​​​实​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​中​​​​​​​,IPVS 会​​​​​​​在​​​​​​​内​​​​​​​核​​​​​​​中​​​​​​​建​​​​​​​立​​​​​​​一​​​​​​​个​​​​​​​ IPVS 表​​​​​​​。​​​​​​​活​​​​​​​跃​​​​​​​ LVS 路​​​​​​​由​​​​​​​器​​​​​​​使​​​​​​​用​​​​​​​这​​​​​​​个​​​​​​​列​​​​​​​表​​​​​​​将​​​​​​​来​​​​​​​自​​​​​​​虚​​​​​​​拟​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​地​​​​​​​址​​​​​​​的​​​​​​​请​​​​​​​求​​​​​​​重​​​​​​​新​​​​​​​路​​​​​​​由​​​​​​​并​​​​​​​返​​​​​​​回​​​​​​​真​​​​​​​实​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​池​​​​​​​中​​​​​​​的​​​​​​​真​​​​​​​实​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​中​​​​​​​。​​​​​​​ipvsadm 程​​​​​​​序​​​​​​​可​​​​​​​随​​​​​​​时​​​​​​​更​​​​​​​新​​​​​​​ IPVS 列​​​​​​​表​​​​​​​ — 根​​​​​​​据​​​​​​​其​​​​​​​可​​​​​​​用​​​​​​​性​​​​​​​添​​​​​​​加​​​​​​​和​​​​​​​删​​​​​​​除​​​​​​​群​​​​​​​集​​​​​​​成​​​​​​​员​​​​​​​。​​​​​​​

1.3.1. 调​​​​​​​度​​​​​​​算​​​​​​​法​​​​​​​

The structure that the IPVS table takes depends on the scheduling algorithm that the administrator chooses for any given virtual server. To allow for maximum flexibility in the types of services you can cluster and how these services are scheduled, Red Hat Enterprise Linux provides the following scheduling algorithms listed below. For instructions on how to assign scheduling algorithms refer to 第 4.6.1 节 “「​​​​​​​虚​​​​​​​拟​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​」​​​​​​​子​​​​​​​界​​​​​​​面​​​​​​​”.
Round-Robin Scheduling
连​​​​​​​续​​​​​​​在​​​​​​​真​​​​​​​实​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​池​​​​​​​中​​​​​​​分​​​​​​​配​​​​​​​每​​​​​​​个​​​​​​​请​​​​​​​求​​​​​​​。​​​​​​​使​​​​​​​用​​​​​​​此​​​​​​​算​​​​​​​法​​​​​​​,所​​​​​​​有​​​​​​​真​​​​​​​实​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​都​​​​​​​会​​​​​​​被​​​​​​​同​​​​​​​等​​​​​​​对​​​​​​​待​​​​​​​,而​​​​​​​不​​​​​​​考​​​​​​​虑​​​​​​​其​​​​​​​容​​​​​​​量​​​​​​​或​​​​​​​者​​​​​​​负​​​​​​​载​​​​​​​。​​​​​​​这​​​​​​​种​​​​​​​调​​​​​​​度​​​​​​​模​​​​​​​式​​​​​​​延​​​​​​​续​​​​​​​了​​​​​​​轮​​​​​​​叫​​​​​​​ DNS 但​​​​​​​更​​​​​​​加​​​​​​​粗​​​​​​​糙​​​​​​​,因​​​​​​​为​​​​​​​它​​​​​​​是​​​​​​​基​​​​​​​于​​​​​​​网​​​​​​​络​​​​​​​连​​​​​​​接​​​​​​​而​​​​​​​不​​​​​​​是​​​​​​​基​​​​​​​于​​​​​​​主​​​​​​​机​​​​​​​。​​​​​​​LVS 轮​​​​​​​叫​​​​​​​调​​​​​​​度​​​​​​​不​​​​​​​会​​​​​​​陷​​​​​​​入​​​​​​​由​​​​​​​ DNS 缓​​​​​​​存​​​​​​​查​​​​​​​询​​​​​​​造​​​​​​​成​​​​​​​的​​​​​​​负​​​​​​​载​​​​​​​失​​​​​​​衡​​​​​​​状​​​​​​​态​​​​​​​。​​​​​​​
Weighted Round-Robin Scheduling
Distributes each request sequentially around the pool of real servers but gives more jobs to servers with greater capacity. Capacity is indicated by a user-assigned weight factor, which is then adjusted upward or downward by dynamic load information. Refer to 第 1.3.2 节 “服​​​​​​​务​​​​​​​器​​​​​​​加​​​​​​​权​​​​​​​和​​​​​​​调​​​​​​​度​​​​​​​” for more on weighting real servers.
如​​​​​​​果​​​​​​​真​​​​​​​实​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​池​​​​​​​中​​​​​​​的​​​​​​​真​​​​​​​实​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​之​​​​​​​间​​​​​​​有​​​​​​​显​​​​​​​著​​​​​​​的​​​​​​​差​​​​​​​别​​​​​​​,加​​​​​​​权​​​​​​​轮​​​​​​​叫​​​​​​​调​​​​​​​度​​​​​​​就​​​​​​​是​​​​​​​首​​​​​​​选​​​​​​​。​​​​​​​但​​​​​​​是​​​​​​​,如​​​​​​​果​​​​​​​请​​​​​​​求​​​​​​​的​​​​​​​负​​​​​​​载​​​​​​​有​​​​​​​很​​​​​​​大​​​​​​​不​​​​​​​同​​​​​​​,那​​​​​​​么​​​​​​​加​​​​​​​权​​​​​​​强​​​​​​​的​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​会​​​​​​​回​​​​​​​应​​​​​​​更​​​​​​​多​​​​​​​的​​​​​​​请​​​​​​​求​​​​​​​。​​​​​​​
Least-Connection
为​​​​​​​有​​​​​​​较​​​​​​​少​​​​​​​活​​​​​​​跃​​​​​​​连​​​​​​​接​​​​​​​的​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​发​​​​​​​送​​​​​​​更​​​​​​​多​​​​​​​请​​​​​​​求​​​​​​​。​​​​​​​因​​​​​​​为​​​​​​​它​​​​​​​会​​​​​​​通​​​​​​​过​​​​​​​ IPVS 列​​​​​​​表​​​​​​​追​​​​​​​踪​​​​​​​到​​​​​​​真​​​​​​​实​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​的​​​​​​​活​​​​​​​跃​​​​​​​连​​​​​​​接​​​​​​​,最​​​​​​​小​​​​​​​连​​​​​​​接​​​​​​​是​​​​​​​动​​​​​​​态​​​​​​​调​​​​​​​度​​​​​​​算​​​​​​​法​​​​​​​的​​​​​​​一​​​​​​​类​​​​​​​,在​​​​​​​请​​​​​​​求​​​​​​​负​​​​​​​载​​​​​​​差​​​​​​​别​​​​​​​很​​​​​​​大​​​​​​​时​​​​​​​是​​​​​​​上​​​​​​​佳​​​​​​​选​​​​​​​择​​​​​​​。​​​​​​​它​​​​​​​最​​​​​​​适​​​​​​​用​​​​​​​于​​​​​​​每​​​​​​​个​​​​​​​节​​​​​​​点​​​​​​​有​​​​​​​类​​​​​​​似​​​​​​​容​​​​​​​量​​​​​​​的​​​​​​​真​​​​​​​实​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​池​​​​​​​。​​​​​​​如​​​​​​​果​​​​​​​一​​​​​​​组​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​有​​​​​​​不​​​​​​​同​​​​​​​的​​​​​​​容​​​​​​​量​​​​​​​,加​​​​​​​权​​​​​​​最​​​​​​​小​​​​​​​连​​​​​​​接​​​​​​​调​​​​​​​度​​​​​​​则​​​​​​​是​​​​​​​更​​​​​​​好​​​​​​​的​​​​​​​选​​​​​​​择​​​​​​​。​​​​​​​
Weighted Least-Connections (default)
Distributes more requests to servers with fewer active connections relative to their capacities. Capacity is indicated by a user-assigned weight, which is then adjusted upward or downward by dynamic load information. The addition of weighting makes this algorithm ideal when the real server pool contains hardware of varying capacity. Refer to 第 1.3.2 节 “服​​​​​​​务​​​​​​​器​​​​​​​加​​​​​​​权​​​​​​​和​​​​​​​调​​​​​​​度​​​​​​​” for more on weighting real servers.
Locality-Based Least-Connection Scheduling
为​​​​​​​与​​​​​​​相​​​​​​​对​​​​​​​它​​​​​​​们​​​​​​​的​​​​​​​目​​​​​​​的​​​​​​​ IP 有​​​​​​​更​​​​​​​少​​​​​​​活​​​​​​​跃​​​​​​​连​​​​​​​接​​​​​​​的​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​分​​​​​​​配​​​​​​​更​​​​​​​多​​​​​​​的​​​​​​​请​​​​​​​求​​​​​​​。​​​​​​​这​​​​​​​种​​​​​​​算​​​​​​​法​​​​​​​是​​​​​​​设​​​​​​​计​​​​​​​用​​​​​​​于​​​​​​​代​​​​​​​理​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​缓​​​​​​​存​​​​​​​的​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​群​​​​​​​集​​​​​​​。​​​​​​​它​​​​​​​会​​​​​​​为​​​​​​​ IP 地​​​​​​​址​​​​​​​将​​​​​​​数​​​​​​​据​​​​​​​包​​​​​​​路​​​​​​​由​​​​​​​到​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​,除​​​​​​​非​​​​​​​该​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​已​​​​​​​经​​​​​​​超​​​​​​​过​​​​​​​了​​​​​​​它​​​​​​​的​​​​​​​容​​​​​​​量​​​​​​​,并​​​​​​​另​​​​​​​有​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​只​​​​​​​使​​​​​​​用​​​​​​​了​​​​​​​容​​​​​​​量​​​​​​​的​​​​​​​一​​​​​​​半​​​​​​​,在​​​​​​​这​​​​​​​种​​​​​​​情​​​​​​​况​​​​​​​下​​​​​​​,它​​​​​​​会​​​​​​​将​​​​​​​ IP 地​​​​​​​址​​​​​​​分​​​​​​​配​​​​​​​给​​​​​​​最​​​​​​​小​​​​​​​负​​​​​​​载​​​​​​​的​​​​​​​真​​​​​​​实​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​。​​​​​​​
Locality-Based Least-Connection Scheduling with Replication Scheduling
为​​​​​​​与​​​​​​​相​​​​​​​对​​​​​​​它​​​​​​​们​​​​​​​的​​​​​​​目​​​​​​​的​​​​​​​ IP 有​​​​​​​更​​​​​​​少​​​​​​​活​​​​​​​跃​​​​​​​连​​​​​​​接​​​​​​​的​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​分​​​​​​​配​​​​​​​更​​​​​​​多​​​​​​​的​​​​​​​请​​​​​​​求​​​​​​​。​​​​​​​这​​​​​​​种​​​​​​​算​​​​​​​法​​​​​​​是​​​​​​​设​​​​​​​计​​​​​​​用​​​​​​​于​​​​​​​代​​​​​​​理​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​缓​​​​​​​存​​​​​​​的​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​群​​​​​​​集​​​​​​​。​​​​​​​它​​​​​​​和​​​​​​​使​​​​​​​用​​​​​​​将​​​​​​​目​​​​​​​标​​​​​​​ IP 与​​​​​​​真​​​​​​​实​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​节​​​​​​​点​​​​​​​的​​​​​​​子​​​​​​​网​​​​​​​络​​​​​​​进​​​​​​​行​​​​​​​映​​​​​​​射​​​​​​​的​​​​​​​局​​​​​​​部​​​​​​​最​​​​​​​小​​​​​​​连​​​​​​​接​​​​​​​调​​​​​​​度​​​​​​​不​​​​​​​同​​​​​​​。​​​​​​​请​​​​​​​求​​​​​​​会​​​​​​​被​​​​​​​路​​​​​​​由​​​​​​​到​​​​​​​子​​​​​​​网​​​​​​​络​​​​​​​中​​​​​​​有​​​​​​​最​​​​​​​少​​​​​​​连​​​​​​​接​​​​​​​的​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​中​​​​​​​。​​​​​​​如​​​​​​​果​​​​​​​目​​​​​​​的​​​​​​​ IP 的​​​​​​​所​​​​​​​有​​​​​​​节​​​​​​​点​​​​​​​都​​​​​​​超​​​​​​​过​​​​​​​了​​​​​​​容​​​​​​​量​​​​​​​,它​​​​​​​会​​​​​​​为​​​​​​​那​​​​​​​个​​​​​​​目​​​​​​​的​​​​​​​ IP 复​​​​​​​制​​​​​​​一​​​​​​​个​​​​​​​新​​​​​​​的​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​,这​​​​​​​可​​​​​​​通​​​​​​​过​​​​​​​将​​​​​​​真​​​​​​​实​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​池​​​​​​​中​​​​​​​那​​​​​​​个​​​​​​​有​​​​​​​最​​​​​​​小​​​​​​​连​​​​​​​接​​​​​​​的​​​​​​​真​​​​​​​实​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​为​​​​​​​目​​​​​​​的​​​​​​​地​​​​​​​址​​​​​​​ IP 添​​​​​​​加​​​​​​​到​​​​​​​真​​​​​​​实​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​的​​​​​​​子​​​​​​​网​​​​​​​中​​​​​​​实​​​​​​​现​​​​​​​。​​​​​​​然​​​​​​​后​​​​​​​会​​​​​​​从​​​​​​​真​​​​​​​实​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​子​​​​​​​网​​​​​​​中​​​​​​​除​​​​​​​去​​​​​​​负​​​​​​​载​​​​​​​最​​​​​​​大​​​​​​​的​​​​​​​节​​​​​​​点​​​​​​​以​​​​​​​免​​​​​​​过​​​​​​​度​​​​​​​重​​​​​​​复​​​​​​​。​​​​​​​
Destination Hash Scheduling
通​​​​​​​过​​​​​​​在​​​​​​​静​​​​​​​态​​​​​​​散​​​​​​​列​​​​​​​列​​​​​​​表​​​​​​​中​​​​​​​查​​​​​​​看​​​​​​​目​​​​​​​的​​​​​​​ IP 来​​​​​​​将​​​​​​​请​​​​​​​求​​​​​​​分​​​​​​​配​​​​​​​到​​​​​​​真​​​​​​​实​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​池​​​​​​​中​​​​​​​。​​​​​​​这​​​​​​​个​​​​​​​算​​​​​​​法​​​​​​​是​​​​​​​设​​​​​​​计​​​​​​​用​​​​​​​于​​​​​​​代​​​​​​​理​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​缓​​​​​​​存​​​​​​​的​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​群​​​​​​​集​​​​​​​。​​​​​​​
Source Hash Scheduling
通​​​​​​​过​​​​​​​在​​​​​​​静​​​​​​​态​​​​​​​散​​​​​​​列​​​​​​​列​​​​​​​表​​​​​​​中​​​​​​​查​​​​​​​看​​​​​​​目​​​​​​​的​​​​​​​ IP 来​​​​​​​将​​​​​​​请​​​​​​​求​​​​​​​分​​​​​​​配​​​​​​​到​​​​​​​真​​​​​​​实​​​​​​​服​​​​​​​务​​​​​​​器​​​​​​​池​​​​​​​中​​​​​​​。​​​​​​​这​​​​​​​个​​​​​​​算​​​​​​​法​​​​​​​是​​​​​​​为​​​​​​​带​​​​​​​多​​​​​​​个​​​​​​​防​​​​​​​火​​​​​​​墙​​​​​​​的​​​​​​​ LVS 路​​​​​​​由​​​​​​​器​​​​​​​设​​​​​​​计​​​​​​​的​​​​​​​。​​​​​​​