Mdadm: Difference between revisions

From DrewWiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
===Software RAID===
====Create md device====
Create a raid5 device with 256 chunk size on 4 devices with out any hot spares.
<syntaxhighlight lang=bash>
# mdadm --create /dev/md0 --level=raid5 --chunk=256 --raid-devices=4 --spare-devices=0 /dev/sd[b-e]
</syntaxhighlight>


# yum install kmod-xfs xfsdump xfsprogs
====Create /etc/mdadm.conf====
===Create md device===
<syntaxhighlight lang=bash>
Create a raid5 device with 256 chunk size on 4 devices with out any hot spares.
# mdadm  --examine  --scan --config=mdadm.conf >> /etc/mdadm.conf
<pre># mdadm --create /dev/md0 --level=raid5 --chunk=256 --raid-devices=4 --spare-devices=0 /dev/sd[b-e]</pre>
</syntaxhighlight>
 
Modify as appropriate, ex;
<syntaxhighlight lang=bash>
DEVICE partitions
CREATE owner=root group=disk mode=0660 auto=yes
HOMEHOST <system>
MAILADDR root
</syntaxhighlight>
 
====Replace dead device====
<syntaxhighlight lang=bash>
# mdadm /dev/md0 -a /dev/sdc
</syntaxhighlight>
 
====Force a degraded array to start====
If a drive fails, reboot happens, and we need to restart an array with 3 out of 4 drives running
<syntaxhighlight lang=bash>
# mdadm -Af /dev/md0 -Af /dev/md0 /dev/sda /dev/sdb /dev/sdd
</syntaxhighlight>


===Create filesystem===
===Create filesystem===
Create an ext3 file system with 0% space reserved for boot, a 4096 block size, and a raid stride of 16 ( 16 * 256 = 4096 | stride*chunk=block)
====Ext3====
<pre># mkfs.ext3 -m 0 -b 4096 -E stride=16 /dev/md0</pre>
Create an ext3 file system with 0% space reserved for root, a 4096 block size, and a raid stride of 16 ( 16 * 256 = 4096 | stride*chunk=block)
<syntaxhighlight lang=bash>
# mkfs.ext3 -m 0 -b 4096 -E stride=16 /dev/md0
</syntaxhighlight>


===Performance Testing===
===Performance Testing===
====Bonnie++====
====Bonnie++====
<pre># bonnie++ -d /mnt/raid5/tmp -u drew -f</pre>
<syntaxhighlight lang=bash>
# bonnie++ -d /mnt/raid5/tmp -u drew -f
</syntaxhighlight>
 
====Iozone====
====Iozone====
-a auto -b output_excel file -i run read test -i run write test
*-a auto  
*-b output_excel file  
*-i 0 run read test  
*-i 1 run write test


<pre># iozone -a -b werd.xls -i 0 -i 1 -C -E</pre>
<syntaxhighlight lang=bash>
# iozone -a -b werd.xls -i 0 -i 1 -C -E
</syntaxhighlight>


===Additional Tunables====
===Additional Tunables===
<pre>
Most of this were pulled from http://www.3ware.com/KB/article.aspx?id=11050
# This step must come first.
# See: http://www.3ware.com/KB/article.aspx?id=11050


====max_sectors_kb====
<syntaxhighlight lang=bash>
echo "Setting max_sectors_kb to chunk size of RAID5 arrays..."
echo "Setting max_sectors_kb to chunk size of RAID5 arrays..."
for i in sdc sdd sde sdf sdg sdh sdi sdj sdk sdl
for i in sdb sdc sdd sde
do
do
   echo "Setting /dev/$i to 128K..."
   echo "Setting /dev/$i to 128K..."
   echo 128 > /sys/block/"$i"/queue/max_sectors_kb
   echo 128 > /sys/block/"$i"/queue/max_sectors_kb
done
done
</syntaxhighlight>


====Read-ahead on md0====
*I hear this eats a lot of RAM
<syntaxhighlight lang=bash>
echo "Setting read-ahead to 64MB for /dev/md3"
echo "Setting read-ahead to 64MB for /dev/md3"
blockdev --setra 65536 /dev/md3
blockdev --setra 65536 /dev/md0
</syntaxhighlight>
 
====stripe_cache_size====
* + stripe_cache_size (raid4, raid5 and raid6)
* number of entries in the stripe cache. This is writable, but there are upper and lower limits (32768, 16). Default is 128.
* + stripe_cache_active (raid4, raid5 and raid6)
* number of active entries in the stripe cache
 


* + The stripe cache memory is locked down and not available for other uses.
* + The total size of the stripe cache is determined by this formula:
* +
* + PAGE_SIZE * raid_disks * stripe_cache_size = memory used
<syntaxhighlight lang=bash>
echo "Setting stripe_cache_size to 16MB for /dev/md3"
echo "Setting stripe_cache_size to 16MB for /dev/md3"
echo 16384 > /sys/block/md3/md/stripe_cache_size
echo 16384 > /sys/block/md0/md/stripe_cache_size
</syntaxhighlight>


# if you use more than the default 64kb stripe with raid5
====Array resync speed====
# this feature is broken so you need to limit it to 30MB/s
* Dramatically improves resync performance...
# neil has a patch, not sure when it will be merged.
<syntaxhighlight lang=bash>
echo "Setting minimum and maximum resync speed to 30MB/s..."
# Increase the minimum / maximum resync speed of the array..
echo 30000 > /sys/block/md0/md/sync_speed_min
echo "Setting minimum and maximum resync speed to 100MB/s..."
echo 30000 > /sys/block/md0/md/sync_speed_max
echo 100000 > /sys/block/md0/md/sync_speed_min
echo 30000 > /sys/block/md1/md/sync_speed_min
echo 100000 > /sys/block/md0/md/sync_speed_max
echo 30000 > /sys/block/md1/md/sync_speed_max
</syntaxhighlight>
echo 30000 > /sys/block/md2/md/sync_speed_min
echo 30000 > /sys/block/md2/md/sync_speed_max
echo 30000 > /sys/block/md3/md/sync_speed_min
echo 30000 > /sys/block/md3/md/sync_speed_max


====Disable NCQ====
* Disabling native command queuing ... Benefits?
<syntaxhighlight lang=bash>
# Disable NCQ.
# Disable NCQ.
echo "Disabling NCQ..."
echo "Disabling NCQ..."
Line 55: Line 108:
   echo 1 > /sys/block/"$i"/device/queue_depth
   echo 1 > /sys/block/"$i"/device/queue_depth
done
done
</pre>
</syntaxhighlight>

Latest revision as of 01:51, 25 January 2018

Software RAID

Create md device

Create a raid5 device with 256 chunk size on 4 devices with out any hot spares.

# mdadm --create /dev/md0 --level=raid5 --chunk=256 --raid-devices=4 --spare-devices=0 /dev/sd[b-e]

Create /etc/mdadm.conf

# mdadm  --examine  --scan --config=mdadm.conf >> /etc/mdadm.conf

Modify as appropriate, ex;

DEVICE partitions
CREATE owner=root group=disk mode=0660 auto=yes
HOMEHOST <system>
MAILADDR root

Replace dead device

# mdadm /dev/md0 -a /dev/sdc

Force a degraded array to start

If a drive fails, reboot happens, and we need to restart an array with 3 out of 4 drives running

# mdadm -Af /dev/md0 -Af /dev/md0 /dev/sda /dev/sdb /dev/sdd

Create filesystem

Ext3

Create an ext3 file system with 0% space reserved for root, a 4096 block size, and a raid stride of 16 ( 16 * 256 = 4096 | stride*chunk=block)

# mkfs.ext3 -m 0 -b 4096 -E stride=16 /dev/md0

Performance Testing

Bonnie++

# bonnie++ -d /mnt/raid5/tmp -u drew -f

Iozone

  • -a auto
  • -b output_excel file
  • -i 0 run read test
  • -i 1 run write test
# iozone -a -b werd.xls -i 0 -i 1 -C -E

Additional Tunables

Most of this were pulled from http://www.3ware.com/KB/article.aspx?id=11050

max_sectors_kb

echo "Setting max_sectors_kb to chunk size of RAID5 arrays..."
for i in sdb sdc sdd sde
do
   echo "Setting /dev/$i to 128K..."
   echo 128 > /sys/block/"$i"/queue/max_sectors_kb
done

Read-ahead on md0

  • I hear this eats a lot of RAM
echo "Setting read-ahead to 64MB for /dev/md3"
blockdev --setra 65536 /dev/md0

stripe_cache_size

  • + stripe_cache_size (raid4, raid5 and raid6)
  • number of entries in the stripe cache. This is writable, but there are upper and lower limits (32768, 16). Default is 128.
  • + stripe_cache_active (raid4, raid5 and raid6)
  • number of active entries in the stripe cache


  • + The stripe cache memory is locked down and not available for other uses.
  • + The total size of the stripe cache is determined by this formula:
  • +
  • + PAGE_SIZE * raid_disks * stripe_cache_size = memory used
echo "Setting stripe_cache_size to 16MB for /dev/md3"
echo 16384 > /sys/block/md0/md/stripe_cache_size

Array resync speed

  • Dramatically improves resync performance...
# Increase the minimum / maximum resync speed of the array..
echo "Setting minimum and maximum resync speed to 100MB/s..."
echo 100000 > /sys/block/md0/md/sync_speed_min
echo 100000 > /sys/block/md0/md/sync_speed_max

Disable NCQ

  • Disabling native command queuing ... Benefits?
# Disable NCQ.
echo "Disabling NCQ..."
for i in sdc sdd sde sdf sdg sdh sdi sdj sdk sdl
do
   echo "Disabling NCQ on $i"
   echo 1 > /sys/block/"$i"/device/queue_depth
done