Что делать, если настал таки момент, к которому мы готовились, создавая raid1 – пресловутое “зеркало”? Один винчестер “вылетел” из массива (или мы его просто отключили).
Давайте понаблюдаем за такой ситуацией. Сервер, настроенный так, как было описано ранее, должен загрузиться даже с одним винчестером. В логах загрузки мы увидим следующие строки
May 15 09:47:26 debiantest kernel: [ 2.869290] md: md4 stopped. May 15 09:47:26 debiantest kernel: [ 2.872888] md: bind<sdb1> May 15 09:47:26 debiantest kernel: [ 2.874327] md: raid1 personality registered for level 1 May 15 09:47:26 debiantest kernel: [ 2.874567] md/raid1:md4: active with 1 out of 2 mirrors May 15 09:47:26 debiantest kernel: [ 2.874634] md4: detected capacity change from 0 to 2001666048 May 15 09:47:26 debiantest kernel: [ 2.877944] md4: unknown partition table May 15 09:47:26 debiantest kernel: [ 3.109765] EXT4-fs (md4): mounted filesystem with ordered data mode. Opts: (null) May 15 09:47:26 debiantest kernel: [ 5.162620] EXT4-fs (md4): re-mounted. Opts: (null) May 15 09:47:26 debiantest kernel: [ 5.265645] EXT4-fs (md4): re-mounted. Opts: errors=remount-ro May 15 09:47:32 debiantest mdadm[2405]: DegradedArray event detected on md device /dev/md/4 |
Вывод “cat /proc/mdstat” даст следующее
root@debiantest:/var/log# cat /proc/mdstat Personalities : [raid1] md4 : active raid1 sda1[1] 1954752 blocks super 1.2 [2/1] [_U] unused devices: <none> |
А детальный вывод будет такой
root@debiantest:/var/log# mdadm -D /dev/md4 /dev/md4: Version : 1.2 Creation Time : Wed May 14 08:34:49 2014 Raid Level : raid1 Array Size : 1954752 (1909.26 MiB 2001.67 MB) Used Dev Size : 1954752 (1909.26 MiB 2001.67 MB) Raid Devices : 2 Total Devices : 1 Persistence : Superblock is persistent Update Time : Thu May 15 07:47:53 2014 State : clean, degraded Active Devices : 1 Working Devices : 1 Failed Devices : 0 Spare Devices : 0 Name : debiantest:4 (local to host debiantest) UUID : a3c152c4:4e443f58:5b07bb17:1d1761bc Events : 526 Number Major Minor RaidDevice State 0 0 0 0 removed 1 8 1 1 active sync /dev/sda1 |
Допустим, система в таком виде существовала некоторое время – вы создавали файлы
root@debiantest:~# dd if=/dev/zero of=z bs=512 count=512000 512000+0 records in 512000+0 records out 262144000 bytes (262 MB) copied, 2.80661 s, 93.4 MB/s |
Теперь подключаем новый диск. Смотрим статус
root@debiantest:~# cat /proc/mdstat Personalities : [raid1] md4 : active raid1 sdb1[1] 1954752 blocks super 1.2 [2/1] [_U] unused devices: <none> root@debiantest:~# mdadm -D /dev/md4 /dev/md4: Version : 1.2 Creation Time : Wed May 14 08:34:49 2014 Raid Level : raid1 Array Size : 1954752 (1909.26 MiB 2001.67 MB) Used Dev Size : 1954752 (1909.26 MiB 2001.67 MB) Raid Devices : 2 Total Devices : 1 Persistence : Superblock is persistent Update Time : Thu May 15 09:48:17 2014 State : clean, degraded Active Devices : 1 Working Devices : 1 Failed Devices : 0 Spare Devices : 0 Name : debiantest:4 (local to host debiantest) UUID : a3c152c4:4e443f58:5b07bb17:1d1761bc Events : 580 Number Major Minor RaidDevice State 0 0 0 0 removed 1 8 17 1 active sync /dev/sdb1 |
И просто добавляем второй диск и дожидаемся окончания синхронизации
root@debiantest:~# mdadm -a /dev/md4 /dev/sda1 mdadm: added /dev/sda1 root@debiantest:~# cat /proc/mdstat Personalities : [raid1] md4 : active raid1 sda1[2] sdb1[1] 1954752 blocks super 1.2 [2/1] [_U] [==>..................] recovery = 11.1% (217792/1954752) finish=0.6min speed=43558K/sec unused devices: <none> root@debiantest:~# cat /proc/mdstat Personalities : [raid1] md4 : active raid1 sda1[2] sdb1[1] 1954752 blocks super 1.2 [2/2] [UU] unused devices: <none> root@debiantest:~# mdadm -D /dev/md4 /dev/md4: Version : 1.2 Creation Time : Wed May 14 08:34:49 2014 Raid Level : raid1 Array Size : 1954752 (1909.26 MiB 2001.67 MB) Used Dev Size : 1954752 (1909.26 MiB 2001.67 MB) Raid Devices : 2 Total Devices : 2 Persistence : Superblock is persistent Update Time : Thu May 15 09:50:29 2014 State : clean Active Devices : 2 Working Devices : 2 Failed Devices : 0 Spare Devices : 0 Name : debiantest:4 (local to host debiantest) UUID : a3c152c4:4e443f58:5b07bb17:1d1761bc Events : 611 Number Major Minor RaidDevice State 2 8 1 0 active sync /dev/sda1 1 8 17 1 active sync /dev/sdb1 |
Всё – одеваем противогаз и радуемся.