Technology of Virtual IP Address

2020-10-05 07:19:57 virtualip

High Availability (HA) refers to improving the availability of systems and applications by minimizing downtime caused by routine maintenance operations (planned) and sudden system crashes (unplanned). HA system is currently the most effective means for enterprises to prevent the core computer system from shutting down due to failure. To achieve HA, two machines are generally used to complete a function at the same time, such as a database server. Usually, only one machine provides external services, and the other machine serves as a hot backup. When this machine fails, it will automatically switch to the other standby machine dynamically.

Principles of Virtual IP Technology

1. How to realize fault detection?

Send a data packet regularly. If the machine does not respond for a certain period, it will be considered as a failure and automatically switch to the standby machine.

2. How to realize automatic switchover between active and standby?

We can get this from the virtual IP technology. A virtual IP is an IP that is not assigned to a real host, which means that the host that provides the database server to the outside has a virtual IP also a real IP. You can connect to this host using either of these two IPs. The virtual IP is configured for the database link in all projects. When the server fails to provide services to the outside world, the virtual IP is dynamically switched to the standby host. Its realization principle mainly relies on TCP/IP's ARP protocol. Since the IP address is only a logical address, the MAC address in the Ethernet is the physical address that is actually used for data transmission. Each host has an ARP cache that stores the correspondence between the IP address and the MAC address in the same network Relationship, when the host in the Ethernet sends data, it will first query the MAC address corresponding to the target IP from this cache, and send data to this MAC address. The operating system will automatically maintain this cache. This is the key to the entire implementation, such as the following ARP cache example:

( at 00:21:5A:DB:68:E8 [ether] on bond0
( at 00:21:5A:DB:68:E8 [ether] on bond0
( at 00:21:5A:DB:7F:C2 [ether] on bond0

Among them, and are two real computers, is the host that provides database services to the outside world, is the hot standby machine, and is the virtual IP. Pay attention to the MAC addresses of 219 and 217 Are the same. When 218 finds that 217 is down, it will send an ARP packet to the network, telling all hosts that the MAC address corresponding to this IP is 00:21:5A:DB:7F:C2, so that all packets sent to 219 will be Send to the machine with the MAC address 00:21:5A:DB:7F:C2, which is the machine with 218.

3. Configure and Delete virtual IP

If the host has a network card eth1, its corresponding IP is, now set a virtual IP for it:

ifconfig eth1:1 netmask

Delete the virtual IP:

ip addr del dev eth1

However, in network operation and maintenance, it is more common to use keepalived to configure virtual ip (vip) to achieve dual-system hot backup and automatically switch between active and standby.

IP address is important to our internet activities, we hope that you have learned through our articles. If you are interested to know more, feel free to read our blog or follow us on LinkedIn.

(Source: Internet)