5/5 - (1 голос)
В данной статье приведена инструкция по замена диска на сервере mdadm RAID1.
Мы не рекомендуем производить любые манипуляции с рейдом не опытным пользователям (возможна потеря всех данных). Если Вам нужна помощь обращайтесь [email protected]
Исходные данные: есть 2 диска sda sdb(поврежденный диск)
Проверяем состояние рейда
# cat /proc/mdstat Personalities : [raid1] md0 : active raid1 sdb1[1] sda1[2] 511936 blocks super 1.0 [2/2] [UU] md1 : active raid1 sdb2[1] sda2[2] 976117568 blocks super 1.1 [2/2] [UU] bitmap: 6/8 pages [24KB], 65536KB chunk unused devices: <none>
- Маркируем диск sdb как поврежденный в двух RAID массивах
# mdadm --manage /dev/md0 --fail /dev/sdb1 mdadm: set /dev/sdb1 faulty in /dev/md0 # mdadm --manage /dev/md1 --fail /dev/sdb2 mdadm: set /dev/sdb2 faulty in /dev/md1
Проверяем еще раз статус RAID массивов смотрим, действительно диск отмечен как зафейленый (F)
# cat /proc/mdstat Personalities : [raid1] md0 : active raid1 sdb1[1](F) sda1[2] 511936 blocks super 1.0 [2/1] [U_] md1 : active raid1 sdb2[1](F) sda2[2] 976117568 blocks super 1.1 [2/1] [U_] bitmap: 7/8 pages [28KB], 65536KB chunk unused devices: <none>
- Отлично, теперь удаляем диск из RAID массивов
# mdadm --manage /dev/md0 --remove /dev/sdb1 mdadm: hot removed /dev/sdb1 from /dev/md0 # mdadm --manage /dev/md1 --remove /dev/sdb2 mdadm: hot removed /dev/sdb2 from /dev/md1
Проверяем статус RAID масивов
cat /proc/mdstat Personalities : [raid1] md0 : active raid1 sda1[2] 511936 blocks super 1.0 [2/1] [U_] md1 : active raid1 sda2[2] 976117568 blocks super 1.1 [2/1] [U_] bitmap: 8/8 pages [32KB], 65536KB chunk unused devices: <none>
Хорошая новость мы удалили зафейленый диск!
- Теперь ставим новый диск в сервер и размечаем его как sda
sfdisk -d /dev/sda | sfdisk /dev/sdb Checking that no-one is using this disk right now ... OK Disk /dev/sdb: 243201 cylinders, 255 heads, 63 sectors/track /dev/sdb: unrecognized partition table type Old situation: No partitions found New situation: Units = sectors of 512 bytes, counting from 0 Device Boot Start End #sectors Id System /dev/sdb1 * 2048 1026047 1024000 fd Linux raid autodetect /dev/sdb2 1026048 1953523711 1952497664 fd Linux raid autodetect /dev/sdb3 0 - 0 0 Empty /dev/sdb4 0 - 0 0 Empty Warning: partition 1 does not end at a cylinder boundary sfdisk: I don't like these partitions - nothing changed. (If you really want this, use the --force option.)
В моем случае диск sda на 1TB, a sdb на 2TB потому добавляем ключ —force
sfdisk -d /dev/sda | sfdisk /dev/sdb --force Checking that no-one is using this disk right now ... OK Disk /dev/sdb: 243201 cylinders, 255 heads, 63 sectors/track /dev/sdb: unrecognized partition table type Old situation: No partitions found New situation: Units = sectors of 512 bytes, counting from 0 Device Boot Start End #sectors Id System /dev/sdb1 * 2048 1026047 1024000 fd Linux raid autodetect /dev/sdb2 1026048 1953523711 1952497664 fd Linux raid autodetect /dev/sdb3 0 - 0 0 Empty /dev/sdb4 0 - 0 0 Empty Warning: partition 1 does not end at a cylinder boundary Successfully wrote the new partition table Re-reading the partition table ... If you created or changed a DOS partition, /dev/foo7, say, then use dd(1) to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1 (See fdisk(8).)
Проверяем, все прошло хорошо и диск разметился как нам нужно
# fdisk -l Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes 255 heads, 63 sectors/track, 243201 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/sdb1 * 1 64 512000 fd Linux raid autodetect Partition 1 does not end on cylinder boundary. /dev/sdb2 64 121602 976248832 fd Linux raid autodetect Disk /dev/sda: 1000.2 GB, 1000204886016 bytes 255 heads, 63 sectors/track, 121601 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/sda1 * 1 64 512000 fd Linux raid autodetect Partition 1 does not end on cylinder boundary. /dev/sda2 64 121602 976248832 fd Linux raid autodetect Disk /dev/md1: 999.5 GB, 999544389632 bytes 2 heads, 4 sectors/track, 244029392 cylinders Units = cylinders of 8 * 512 = 4096 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/mapper/vg_jcs-lv_root: 257.7 GB, 257698037760 bytes 255 heads, 63 sectors/track, 31330 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/mapper/vg_jcs-lv_swap: 4294 MB, 4294967296 bytes 255 heads, 63 sectors/track, 522 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/md0: 524 MB, 524222464 bytes 2 heads, 4 sectors/track, 127984 cylinders Units = cylinders of 8 * 512 = 4096 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/mapper/vg_jcs-lv_data: 737.5 GB, 737547386880 bytes 255 heads, 63 sectors/track, 89668 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000
- Отлично диск sdb мы разметили
Теперь добавляем диск sdb в RAID массивы
# mdadm --manage /dev/md0 --add /dev/sdb1 mdadm: added /dev/sdb1 [root@jcs ~]# mdadm --manage /dev/md1 --add /dev/sdb2 mdadm: added /dev/sdb2
Выводим статус RAID масивов
# cat /proc/mdstat Personalities : [raid1] md0 : active raid1 sdb1[3] sda1[2] 511936 blocks super 1.0 [2/2] [UU] md1 : active raid1 sdb2[3] sda2[2] 976117568 blocks super 1.1 [2/1] [U_] [>....................] recovery = 0.1% (1575808/976117568) finish=195.8min speed=82937K/sec bitmap: 8/8 pages [32KB], 65536KB chunk unused devices: <none>
- Теперь ждем пока RAID пересоберется