本文主要介绍了利用Keepalived实现简单的VIP自动切换。
Configuring Simple Virtual IP Address Failover Using Keepalived
A typical Keepalived high-availability configuration consists of one master server and one or more backup servers. One or more virtual IP addresses, defined as VRRP instances, are assigned to the master server’s network interfaces so that it can service network clients. The backup servers listen for multicast VRRP advertisement packets that the master server transmits at regular intervals. The default advertisement interval is one second. If the backup nodes fail to receive three consecutive VRRP advertisements, the backup server with the highest assigned priority takes over as the master server and assigns the virtual IP addresses to its own network interfaces. If several backup servers have the same priority, the backup server with the highest IP address value becomes the master server.
The following example uses Keepalived to implement a simple failover configuration on two servers. One server acts as the master, the other acts as a backup, and the master server has a higher priority than the backup server.
the virtual IP address 10.0.0.100 is initially assigned to the master server (10.0.0.71). When the master server fails, the backup server (10.0.0.72) becomes the new master server and is assigned the virtual IP address 10.0.0.100.
配置文件
/etc/keepalived/keepalived.conf
on the master server:
|
|
/etc/keepalived/keepalived.conf
The configuration of the backup server is the same except for the values of notification_email_from
, state
, priority
, and possibly interface
if the system hardware configuration is different:
|
|
查看IP 绑定
|
|
另外切换时 /var/log/messages
记录了主从切换的信息
参考
(Configuring Simple Virtual IP Address Failover Using Keepalived](https://docs.oracle.com/cd/E52668_01/E54669/html/section_uxg_lzh_nr.html)