Только raid диск linux

Программный RAID под Linux

Подсказка : 8192 сектора в конце диска намеренно оставлены неиспользованными для подготовки к сбоям. Это позволяет вам использовать диски с несколькими секторами в качестве замены из-за свободного места.

sudo parted /dev/sda set 1 raid on

Шаг 2.2 — Создание программного RAID

Под Linux mdadm это основной инструмент. Это интерфейс к функциям RAID ядра.
Для создания RAID 1 достаточно следующей команды:

sudo mdadm --create /dev/md0 --auto md --level=1 --raid-devices=2 /dev/sda1 /dev/sdb2
sudo mdadm --create /dev/md0 --auto md --level=5 --raid-devices=4 /dev/sda1 /dev/sdb2 /dev/sdc3 /dev/sdd4 
  • —create /dev/md0 — Создает новую конечную точку с именем md0. Если конечные точки с таким именем уже существуют, выберите другое свободное имя (md1, md2 и т. Д.).
  • —auto md — Создает «классическую» конечную точку без предварительного разбиения.
  • —level= — Тип уровня RAID.
  • —raid-devices — Количество отдельных устройств, из которых должен состоять RAID.
  • /dev/sde1 /dev/sde2 . — Отдельные устройства для объединения. Порядок идентификаторов или, в идеале, идентификаторов соответствующих физических устройств, должен быть записан, если RAID необходимо собрать вручную в чрезвычайной ситуации.
Personalities : [raid0] [raid1] mdX : active raid1 sda1[1] sdb1[0] 8384448 blocks super 1.2 [2/2] [UU] [==============>. ] check = 74.7% (6267520/8384448) finish=0.1min speed=202178K/sec
/dev/mdX /mnt/md0 xt4 defaults 0 2

(Необязательно) Диски Hotspare : Диски / разделы Hotspare — это те, которые обычно не используются. Они используются, если один из активных дисков / разделов системы RAID имеет ошибку или неисправен. Если в программном рейде не определен диск горячего резервирования, восстановление поврежденного RAID-массива необходимо запустить вручную. Если имеется горячий резерв, восстановление будет начато автоматически. Горячий резервный диск можно добавить с помощью следующей команды.

Шаг 3 — Удаление программного RAID

sudo umount /dev/md0 sudo mdadm --stop /dev/md0
sudo mdadm --zero-superblock /dev/sda1 /dev/sdb1 
sudo parted /dev/sda set 1 raid off

Шаг 4 — Управление программным RAID

Шаг 4.1 — Получить статус RAID

Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10] md0 : active raid1 sdb1[1] sda1[0] 8380416 blocks super 1.2 [2/2] [UU] md2 : active raid1 sdb3[1] sda3[0] 536739840 blocks super 1.2 [2/2] [UU] bitmap: 3/4 pages [12KB], 65536KB chunk md1 : active raid1 sdb2[1] sda2[0] 1047552 blocks super 1.2 [2/2] [UU] unused devices:
/dev/md/2: Version : 1.2 Creation Time : Fri Feb 22 17:19:37 2019 Raid Level : raid1 Array Size : 536739840 (511.88 GiB 549.62 GB) Used Dev Size : 536739840 (511.88 GiB 549.62 GB) Raid Devices : 2 Total Devices : 2 Persistence : Superblock is persistent Intent Bitmap : Internal Update Time : Sun May 26 13:49:02 2019 State : clean Active Devices : 2 Working Devices : 2 Failed Devices : 0 Spare Devices : 0 Consistency Policy : bitmap Name : rescue:2 UUID : c76e5446:f3c41fbc:0b62ca86:803a7e88 Events : 2170 Number Major Minor RaidDevice State 0 8 3 0 active sync /dev/sda3 1 8 19 1 active sync /dev/sdb3

Шаг 4.2 — Заменить неисправный диск

sudo mdadm --manage /dev/md/0 -r /dev/sda1

Если диск горячего резервирования недоступен, новый диск должен быть разбит на разделы. Важно, чтобы новый диск имел те же разделы, что и неисправный диск!
Для разбиения нового диска достаточно скопировать таблицу разделов с существующего диска.
Для разделенных на MBR дисков:

sfdisk --dump /dev/sda > sda_parttable_mbr.bak # Backs up partition table sfdisk -d /dev/sda | sfdisk /dev/sdb # Copy partition table from sda to sdb
sgdisk --backup=sda_parttable_gpt.bak /dev/sda # Create a backup of the partition table sgdisk --load-backup=sda_parttable_gpt.bak /dev/sdb # Copy the created backup of the partition table to sdb
sudo mdadm --manage /dev/md/0 -a /dev/sda1
sudo mdadm --manage --set-faulty /dev/md/0 /dev/sda1

Ход можно снова отслеживать с помощью команды watch cat /proc/mdstat .
Как только восстановление RAID завершено, раздел должен быть удален из RAID и добавлен снова, чтобы удалить состояние «неисправен». Это делается с помощью команд:

sudo mdadm --manage /dev/md/0 -r /dev/sda1 # To be removed sudo mdadm --manage /dev/md/0 -a /dev/sda1 # To be added again

* * Примечание . Если система находится на самом RAID-массиве, необходимо установить загрузчик на соответствующий диск. Это делается с помощью следующей команды:

update grub && grub-install /dev/sda

Шаг 4.3 — Расширить RAID

Только RAID с уровнями 1, 5 и 6 могут быть расширены.
Новый раздел должен быть сначала добавлен в качестве горячего резерва:

sudo mdadm /dev/md0 --add /dev/sda1 
sudo mdadm --grow --raid-devices=5 /dev/md0 --backup-file=/root/md0.bak 

Примечание : в указанном файле —backup-file сохраняются критические области (обычно несколько МБ). Если во время расширения происходит сбой системы, расширение можно продолжить позже, используя следующую команду:

sudo mdadm /dev/md0 --continue --backup-file=/tmp/md0.bak

Файл резервной копии не должен быть расположен на RAID, чтобы быть расширенным! Использование backup-file не обязательно, но настоятельно рекомендуется.

Читайте также:  Linux remove permission denied

Файловая система должна быть расширена, чтобы можно было использовать только что созданное пространство хранения. Расширение происходит с помощью следующих команд:

sudo umount /dev/md0 /mnt # Unmount the file system sudo fsck.ext4 -f /dev/md0 # Force the check, even if it has recently been checked sudo resize2fs /dev/md0 # Extend file system to maximum size sudo mount /dev/md0 /mnt # Mount the file system again 

Шаг 4.4 — RAID-мониторы

0 0 * * * /usr/share/mdadm/checkarray --cron --all --quiet >/dev/null 2>&1 # Runs every day at 00:00 AM

Вывод

В этой статье мы рассказали, как выбрать подходящий уровень RAID для вашего проекта, а затем настроить его в системах Linux, используя mdadm . Кроме того, будут обсуждаться административные задачи, такие как расширение RAID или замена неисправных жестких дисков.

Источник

RAID

Redundant Array of Independent Disks (RAID) is a storage technology that combines multiple disk drive components (typically disk drives or partitions thereof) into a logical unit. Depending on the RAID implementation, this logical unit can be a file system or an additional transparent layer that can hold several partitions. Data is distributed across the drives in one of several ways called #RAID levels, depending on the level of redundancy and performance required. The RAID level chosen can thus prevent data loss in the event of a hard disk failure, increase performance or be a combination of both.

This article explains how to create/manage a software RAID array using mdadm.

RAID levels

Despite redundancy implied by most RAID levels, RAID does not guarantee that data is safe. A RAID will not protect data if there is a fire, the computer is stolen or multiple hard drives fail at once. Furthermore, installing a system with RAID is a complex process that may destroy data.

Читайте также:  Linux modify file modify time

Standard RAID levels

There are many different levels of RAID; listed below are the most common.

RAID 0 Uses striping to combine disks. Even though it does not provide redundancy, it is still considered RAID. It does, however, provide a big speed benefit. If the speed increase is worth the possibility of data loss (for swap partition for example), choose this RAID level. On a server, RAID 1 and RAID 5 arrays are more appropriate. The size of a RAID 0 array block device is the size of the smallest component partition times the number of component partitions. RAID 1 The most straightforward RAID level: straight mirroring. As with other RAID levels, it only makes sense if the partitions are on different physical disk drives. If one of those drives fails, the block device provided by the RAID array will continue to function as normal. The example will be using RAID 1 for everything except swap and temporary data. Please note that with a software implementation, the RAID 1 level is the only option for the boot partition, because bootloaders reading the boot partition do not understand RAID, but a RAID 1 component partition can be read as a normal partition. The size of a RAID 1 array block device is the size of the smallest component partition. RAID 5 Requires 3 or more physical drives, and provides the redundancy of RAID 1 combined with the speed and size benefits of RAID 0. RAID 5 uses striping, like RAID 0, but also stores parity blocks distributed across each member disk. In the event of a failed disk, these parity blocks are used to reconstruct the data on a replacement disk. RAID 5 can withstand the loss of one member disk.

Note: RAID 5 is a common choice due to its combination of speed and data redundancy. The caveat is that if one drive were to fail and another drive failed before that drive was replaced, all data will be lost. Furthermore, with modern disk sizes and expected unrecoverable read error (URE) rates on consumer disks, the rebuild of a 4TiB array is expected (i.e. higher than 50% chance) to have at least one URE. Because of this, RAID 5 is no longer advised by the storage industry.

RAID 6 Requires 4 or more physical drives, and provides the benefits of RAID 5 but with security against two drive failures. RAID 6 also uses striping, like RAID 5, but stores two distinct parity blocks distributed across each member disk. In the event of a failed disk, these parity blocks are used to reconstruct the data on a replacement disk. RAID 6 can withstand the loss of two member disks. The robustness against unrecoverable read errors is somewhat better, because the array still has parity blocks when rebuilding from a single failed drive. However, given the overhead, RAID 6 is costly and in most settings RAID 10 in far2 layout (see below) provides better speed benefits and robustness, and is therefore preferred.

Читайте также:  Дистрибутив ubuntu это линукс

Nested RAID levels

RAID 1+0 RAID1+0 is a nested RAID that combines two of the standard levels of RAID to gain performance and additional redundancy. It is commonly referred to as RAID10, however, Linux MD RAID10 is slightly different from simple RAID layering, see below. RAID 10 RAID10 under Linux is built on the concepts of RAID1+0, however, it implements this as a single layer, with multiple possible layouts. The near X layout on Y disks repeats each chunk X times on Y/2 stripes, but does not need X to divide Y evenly. The chunks are placed on almost the same location on each disk they are mirrored on, hence the name. It can work with any number of disks, starting at 2. Near 2 on 2 disks is equivalent to RAID1, near 2 on 4 disks to RAID1+0. The far X layout on Y disks is designed to offer striped read performance on a mirrored array. It accomplishes this by dividing each disk in two sections, say front and back, and what is written to disk 1 front is mirrored in disk 2 back, and vice versa. This has the effect of being able to stripe sequential reads, which is where RAID0 and RAID5 get their performance from. The drawback is that sequential writing has a very slight performance penalty because of the distance the disk needs to seek to the other section of the disk to store the mirror. RAID10 in far 2 layout is, however, preferable to layered RAID1+0 and RAID5 whenever read speeds are of concern and availability / redundancy is crucial. However, it is still not a substitute for backups. See the wikipedia page for more information.

Warning: mdadm cannot reshape arrays in far X layouts which means once the array is created, you will not be able to mdadm —grow it. For example, if you have a 4x1TB RAID10 array and you want to switch to 2TB disks, your usable capacity will remain 2TB. For such use cases, stick to near X layouts.

RAID level comparison

RAID level Data redundancy Physical drive utilization Read performance Write performance Min drives
0 No 100% nX

Best; on par with RAID0 but redundant

Источник

Оцените статью
Adblock
detector