Software RAID on linux with mdadmCampus-Booster ID: 38503
www.supinfo.com
Copyright © SUPINFO. All rights reserved
Software RAID
Your trainer…
Presenter’s Name
Software RAID
Title: **Enter title or job role.
Accomplishments: **What makes the presenter qualified to present this course.
Education: **List degrees if important.
Publications: **Writings by the presenter on the subject of the course or presentation.
Contact:**Campus-Booster ID: [email protected]
Create a loop device: to use RAID without additional disk
Know all differents RAID levels: choose the level for your need
Install and configure RAID software: when we had no hardware solution
Monitoring RAID devices: to be alerted of arrays problem
By completing this course, you will:
Software RAID
Course objectives
Loop devices: know and manipulate loop devices
System preparation: Configure the linux kernel and disks to use RAID
mdadm installation: the software RAID solution
RAID implementation: increase performance and implement fault tolerance
Monitoring and maintenance: Change disk or be aware of any problems
Software RAID
Course’s plan:
Course topics
PresentationLoop devices
Loopback device
Same operations as a real disk, example:
Can be bound to a file
File Virtual disk
Become /dev/loop[0-7]
fdisk /dev/loop0fdisk /dev/loop0
mkfs.ext3 /dev/loop0mkfs.ext3 /dev/loop0
ExampleLoop devices
Creation of a 10Mo file
Bind /dev/loop0 device to image.loop
Unbind:
dd if=/dev/zero of=image.loop bs=1024k count=10dd if=/dev/zero of=image.loop bs=1024k count=10
losetup /dev/loop0 image.looplosetup /dev/loop0 image.loop
losetup –d /dev/loop0losetup –d /dev/loop0
PreviewRAID introduction
Here are the chapters we will see:
Introduction
Stripping
Mirroring
RAID 5
RAID 1+0
Introduction Objective: using inexpensive disks
Disks aggregation: the OS only sees one logical disk.
Disks capacity addition (RAID 0, JBOD)
Enhanced performance (RAID 0, 5)
Fault tolerance (RAID 1, 5)
Increase capacity, performance, security (RAID 5)
Hardware and Software implementation
IMPORTANT: it's not a backup solution!
RAID introduction
Raid – Historique
1987, Berkeley University: birth of the first 5 Raid levels RAID (1-5)
Raid 0, 6, 7 and Jbod added after
Level 0 and Jbod without fault tolerance (no
redundancy)
RAID introduction
RAID 1 (mirroring)
Raid level 1 or Mirroring
Fault tolerance
Enhanced performance on data reading
Disadvantage: not very disk space efficient
2 Disks of 40Go = 1 Raid device of 40Go
RAID introduction
RAID 5
Raid level 5
Mix between reliability and performance
Read/Write Data on all disks
Parity check system
RAID introduction
RAID 1+0
Raid 1+ Raid 0
Need 4 Disks minimum
Mix Raid 0 performance with Raid 1 Reliability
RAID introduction
PreviewSoftware RAID implementation
These are the chapters that we will approach :
Kernel configuration
mdadm installation
Disks preparation
RAID device
Kernel configuration
Linux kernel must support Raid devices
1 Verify Raid support:
2 Reconfigure the kernel if needed:
Software RAID implementation
cat /boot/config-2.6.x | grep RAIDcat /boot/config-2.6.x | grep RAID
mdadm installation
mdadm: Tool to manage raid devices
Install from sources:
http://neil.brown.name/blog/mdadm
Mandriva: urpmi mdadm
Software RAID implementation
Disks preparation
Partitions need to support raid
1 disk = only 1 partition
Warning: All data will be lost !
1 Launch fdisk or any other partition manager of your choice
2 Create a partition for the entire disk
3 Modify partition type to type FD (Linux RAID autodetect)
Software RAID implementation
fdisk /dev/hdbfdisk /dev/hdb
Raid device
Raid device = Virtual partition
Represented by: /dev/md<x>
X is a number: 0 to 15
Example: /dev/md1
16 Raid partitions maximum
No partitioning required on raid device.
Software RAID implementation
PreviewConfiguration and use of Software RAID
These are the chapters that we will approach :
The mdadm command
RAID 1 Implementation
RAID 5 Implementation
RAID 0+1 Implementation
The mdadm command
Only one command for all management: mdadm
--create <device>: Raid device to create (/dev/md1)
--level=<x>: Raid level (0,1,5,...)
--raid-devices=<x> <devices>: number of physical disks and their access path
Configuration of Software RAID
mdadm --create <device> --level=<x> \> --raid-devices=<x> <device1> <device2> ...
mdadm --create <device> --level=<x> \> --raid-devices=<x> <device1> <device2> ...
Raid 1 implementation
Data duplicated: writing synchronously on all disks
2 disks minimum
Creation of a Raid 1 device /dev/md0
Mirroring of /dev/sdb1 and /dev/sdc1
Configuration of Software RAID
mdadm --create /dev/md0 --level=1 \> --raid-devices=2 /dev/sdb1 /dev/sdc1
mdadm --create /dev/md0 --level=1 \> --raid-devices=2 /dev/sdb1 /dev/sdc1
Raid 5 implementation
Fault tolerance and performance
3 disks minimum
Configuration of Software RAID
mdadm --create /dev/md1 --level=5 \> --raid-devices=3 /dev/sdb1 /dev/sdc1 /dev/sdd1 \> --spare-devices=1 /dev/sde1
mdadm --create /dev/md1 --level=5 \> --raid-devices=3 /dev/sdb1 /dev/sdc1 /dev/sdd1 \> --spare-devices=1 /dev/sde1
Raid 1+0 implementation Raid 1 + Raid 0
First we create two RAID 1
Configuration of Software RAID
mdadm --create /dev/md1 --level=1 \> --raid-devices=2 /dev/sdd1 /dev/sde1
mdadm --create /dev/md1 --level=1 \> --raid-devices=2 /dev/sdd1 /dev/sde1
mdadm --create /dev/md2 --level=0 \> --raid-devices=2 /dev/md0 /dev/md1
mdadm --create /dev/md2 --level=0 \> --raid-devices=2 /dev/md0 /dev/md1
mdadm --create /dev/md0 --level=1 \> --raid-devices=2 /dev/sdb1 /dev/sdc1
mdadm --create /dev/md0 --level=1 \> --raid-devices=2 /dev/sdb1 /dev/sdc1
And then the RAID 0 from the two RAID 1 sets
PreviewMaintenance and monitoring
These are the chapters that we will approach :
Simulate a faulty disk
Hot add / remove
Monitoring your arrays
Simulate a faulty disk Hot add and remove of disk
Simulate a faulty disk:
See the changes:
1
2
Maintenance and monitoring
mdadm /dev/md0 -f /dev/sdc1mdadm /dev/md0 -f /dev/sdc1
mdadm --detail /dev/md0[ ? ] Number Major Minor RaidDevice State0 8 17 0 active sync /dev/sdb11 8 49 1 active sync /dev/sdd12 8 33 - faulty /dev/sdc1
mdadm --detail /dev/md0[ ? ] Number Major Minor RaidDevice State0 8 17 0 active sync /dev/sdb11 8 49 1 active sync /dev/sdd12 8 33 - faulty /dev/sdc1
Hot add / remove
Hot add and remove of disk
Remove /dev/sdc1
Add the spare disk /dev/sde1
3
4
Maintenance and monitoring
mdadm /dev/md0 -r /dev/sdc1mdadm /dev/md0 -r /dev/sdc1
mdadm /dev/md0 -a /dev/sde1mdadm /dev/md0 -a /dev/sde1
Monitoring your arrays
Get mail alerts about your RAID array state:
Maintenance and monitoring
mdadm -F --scan -f --delay 30 --pid-file \ > /var/run/mdadm.pid -m [email protected]
mdadm -F --scan -f --delay 30 --pid-file \ > /var/run/mdadm.pid -m [email protected]
RAID levelsRAID levels
Mdadm commandMdadm
command
RAID maintenance & monitoring
RAID maintenance & monitoring
Course summary
Loop devicesLoop devices
Software RAID
Top Related