Blame docs/tips/mdadm.md

David Kirwan 1574d7
# mdadm
David Kirwan 1574d7
Some tips and tricks regarding `mdadm`.
David Kirwan 1574d7
David Kirwan 1574d7
David Kirwan 1574d7
## raid 6 ioperf tests
David Kirwan 1574d7
David Kirwan 1574d7
### 4k random read write tests
David Kirwan 1574d7
David Kirwan 1574d7
```
David Kirwan 1574d7
fio --name TEST --filename=temp.file --rw=randrw --size=4g --io_size=10g --blocksize=4k --ioengine=libaio --fsync=1 --iodepth=1 --direct=1 --numjobs=16 --runtime=60
David Kirwan 1574d7
David Kirwan 1574d7
Run status group 0 (all jobs):
David Kirwan 1574d7
   READ: bw=489KiB/s (500kB/s), 28.9KiB/s-32.5KiB/s (29.5kB/s-33.2kB/s), io=28.7MiB (30.1MB), run=60002-60062msec
David Kirwan 1574d7
  WRITE: bw=499KiB/s (511kB/s), 29.4KiB/s-33.2KiB/s (30.1kB/s-33.0kB/s), io=29.3MiB (30.7MB), run=60002-60062msec
David Kirwan 1574d7
```
David Kirwan 1574d7
David Kirwan 1574d7
### 128k random read write tests
David Kirwan 1574d7
David Kirwan 1574d7
```
David Kirwan 1574d7
fio --name TEST --filename=temp.file --rw=randrw --size=4g --io_size=10g --blocksize=128k --ioengine=libaio --fsync=1 --iodepth=1 --direct=1 --numjobs=16 --runtime=60
David Kirwan 1574d7
David Kirwan 1574d7
Run status group 0 (all jobs):
David Kirwan 1574d7
   READ: bw=16.5MiB/s (17.2MB/s), 1007KiB/s-1107KiB/s (1031kB/s-1133kB/s), io=988MiB (1036MB), run=60003-60043msec
David Kirwan 1574d7
  WRITE: bw=16.7MiB/s (17.6MB/s), 1017KiB/s-1126KiB/s (1042kB/s-1153kB/s), io=1005MiB (1054MB), run=60003-60043msec
David Kirwan 1574d7
```
David Kirwan 1574d7
David Kirwan 1574d7
### 4M random read write tests
David Kirwan 1574d7
David Kirwan 1574d7
```
David Kirwan 1574d7
fio --name TEST --filename=temp.file --rw=randrw --size=4g --io_size=10g --blocksize=4M --ioengine=libaio --fsync=1 --iodepth=1 --direct=1 --numjobs=16 --runtime=60 
David Kirwan 1574d7
David Kirwan 1574d7
Run status group 0 (all jobs):
David Kirwan 1574d7
   READ: bw=208MiB/s (218MB/s), 11.9MiB/s-14.1MiB/s (12.5MB/s-14.7MB/s), io=12.2GiB (13.1GB), run=60011-60081msec
David Kirwan 1574d7
  WRITE: bw=205MiB/s (215MB/s), 11.9MiB/s-13.8MiB/s (12.4MB/s-14.5MB/s), io=12.1GiB (12.9GB), run=60011-60081msec
David Kirwan 1574d7
```
David Kirwan 1574d7
David Kirwan 1574d7
## Reconfigure to raid10
David Kirwan 1574d7
David Kirwan 1574d7
We have 14 free disks to be used, so let's create raid 10 array with 10 disk and 4 four as `spare` devices for auto-rebuild in case of failure
David Kirwan 1574d7
David Kirwan 1574d7
```
David Kirwan 1574d7
mdadm -v --create /dev/md0 --level=raid10 --layout=f2 --raid-devices=10 /dev/sdc /dev/sdd /dev/sde /dev/sdf /dev/sdg /dev/sdh /dev/sdi /dev/sdj /dev/sdk /dev/sdl
David Kirwan 1574d7
David Kirwan 1574d7
 mdadm --detail /dev/md0
David Kirwan 1574d7
/dev/md0:
David Kirwan 1574d7
           Version : 1.2
David Kirwan 1574d7
     Creation Time : Tue Jun 22 12:20:31 2021
David Kirwan 1574d7
        Raid Level : raid10
David Kirwan 1574d7
        Array Size : 48831523840 (45.48 TiB 50.00 TB)
David Kirwan 1574d7
     Used Dev Size : 9766304768 (9.10 TiB 10.00 TB)
David Kirwan 1574d7
      Raid Devices : 10
David Kirwan 1574d7
     Total Devices : 10
David Kirwan 1574d7
       Persistence : Superblock is persistent
David Kirwan 1574d7
David Kirwan 1574d7
     Intent Bitmap : Internal
David Kirwan 1574d7
David Kirwan 1574d7
       Update Time : Tue Jun 22 12:20:58 2021
David Kirwan 1574d7
             State : clean, resyncing 
David Kirwan 1574d7
    Active Devices : 10
David Kirwan 1574d7
   Working Devices : 10
David Kirwan 1574d7
    Failed Devices : 0
David Kirwan 1574d7
     Spare Devices : 0
David Kirwan 1574d7
David Kirwan 1574d7
            Layout : far=2
David Kirwan 1574d7
        Chunk Size : 512K
David Kirwan 1574d7
David Kirwan 1574d7
Consistency Policy : bitmap
David Kirwan 1574d7
David Kirwan 1574d7
     Resync Status : 0% complete
David Kirwan 1574d7
David Kirwan 1574d7
              Name : storage02.rdu2.centos.org:0  (local to host storage02.rdu2.centos.org)
David Kirwan 1574d7
              UUID : 521a6cbb:cb76e0c1:dc7fe98c:fe1b0bec
David Kirwan 1574d7
            Events : 5
David Kirwan 1574d7
David Kirwan 1574d7
    Number   Major   Minor   RaidDevice State
David Kirwan 1574d7
       0       8       32        0      active sync   /dev/sdc
David Kirwan 1574d7
       1       8       48        1      active sync   /dev/sdd
David Kirwan 1574d7
       2       8       64        2      active sync   /dev/sde
David Kirwan 1574d7
       3       8       80        3      active sync   /dev/sdf
David Kirwan 1574d7
       4       8       96        4      active sync   /dev/sdg
David Kirwan 1574d7
       5       8      112        5      active sync   /dev/sdh
David Kirwan 1574d7
       6       8      128        6      active sync   /dev/sdi
David Kirwan 1574d7
       7       8      144        7      active sync   /dev/sdj
David Kirwan 1574d7
       8       8      160        8      active sync   /dev/sdk
David Kirwan 1574d7
       9       8      176        9      active sync   /dev/sdl
David Kirwan 1574d7
```
David Kirwan 1574d7
David Kirwan 1574d7
Let's increase the raid array speed
David Kirwan 1574d7
David Kirwan 1574d7
```
David Kirwan 1574d7
md_device=md0
David Kirwan 1574d7
echo max > /sys/block/${md_device}/md/sync_max
David Kirwan 1574d7
echo 500000 > /sys/block/${md_device}/md/sync_speed_min
David Kirwan 1574d7
echo 500000 > /proc/sys/dev/raid/speed_limit_max
David Kirwan 1574d7
```
David Kirwan 1574d7
David Kirwan 1574d7
### Adding other disks as Spare disks in array
David Kirwan 1574d7
David Kirwan 1574d7
```
David Kirwan 1574d7
 for i in m n o p ; do mdadm --add /dev/md0 /dev/sd${i} ; done
David Kirwan 1574d7
mdadm: added /dev/sdm
David Kirwan 1574d7
mdadm: added /dev/sdn
David Kirwan 1574d7
mdadm: added /dev/sdo
David Kirwan 1574d7
mdadm: added /dev/sdp
David Kirwan 1574d7
David Kirwan 1574d7
mdadm --detail /dev/md0|grep Devices
David Kirwan 1574d7
      Raid Devices : 10
David Kirwan 1574d7
     Total Devices : 14
David Kirwan 1574d7
    Active Devices : 10
David Kirwan 1574d7
   Working Devices : 14
David Kirwan 1574d7
    Failed Devices : 0
David Kirwan 1574d7
     Spare Devices : 4
David Kirwan 1574d7
```
David Kirwan 1574d7
David Kirwan 1574d7
David Kirwan 1574d7
### VolumeGroup create and LV/filesystem
David Kirwan 1574d7
Let's now create a vg_array volume on top of new /dev/md0 raid10 device :-1: 
David Kirwan 1574d7
David Kirwan 1574d7
```
David Kirwan 1574d7
pvcreate /dev/md0
David Kirwan 1574d7
vgcreate vg_array /dev/md0
David Kirwan 1574d7
```
David Kirwan 1574d7
David Kirwan 1574d7
## raid10 ioperf tests
David Kirwan 1574d7
David Kirwan 1574d7
David Kirwan 1574d7
```
David Kirwan 1574d7
David Kirwan 1574d7
```
David Kirwan 1574d7
David Kirwan 1574d7