如何配置软件RAID发送电子邮件时出现错误的RAID
版本1.0
作者:Falko Timme
本简短的指南介绍了如何配置软件RAID,以便在RAID出现问题时向您发送电子邮件,例如硬盘驱动器发生故障。 我已经在Debian Etch上进行了测试,但它应该适用于所有其他发行版,而且对路径进行了微调。
我不会保证这将为您工作!
打开你的mdadm.conf
文件(在Debian上是/etc/mdadm/mdadm.conf
)...
vi /etc/mdadm/mdadm.conf
...并添加一个MAILADDR
行(与您的电子邮件地址)到文件,例如:
DEVICES /dev/sda* /dev/sdb* ARRAY /dev/md0 level=raid1 num-devices=2 UUID=c8a78e3a:e335c0f0:997be224:f02c088a ARRAY /dev/md1 level=raid1 num-devices=2 UUID=fd9f3b6b:4fc9cf4f:09db592d:480d34fe MAILADDR you@yourdomain.com |
然后重启mdadm
:
/etc/init.d/mdadm restart
而已。 现在,当您的RAID设置出现问题时,您将收到一封电子邮件,例如:
From: mdadm monitoring <root@server1.example.com>
To: you@yourdomain.com
Subject: DegradedArray event on /dev/md1:server1.example.com
This is an automatically generated mail message from mdadm
running on server1.example.com
A DegradedArray event had been detected on md device /dev/md1.
Faithfully yours, etc.
P.S. The /proc/mdstat file currently contains the following:
Personalities : [raid0] [raid1]
md1 : active raid1 sda2[2] sdb2[1]
487853760 blocks [2/1] [_U]
[>....................] recovery = 4.3% (21448384/487853760) finish=114.3min speed=67983K/sec
md0 : active raid1 sda1[0] sdb1[1]
530048 blocks [2/2] [UU]
unused devices: <none>
或者这样:
From: mdadm monitoring <root@server1.example.com>
To: you@yourdomain.com
Subject: FailSpare event on /dev/md1:server1.example.com
This is an automatically generated mail message from mdadm
running on server1.example.com
A FailSpare event had been detected on md device /dev/md1.
It could be related to component device /dev/sda2.
Faithfully yours, etc.
P.S. The /proc/mdstat file currently contains the following:
Personalities : [raid0] [raid1]
md1 : active raid1 sda2[2](F) sdb2[1]
487853760 blocks [2/1] [_U]
[===================>.] recovery = 99.9% (487851840/487853760) finish=0.0min speed=61037K/sec
md0 : active raid1 sda1[0] sdb1[1]
530048 blocks [2/2] [UU]
unused devices: <none>