Управление устройствами типа MD (Linux Software RAID
)
Устройства RAID это виртуальные устроройства, созданные на базе одного или нескольких обычных блочных устройств. Это позволяет нескольким устройствам (обычно диски или их разделы) быть в одном устройстве, чтобы быть (например) в одной файловой системе. Некоторые уровни RAID включают резервирование и поэтому могут сохранять работоспособность в случае отказе определенного числа устройств.
Устройства Linux Software RAID работают через системный драйвер устройств md
(Multiple Devices).
В настоящее время, Linux поддерживает:
The remaining three might have a RAID5 over the first half of each device, and a RAID0 over the second half.
With a CONTAINER, there is one set of metadata that describes all of the arrays in the container. So when mdadm creates a CONTAINER device, the device just represents the metadata. Other normal arrays (RAID1 etc) can be created inside the container.
apt-get install mdadm
mdadm [режим] <md_утройство> [options] <component-devices>
Настройка GRUB
Установка GRUB на новый диск:
grub-install --recheck /dev/sdb
mdadm имеет несколько основных режимов работы:
Сборка the components of a previously created array into an active array. Components can be explicitly given or can be searched for. mdadm checks that the components do form a bona fide array, and can, on request, fiddle superblock information so as to assemble a faulty array.
Сборка компонентов ранее созданного массива в активный массив. Компоненты могут быть явно заданы или могут быть найдены. mdadm проверяет, что компоненты делать образуют добросовестный массив, а может, по запросу, скрипка Суперблок информация для того, чтобы собрать неисправный массив.
Build an array that doesn't have per-device metadata (superblocks). For these sorts of arrays, mdadm cannot differentiate between initial creation and subsequent assembly of an array. It also cannot perform any checks that appropriate components have been requested. Because of this, the Build mode should only be used together with a complete understanding of what you are doing.
Create a new array with per-device metadata (superblocks). Appropriate metadata is written to each device, and then the array comprising those devices is activated. A 'resync' process is started to make sure that the array is consistent (e.g. both sides of a mirror contain the same data) but the content of the device is left otherwise untouched. The array can be used as soon as it has been created. There is no need to wait for the initial resync to finish.
Monitor one or more md devices and act on any state changes. This is only meaningful for RAID1, 4, 5, 6, 10 or multipath arrays, as only these have interesting state. RAID0 or Linear never have missing, spare, or failed drives, so there is nothing to monitor.
Grow (или shrink) an array, or otherwise reshape it in some way.
Currently supported growth options including changing the active size of component devices and changing the number of active devices in Linear and RAID levels 0/1/4/5/6, changing the RAID level between 0, 1, 5, and 6, and between 0 and 10, changing the chunk size and layout for RAID 0,4,5,6,10 as well as adding or removing a write-intent bitmap.
Add a single device to an appropriate array. If the addition of the device makes the array runnable, the array will be started.
This provides a convenient interface to a hot-plug system. As each device is detected, mdadm has a chance to include it in some array as appropriate. Optionally, when the –fail flag is passed in we will remove the device from any active array instead of adding it.
If a CONTAINER is passed to mdadm in this mode, then any arrays within that container will be assembled and started.
This is for doing things to specific components of an array such as adding new spares and removing faulty devices.
This is an 'everything else' mode that supports operations on active arrays, operations on component devices such as erasing old superblocks, and information gathering operations.
This mode does not act on a specific device or array, but rather it requests the Linux Kernel to activate any auto-detected arrays.
В данном примере приведена последовательность действий по замене диска в RAID 1 (зеркало).
Состояние массивов выдаёт команда:
cat /proc/mdstat
То же самое но с обновлением:
watch cat /proc/mdstat
mdadm --create /dev/md/1 --metadata=1.2 --level=1 --raid-devices=2 /dev/sdc1 /dev/sdd1
Добавление раздела в массив
mdadm --manage /dev/md1 --add /dev/sdc1
mdadm --manage /dev/md1 --fail /dev/sdc1
mdadm --manage /dev/md1 --remove /dev/sdc1
Вывод:
mdadm: hot removed /dev/sdc1 from /dev/md1
Для начала нужно размонтировать и остановить массив:
umount /dev/md0 mdadm -S /dev/md0
Затем необходимо выполнить Удаление данных массива.
Нужно очистить superblock
каждого из составляющих массива:
mdadm --zero-superblock /dev/sda1 mdadm --zero-superblock /dev/sda2
Если действие выше не помогло, то затираем так:
dd if=/dev/zero of=/dev/sda1 bs=512 count=1 dd if=/dev/zero of=/dev/sda2 bs=512 count=1
Если режим синхронизации был прерван, resync=pending
, то массив из состояния auto-read-only
можно перевести командой:
mdadm --readwrite /dev/md/1
mdadm --detail --scan --verbose
mdadm --detail /dev/md1
mdadm --create /dev/md1 -l1 -n2 missing /dev/sdb1 mdadm --create /dev/md2 -l1 -n2 missing /dev/sdb2
Для увеличения скорости выполнения операции resync
можно увеличить speed_limit_min
Пример:
cat /proc/sys/dev/raid/speed_limit_min echo 50000 > /proc/sys/dev/raid/speed_limit_min
Необходимые файлы нужно загрузить с github.com, вот прямая ссылка.
На агенте нужно:
userparameter_md.conf
в /etc/zabbix/zabbix_agentd.conf.d/
service zabbix-agent restart
На сервере нужно импортировать шаблон template_md.xml
MDADM(8) v3.3.2
http://neil.brown.name/blog/mdadm
xgu.ru : Программный RAID в Linux
Решение проблемы с зеркалом mdadm после обновления ядра
Перевод работающей системы Debian на RAID 1
Установка Debian на Linux RAID
ArchLinux : Software RAID and LVM
Управление дисковым пространством в Linux с помощью LVM (linux disk lvm partition raid)
Глава 12. Углублённое администрирование
DebianInstaller SoftwareRaidRoot
Софтовый RAID-1 с LVМ на Debian
Замена сбойного диска в программном RAID массиве
Заметки о программном RAID с помощью mdadm
Speeding Up MDADM RAID Rebuilds