Linux raid файловая система

Программный RAID — собираем под управлением Linux

Возникла необходимость в надежном хранилище информации. Выбор пал на программный RAID. В моем случае, думаю, достаточно будет зеркального RAID 1. Если есть финансы и возможность можно и увеличить, хоть до гигантского RAID 6.

Что такое Программный RAID

RAID (англ. Redundant Array of Independent Disksизбыточный массив независимых (самостоятельных) дисков) — технология виртуализации данных для объединения нескольких физических дисковых устройств в логический модуль для повышения отказоустойчивости и производительности.

Там же в википедии можете почитать о всех особенностях raid массивов.

Исходя из своих финансовых возможностей и руководствуясь здравым смыслом, решил использовать зеркальный RAID 1.

Программный массив можно спокойно перенести на другой пк, в случае необходимости.

Выход из строя одновременно двух дисков мало вероятен. В случае каких то проблем, хотя бы с одним диском, можно будет без затруднений спасти всю информацию.

Аппаратный RAID

Аппаратный RAID предусматривает собой специальный контроллер, плату, к которой подключаются диски. Этот контроллер собирает RAID и его контролирует.

От использования специального RAID контроллера отказался по понятным причинам:

Стоимость — его нужно приобретать отдельно.

Надежность — в случае его выхода из строя, данные трудно восстановить без такого же рабочего контроллера.

Лишнее звено в структуре уменьшает надежность и увеличивает стоимость.

Собираем программный RAID в Linux

Так как я использую в качестве основной операционной системы Linux, то естественно, что и RAID будем собирать на работающем компьютере под управлением Linux

Собирать буду зеркальный RAID из двух дисков, но таким же способом можно собрать RAID с большим количеством дисков.

Перед сборкой массива, диски, в моем случае два диска по 1Tb, за ранее подключаем к компьютеру.

Для работы с массивами в Linux необходимо установить утилиту администрирования и контроля программного RAID — mdadm

Всю сборку и запуск нашего raid произведем в терминале.

Обновляем информацию о пакетах

Проверяем установлена ли утилита

если утилита стоит вы увидите примерно такой текст

mdadm info

Узнаем информацию о подключенных дисках

Проверяем идентификаторы дисков которые будем использовать, их принадлежность

lsblk -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINT

disk info

В данном случае, видим два диска sdb и sdc.

Их идентификаторы будут /dev/sdb и /dev/sdc, соответственно.

Из этих дисков и будем создавать массив Raid-1.

Создаем RAID массив

sudo mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/имя первого диска /dev/имя второго диска

/dev/md0 — имя нашего будущего рейда

—livel=1 — уровень рейда, в нашем варианте собираем RAID1, если собираете RAID2 то ставим =2, ну и так далее

Читайте также:  Как установить linux mate

—raid-devices=2 — количество дисков используемых в рейде, ну и далее перечисляются их имена

После ввода команды будет вопрос

Continue creating array? — соглашаемся, введя Y и нажимаем Enter

Если сделали все правильно, начнется процесс зеркалирования дисков.

Проверить статус можно командой

Мониторинг процесса удобно отслеживать с помощью команды

Так вы в реальном времени сможете наблюдать процесс и знать время его завершения.

Желательно дождаться окончания процесса.

Создаем и монтируем файловую систему в нашем RAID

Созданный массив должен иметь свою файловую систему, так как в данном случае linux, очевидно, что это будет ext4

/dev/md0 — имя нашего созданного массива.

Создаем точку в которую будем монтировать наш массив

/mnt/md0 — точка куда будем монтировать наш массив

Точка монтирования, по сути своей, это директория в виде папки, в которую будет смонтирован наш массив, название вы можете задать свое. Вместо md0 — например Arhiv. Если зададите другую, то учитывайте это в последующих ваших действиях.

Теперь можно смонтировать массив /dev/md0 в нашу ранее созданную директорию /mnt/md0

Проверить доступно ли новое пространство можно командой

диски доступные в системе

Сохраняем наш программный RAID

Если не сохранить все проделанное, после перезагрузки мы не увидим нашего рейда в наличии.

Настраиваем автоматическую сборку рейда при запуске системы.

Информацию, о нашем созданном рейде, необходимо записать в файл /etc/mdadm/mdadm.conf

Выполним команду которая сделает это автоматически

sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf

В результате в файл mdadm.conf будет сделана запись о сформированном RAID. Если открыть этот файл в блокноте то выглядеть это будет примерно так

запись о RAID в файле mdadm.conf

Теперь необходимо обновить информацию о наших файловых системах для их автоматического распознования при запуске системы

Для автоматического монтирования нашего диска /dev/md0 в нашу ранее созданную директорию /mnt/md0, нам необходимо так же зделать запись в файл /etc/fstab

echo '/dev/md0 /mnt/md0 ext4 defaults,nofail,discard 0 0' | sudo tee -a /etc/fstab

В результате будет сделана запись в файл fstab. Если открыть этот файл в блокноте то выглядеть это будет примерно так

запись о RAID в файле fstab

Теперь можете перезагружать систему. После перезагрузки ваш RAID массив должен быть там куда вы его смонтировали.

Если хотите удалить или расформировать 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.

Читайте также:  Java server for linux

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.

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.

Читайте также:  Узнать hostname по ip linux

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