LoginSignup
6
4

More than 5 years have passed since last update.

keepalivedで仮想IPを体験

Last updated at Posted at 2014-12-13

参考

  • HAProxyをkeepalivedで冗長化 - Qiita

  • 仮想IPを192.168.100.103とする。

  • CentOS7で実施。

    • 似たアプリにucarpがあるが、こちらはうまく動作しなかった。(両方のサーバに仮想IPが振られる・・・)

通常master側

/etc/keepalived/keepalived.conf
global_defs {
   notification_email {
     admin@hoge.com
   }
   notification_email_from master@hoge.com
   smtp_server 192.168.100.3
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}

vrrp_instance VI_1 {
   interface eth1
   state MASTER
   virtual_router_id 51
   priority 101
   virtual_ipaddress {
       192.168.100.103
   }
}

通常backup側

/etc/keepalived/keepalived.conf
global_defs {
   notification_email {
     admin@hoge.com
   }
   notification_email_from master@hoge.com
   smtp_server 192.168.100.3
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}

vrrp_instance VI_1 {
   interface eth1
-  state MASTER
+  state BACKUP
   virtual_router_id 51
-  priority 101
+  priority 100
   virtual_ipaddress {
       192.168.100.103
   }
}

サービス登録

systemctl enable keepalived
systemctl start keepalived

確認

watch ip a
  • 仮想IPが片方のサーバに居続けることを確認。
  • MASTER側のサーバを再起動している間は、BACKUP側が仮想IPが振られることを確認
  • MASTER/BACKUP切り替わりのタイミングでpingが1回程度しか落ちないことを確認。
6
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
4