Implementation of failover and load Balancing cluster with Carp

Source: Internet
Author: User
Tags failover

These two days in a detailed look at the man carp document. found that the original carp can not only achieve failover (failover) cluster, through a simple configuration or can be a local LAN load balance.

Carp load Balancing uses the Arpbalance function, which is understood literally as the use of ARP load balancing, that is, the second layer of the OSI7 layer model-the data link layer. Therefore, using arpbalance can only be applied to local LAN, can not achieve a higher level of balance.

The principle is roughly as follows

Two servers A, B, the establishment of two Carp Virtual network card a1, A2, B1, B2, where A1, B1 as a carp group (that is, the same vhid), the remaining two network cards for another carp group. A1 is master,b1 as slave in the first Carp group. In the second Carp group, exactly the opposite, A2 is slave,b2 as master. These two carp groups have the same virtual IP.

So arpbalance can rotate between the two groups. When using the CARP1 group, the A1 is master. So the service is provided by a at this time, and when the CARP2 group is used, the service is provided by B because B2 is master.

At the same time, the rotary algorithm is based on the source IP address hash algorithm to ensure that the same source address by the fixed carp group to provide services, can ensure that the client session and other applications.

The following steps are implemented

Modify the configuration file on Server A

ee/etc/rc.conf #配置rc. conf file, establish CARP virtual network card respectively. Add the following content

cloned_interfaces= "Carp0 Carp1"

ifconfig_carp0= "Vhid 1 advbase 5 pass passwd 192.168.1.100/24"

Ifconfig_carp1= "Vhid 2 advbase 5 Advskew pass passwd 192.168.1.100/24"

Ee/etc/sysctl.conf #修改sysctl文件启用carp的arpbalance和carp抢占功能. Add the following content

Net.inet.carp.preempt=1

Net.inet.carp.arpbalance=1

Modified on Server B is roughly the same, just a little change in the carp NIC

ee/etc/rc.conf #配置rc. conf file, establish CARP virtual network card respectively. Add the following content

cloned_interfaces= "Carp0 Carp1"

ifconfig_carp0= "Vhid 1 advbase 5 Advskew pass passwd 192.168.1.100/24"

Ifconfig_carp1= "Vhid 2 advbase 5 pass passwd 192.168.1.100/24"

Ee/etc/sysctl.conf #修改sysctl文件启用carp的arpbalance和carp抢占功能. Add the following content

Net.inet.carp.preempt=1

Net.inet.carp.arpbalance=1

Restarting two servers will take effect.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.