Keepalived : メール通知の設定2023/10/11 |
Keepalived ノード間で障害が発生してフェイルオーバーした場合に、メール通知するよう設定します。 当例では以下のような環境を例にします。 VIP:10.0.0.30 +----------------------+ | +----------------------+ | [node01.srv.world] |10.0.0.51 | 10.0.0.52| [node02.srv.world] | | Keepalived#1 +----------+----------+ Keepalived#2 | | | | | +----------------------+ +----------------------+ |
[1] |
こちらを参考に、全ノードで SMTP サーバーを起動しておきます。 |
[2] | Keepalived ノード間の基本的な設定に加えて、全ノードでメール通知の設定をします。 |
root@node01:~#
vi /etc/keepalived/keepalived.conf global_defs { router_id node01 # SMTP 設定を追記 notification_email { root@localhost } notification_email_from root@node01.srv.world smtp_server localhost smtp_connect_timeout 30 } vrrp_instance VRRP1 { state MASTER # nopreempt interface enp1s0 virtual_router_id 101 priority 200 advert_int 1 virtual_ipaddress { 10.0.0.30/24 } # 追記 smtp_alert }root@node01:~# systemctl reload keepalived
|
[3] | 以上で、フェイルオーバーやフェイルバックした際にはメール通知が送信されます。 |
# 障害発生ノード root@node01:~# mail "/var/mail/root": 1 message 1 unread >U 1 root@node01.srv.wo Wed Oct 11 09:58 19/608 [node01] VRRP Instance VR ? 1 Return-Path: <root@node01.srv.world> X-Original-To: root@localhost Delivered-To: root@localhost Received: from node01.srv.world (localhost [127.0.0.1]) by node01.srv.world (Postfix) with SMTP id 4B14BE0220 for <root@localhost>; Wed, 11 Oct 2023 09:58:46 +0900 (JST) Date: Wed, 11 Oct 2023 09:58:46 +0900 From: root@node01.srv.world Subject: [node01] VRRP Instance VRRP1 - Entering FAULT state X-Mailer: Keepalived To: root@localhost Message-Id: <20231011005846.4B14BE0220@node01.srv.world> X-IMAPbase: 1696985936 2 X-UID: 1 Status: O => VRRP Instance is no longer owning VRRP VIPs <= # バックアップノード root@node02:~# mail "/var/mail/root": 2 messages 2 new >N 1 root@node01.srv.wo Wed Oct 11 09:58 16/540 [node02] VRRP Instance VR N 2 root@node01.srv.wo Wed Oct 11 10:00 16/546 [node02] VRRP Instance VR ? 1 Return-Path: <root@node01.srv.world> X-Original-To: root@localhost Delivered-To: root@localhost Received: from node02.srv.world (localhost [127.0.0.1]) by node02.srv.world (Postfix) with SMTP id 514ACE0222 for <root@localhost>; Wed, 11 Oct 2023 09:58:49 +0900 (JST) Date: Wed, 11 Oct 2023 09:58:49 +0900 From: root@node01.srv.world Subject: [node02] VRRP Instance VRRP1 - Entering MASTER state X-Mailer: Keepalived To: root@localhost Message-Id: <20231011005849.514ACE0222@node02.srv.world> => VRRP Instance is now owning VRRP VIPs <= |
Sponsored Link |