When managing a dedicated server, one crucial aspect to keep an eye on is the health of your RAID (Redundant Array of Independent Disks) system. RAID systems are like the unsung heroes of the server world, working behind the scenes to keep your data safe and accessible. Just as you’d want to know if your car’s engine is running smoothly, it’s essential to monitor the performance of your RAID to prevent potential data loss and ensure optimal server performance.
Imagine RAID monitoring like a diligent caretaker for your precious digital assets, always keeping watch and notifying you when something isn’t quite right. You gain a lot from this proactive approach to safeguarding your data, which is really important for our dedicated hosting customers. This is especially true if you sell VPS or shared hosting, where uptime and data security are critical. At IOFLOOD we set up RAID alerts for you during OS installation, so our customers don’t have to worry about this.
For everyone who is not yet an IOFLOOD customer, in this blog post, we’ll be sharing how to set up email alerts for mdadm software RAID specifically. Don’t worry, hardware RAID enthusiasts; we’ll have a separate article coming soon for you too! So buckle up and let’s dive into the world of RAID monitoring and notifications, ensuring your server remains in tip-top shape.
TL;DR — How to set up mdadm status emails:
Add this line to /etc/mdadm.confThis will work for Centos 7, Ubuntu, and Debian, in most cases. Read the full article for all commands, steps and troubleshooting tips
MAILADDR [email protected]
Add this command to
/etc/rc.local and also run the command once:
/sbin/mdadm –monitor –scan –daemonize
Importance of RAID Status Monitoring
In the world of server management, protecting your valuable data is of the utmost importance. RAID systems (other than RAID 0), with their ability to tolerate the loss of at least one drive without losing any data, are designed to provide a safeguard against data loss. However, when more than one drive fails, the chances of losing all of the data on the array is very high. Therefore, it’s crucial to know when a drive has failed, so you can replace it before another failure causes the total loss of the array. That’s where RAID status monitoring comes in.
Imagine receiving an email alert informing you that one of your drives has failed. Thanks to this early warning, you can quickly replace the faulty drive before a second one fails, thus preserving your data and maintaining server reliability. This proactive approach helps you avoid potential disasters, like losing critical projects or client information, and gives you greater peace of mind knowing that your digital assets are well protected.
Setting up Email Notifications Using mdadm
Now that we’ve established the importance of RAID status monitoring, let’s dive into the process of setting up email notifications using mdadm for your software RAID. Don’t worry – we’ll walk you through each step, making it as easy and painless as possible. So, grab a cup of coffee and let’s get started!
First, edit the configuration file.
Open up your terminal and access the mdadm configuration file by running the following command:
On Debian or Ubuntu systems, the file might be located at
/etc/mdadm/mdadm.conf instead. Make sure you’ve got the right file before proceeding.
Once you have the configuration file open, look for the line that reads
DEVICE partitions. If it’s not there, go ahead and add it:
Next, update the email address where notifications will be sent. Replace the existing email address with your own or the appropriate recipient’s email address(es). The following example assumes you want to email two different recipients, but you can also just email one. When alerting more than one email address, there should be no spaces between the comma and the email addresses. For example:
MAILADDR [email protected],[email protected]
Setting an appropriate email sender is important to ensure your alert emails get delivered properly instead of being flagged as spam. You’ll want to set a recipient email address that your server’s IP address is whitelisted as an allowed sender for the email domain, as specified by SPF records for your domain. You’ll also want to whitelist this email sender in your mail client so that you definitely receive these alerts.
To specify the email sender address, add the following line:
MAILFROM [email protected]
Save the file and exit.
Now, tell mdadm to start monitoring your RAID array.
Depending on your OS version, run one of the following commands:
For RHEL7 based OS, Ubuntu, and Debian:
/sbin/mdadm --monitor --scan --daemonize
For RHEL8 based OS:
systemctl restart mdmonitor
To make sure mdadm starts monitoring every time the server boots, add the command above to your startup file:
Be careful to place the command before the “exit 0” line in Debian or Ubuntu systems.
Make sure sendmail is installed:
If you haven’t already, you’ll need to install sendmail to enable email notifications:
yum install sendmail
apt install sendmail
And there you have it! You’ve successfully set up email notifications for your mdadm software RAID. For testing and troubleshooting tips, keep reading.
Testing the Email Notification
Now that You’ve configured your email notifications, the most important thing is to make sure these notifications work. Without that, they simply provide a false sense of security. Once you verify that your server sends alerts successfully, you’ll know that when you have a RAID problem, you’ll be promptly notified of any RAID health issues that require your attention.
Let’s go through the testing process step by step:
First, you’ll need to stop any running mdadm process. Open your terminal and run the following command:
This command will end any mdadm monitoring process that’s already running. As only one can run at a time, doing so will allow you to perform your email test. If the “killall” command is not available, you can use “pkill” instead:
Now it’s time to run the actual test. To do so, execute the following command:
/sbin/mdadm --monitor --scan --test
Keep in mind that while running this test, it might seem like the terminal has frozen or is unresponsive. Don’t worry! This is normal behavior. Simply press
Ctrl+C after waiting for a while, and the test email should be sent for each RAID device (e.g., md0, md1, md2).
Here’s a pro tip: Be patient during this process. It may take a few minutes for the test email to arrive in your inbox. Make sure to check your spam folder, as well – sometimes, email notifications can get caught up in there.
By testing the email notifications, you’re adding an extra layer of assurance that you’ll be promptly informed of any RAID issues. It’s a simple but important step in maintaining the health and security of your server environment. So, pat yourself on the back – you’re one step closer to RAID monitoring mastery!
Troubleshooting common issues
Now that we’ve gone through the entire process of setting up mdadm email notifications, it’s important to be aware of some common issues that users might encounter. In this section, we’ll discuss these problems and provide solutions and tips to help you overcome them, ensuring your RAID monitoring is running smoothly.
No notifications received:
If you’ve set up everything correctly but still don’t receive email notifications, it might be due to sendmail not being installed. Sendmail is required for the notifications to be sent. Here’s how you can install it:
yum install sendmail
apt install sendmail
Incorrect email address format:
Remember that when specifying multiple email addresses in the
/etc/mdadm.conf file, there should be no spaces between the comma and the email addresses. A common mistake is to include a space, which prevents the emails from being sent correctly. Ensure that the format is as follows:
MAILADDR [email protected],[email protected]
Command not running at startup:
If your RAID monitoring doesn’t start automatically when the server boots, double-check your
/etc/rc.local file or the
systemd service file, depending on the method you used. Make sure that the monitoring command has been added correctly and that there are no typos or syntax errors. In case of the
/etc/rc.local method, ensure that the command is placed before the “exit 0” line in Debian and Ubuntu systems.
In some cases, you might encounter permission issues when trying to edit configuration files or run certain commands. Make sure that you’re using the appropriate user account with sufficient privileges (usually the root user) to perform the necessary actions.
Mdadm process already running:
When testing email notifications, you might see an error message that says
"Only one autorebuild process allowed in scan mode, aborting." This occurs if the mdadm process is already running. To resolve this, first kill the existing mdadm process with
killall mdadm, and then run the test command again.
By being aware of these common issues and their solutions, you’ll be better prepared to tackle any challenges that arise during the setup process. Remember, RAID monitoring is crucial to maintaining the reliability of your server, and IOFLOOD is here to help you every step of the way. Don’t hesitate to reach out if you need further assistance or have any questions. Happy monitoring!
In conclusion, RAID monitoring is a critical aspect of managing your server environment, as it helps you stay proactive in maintaining server reliability and preventing data loss. By setting up email notifications using mdadm, you can ensure that you’re alerted as soon as a drive fails or is likely to fail. This allows you to take timely action, such as replacing a failed drive before a second failure occurs, ultimately safeguarding your precious data.
We hope that this guide has been educational and engaging, helping you understand the importance of RAID monitoring and guiding you through the process of setting up email notifications for your mdadm software RAID. Remember, a proactive approach to server management can save you from the headaches of dealing with data loss and server downtime.
Do You love Servers?
We do! As you continue to optimize your server experience, consider IOFLOOD for your dedicated server hosting needs. Contact us at sales[at]ioflood.com to ask about a RAID enabled server for optimal reliability and performance, or visit our website at IOFLOOD.com. Our commitment to providing excellent service and support will help you achieve the best performance and reliability for your servers. Thank you for visiting IOFLOOD, and happy monitoring!