Do I need to stop or limit services (Apache, MySQL, ...) during software RAID 1 reconstruction on Linux ?
Is there a risk of corrupting or losing data ?
I am using Linux MD devices (with mdadm) on Debian 5.
As has been commented, there is very little risk of any data corruption during a rebuild. You are obviously still at risk of losing another drive until it has completed. You should make sure your backups are up to date and working. You do have backups don't you?
The rebuild obviously is going to use IO, but running processes will have higher priority. This means that heavy IO bound processes are going to make your rebuild take longer.
Linux has a couple of tuning knobs to change how fast the process runs at:
On my machine they are set to 1000 and 200,000 respectively. The minimum is not all that reliable as I believe userspace IO still trumps it. Just echo new values in to those files to change them. You can see the current speed by checking
Press ctrl-c to exit.
If you're rebuilding your RAID,
A) You should make backups first
B) Your performance will suck. You'd be better off to move any critical services to another host while this is happening, in which case yes, I'd turn off the various daemons.
Agreed with what the others have said. But just to pick on the last point of your question:
There's no risk of corrupting or losing data if you continue to use the drives during the re-sync period.
While it is not required that you stop services from running on the system you will find that performance will be degraded due to the disk IO caused by the rebuild process. If you watch the rebuild processes speed you will see that the process does free up resources to other processes so that the system continues to work.
If you want to speed the rebuild up then it would be advantageous to stop unnecessary processes and let the box just rebuild or if this is not possible to move some of the load off to another system.
Yes, resyncing seriously affects disk performance. Depending on the size of your RAID partition, you cold throttle down resync speed (as root):
echo 10000 > /proc/sys/dev/raid/speed_limit_max
for instance throttles resync at a rate of 10MB/sec. You can throttle it down as much as needed to leave I/O capacity for your services.
The disadvantage is that the more you throttle it down, the longer it takes until the RAID is redundant again. Thus more time for the remaining drive to fail as well and taking the entire array with it.