LoginSignup
3
2

More than 3 years have passed since last update.

[Oracle Cloud] SoftwareRAID(mdadm) にディスクを追加して性能を向上する

Last updated at Posted at 2020-07-12

はじめに

前回の記事 で、Block Volume を5つまとめて、SoftwareRAID で性能を上げられることを確認しました。今回の記事では、この SoftwareRAID に Block Volume を1個追加して、ストライプ数を増やしてさらに性能を追加する方法を確認してみましょう

ポイント

  • mdadm で 5個の Volume を RAID 0 でストライピングしている状態
  • 1個の Block Volume 追加で6個の RAID 0 にする
  • 1個の Block Volume を追加して、Rebuild が走ったタイミングから、再度手動で RAID 0 に戻すまでの期間、性能が縮退する (今回の構成では半分くらいの性能に減った)
  • Rebuild の時間は、今回の構成では 6時間弱ほどかかった。必要な時間は、容量や負荷状況に応じて変わるはず

ディスクを追加して、ストライプ数を増やす

現状確認
5個の Volume で RAID 0 (ストライピング) を構成しています

[root@lvm01 ~]# mdadm --detail /dev/md/mdadm-vol01
/dev/md/mdadm-vol01:
           Version : 1.2
     Creation Time : Sat Jul 11 08:32:51 2020
        Raid Level : raid0
        Array Size : 4193643520 (3999.37 GiB 4294.29 GB)
      Raid Devices : 5
     Total Devices : 5
       Persistence : Superblock is persistent

       Update Time : Sat Jul 11 08:32:51 2020
             State : clean
    Active Devices : 5
   Working Devices : 5
    Failed Devices : 0
     Spare Devices : 0

        Chunk Size : 4K

Consistency Policy : none

              Name : lvm01:mdadm-vol01  (local to host lvm01)
              UUID : de777861:5e62caaa:030b36b9:cdf777d5
            Events : 0

    Number   Major   Minor   RaidDevice State
       0       8      144        0      active sync   /dev/sdj
       1       8       32        1      active sync   /dev/sdc
       2       8       48        2      active sync   /dev/sdd
       3       8      112        3      active sync   /dev/sdh
       4       8      160        4      active sync   /dev/sdk
[root@lvm01 ~]#

なお、性能検証コマンドはこちらです。実施前、実施後で性能を確認しました

sudo fio --filename=/dev/md/mdadm-vol01 --direct=1 --rw=randread --bs=4k --ioengine=libaio --iodepth=256 --runtime=120 --numjobs=4 --time_based --group_reporting --name=iops-test-job --eta-newline=1 --readonly

追加するディスクは、/dev/oracleoci/oraclevdm です

[root@lvm01 ~]# ls -la /dev/oracleoci/
total 0
drwxr-xr-x.  2 root root  360 Jul 11 15:25 .
drwxr-xr-x. 23 root root 3980 Jul 11 15:25 ..
lrwxrwxrwx.  1 root root    6 Jul 11 15:21 oraclevda -> ../sda
lrwxrwxrwx.  1 root root    7 Jul 11 15:21 oraclevda1 -> ../sda1
lrwxrwxrwx.  1 root root    7 Jul 11 15:21 oraclevda2 -> ../sda2
lrwxrwxrwx.  1 root root    7 Jul 11 15:21 oraclevda3 -> ../sda3
lrwxrwxrwx.  1 root root    6 Jul 11 15:22 oraclevdb -> ../sdd
lrwxrwxrwx.  1 root root    6 Jul 11 15:22 oraclevdc -> ../sdh
lrwxrwxrwx.  1 root root    6 Jul 11 15:22 oraclevdd -> ../sdf
lrwxrwxrwx.  1 root root    6 Jul 11 15:22 oraclevde -> ../sdb
lrwxrwxrwx.  1 root root    6 Jul 11 15:22 oraclevdf -> ../sdc
lrwxrwxrwx.  1 root root    6 Jul 11 15:22 oraclevdg -> ../sdg
lrwxrwxrwx.  1 root root    6 Jul 11 15:24 oraclevdh -> ../sdl
lrwxrwxrwx.  1 root root    6 Jul 11 15:24 oraclevdi -> ../sde
lrwxrwxrwx.  1 root root    6 Jul 11 15:24 oraclevdj -> ../sdk
lrwxrwxrwx.  1 root root    6 Jul 11 15:24 oraclevdk -> ../sdj
lrwxrwxrwx.  1 root root    6 Jul 11 15:24 oraclevdl -> ../sdi
lrwxrwxrwx.  1 root root    6 Jul 11 15:25 oraclevdm -> ../sdm

RAID 0 に 1本のディスクを追加です。
同時に2本のDiskを追加すると、Rebuild がうまく進まないように見えましたので、ご注意ください。
今回の検証では、6時間ほど Rebuild に時間が掛かりました

mdadm --grow /dev/md/mdadm-vol01 --level=raid0 --raid-devices=6 --backup-file=/root/RAID0ArrayBackup.reshape_$(date "+%Y%m%d_%H%M%S") --add /dev/oracleoci/oraclevdm

実行例

[root@lvm01 ~]# mdadm --grow /dev/md/mdadm-vol01 --level=raid0 --raid-devices=6 --backup-file=/root/RAID0ArrayBackup.reshape_$(date "+%Y%m%d_%H%M%S") --add /dev/oracleoci/oraclevdm
mdadm: level of /dev/md/mdadm-vol01 changed to raid4
mdadm: added /dev/oracleoci/oraclevdm
mdadm: Need to backup 120K of critical section..
[root@lvm01 ~]#

追加したタイミングで、性能が下がっている (RAID 4になったので、下がっているように見える)

[root@lvm01 ~]# sudo fio --filename=/dev/md/mdadm-vol01 --direct=1 --rw=randread --bs=4k --ioengine=libaio --
追加したタイミングで、性能が半分ほどになっている

mdadm で detail を確認すると、RAID 4 に一時的に切り替わっています
RAID 4 は、 RAID 0 + パリティディスク の構成です

[root@lvm01 ~]# mdadm --detail /dev/md/mdadm-vol01
/dev/md/mdadm-vol01:
           Version : 1.2
     Creation Time : Sat Jul 11 15:24:41 2020
        Raid Level : raid4
        Array Size : 4193643520 (3999.37 GiB 4294.29 GB)
     Used Dev Size : 838728704 (799.87 GiB 858.86 GB)
      Raid Devices : 7
     Total Devices : 6
       Persistence : Superblock is persistent

       Update Time : Sat Jul 11 15:27:06 2020
             State : clean, FAILED, reshaping
    Active Devices : 5
   Working Devices : 6
    Failed Devices : 0
     Spare Devices : 1

        Chunk Size : 4K

Consistency Policy : resync

    Reshape Status : 0% complete
     Delta Devices : 1, (6->7)

              Name : lvm01:mdadm-vol01  (local to host lvm01)
              UUID : 55cc11d3:a34ac1eb:8f391e0f:f6d62598
            Events : 50

    Number   Major   Minor   RaidDevice State
       0       8      176        0      active sync   /dev/sdl
       1       8       64        1      active sync   /dev/sde
       2       8      160        2      active sync   /dev/sdk
       3       8      144        3      active sync   /dev/sdj
       4       8      128        4      active sync   /dev/sdi
       6       8      192        5      spare rebuilding   /dev/sdm
       -       0        0        6      removed
[root@lvm01 ~]#

rebuild の速度が確認できる

cat /proc/mdstat

実行例

[root@lvm01 workdir]# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4] [raid0]
md127 : active raid4 sdm[6] sdi[4] sdj[3] sdk[2] sde[1] sdl[0]
      4193643520 blocks super 1.2 level 4, 4k chunk, algorithm 5 [7/6] [UUUUU__]
      [>....................]  reshape =  0.6% (5427840/838728704) finish=574.2min speed=24184K/sec

unused devices: <none>
[root@lvm01 workdir]#

なお、当たり前ですが、ファイルシステムとしては容量はかわっていません

[root@lvm01 oracleoci]# df -hT
Filesystem          Type      Size  Used Avail Use% Mounted on
devtmpfs            devtmpfs  158G     0  158G   0% /dev
tmpfs               tmpfs     158G     0  158G   0% /dev/shm
tmpfs               tmpfs     158G  9.0M  158G   1% /run
tmpfs               tmpfs     158G     0  158G   0% /sys/fs/cgroup
/dev/sda3           xfs        39G  2.0G   37G   6% /
/dev/sda1           vfat      512M   12M  501M   3% /boot/efi
/dev/sdc            xfs       800G  5.1G  795G   1% /mnt/singlevol01
/dev/mapper/vg1-lv1 xfs       4.0T  5.1G  3.9T   1% /mnt/lvmvol01
tmpfs               tmpfs      32G     0   32G   0% /run/user/1000
/dev/md127          xfs       4.0T  5.1G  3.9T   1% /mnt/mdadmvol01

Rebuild に時間が掛かるため、ステータスを確認しつづける Bash Script を流しておきます。

vim mdadm_detail_output.sh

中身

#!/bin/bash

while :
do
  echo "=========================="
  date
  mdadm --detail /dev/md/mdadm-vol01
  sleep 60;
  echo ""
  echo ""
done

exit 0

バックグラウンド実行

nohup sh mdadm_detail_output.sh >> output.logs &

なお、Rebuild のパフォーマンス調整はこちらで出来ます。あまりに数値を高くしすぎると、他に影響をあたえるので注意
http://liliumrubellum.blog10.fc2.com/blog-entry-300.html?sp

rebuild完了

[root@lvm01 workdir]# mdadm --detail /dev/md/mdadm-vol01
/dev/md/mdadm-vol01:
           Version : 1.2
     Creation Time : Sat Jul 11 15:24:41 2020
        Raid Level : raid4
        Array Size : 5032372224 (4799.24 GiB 5153.15 GB)
     Used Dev Size : 838728704 (799.87 GiB 858.86 GB)
      Raid Devices : 7
     Total Devices : 6
       Persistence : Superblock is persistent

       Update Time : Sun Jul 12 01:00:01 2020
             State : clean, degraded
    Active Devices : 6
   Working Devices : 6
    Failed Devices : 0
     Spare Devices : 0

        Chunk Size : 4K

Consistency Policy : resync

              Name : lvm01:mdadm-vol01  (local to host lvm01)
              UUID : 55cc11d3:a34ac1eb:8f391e0f:f6d62598
            Events : 1582

    Number   Major   Minor   RaidDevice State
       0       8      176        0      active sync   /dev/sdl
       1       8       64        1      active sync   /dev/sde
       2       8      160        2      active sync   /dev/sdk
       3       8      144        3      active sync   /dev/sdj
       4       8      128        4      active sync   /dev/sdi
       6       8      192        5      active sync   /dev/sdm
       -       0        0        6      removed
[root@lvm01 workdir]#

Rebuild が完了している状態でも、読み込み性能が半分ほどになっている。RAID 4 だからだと思われます

[root@lvm01 workdir]# sudo fio --filename=/dev/md/mdadm-vol01 --direct=1 --rw=randread --bs=4k --ioengine=libaio --iodepth=256 --runtime=120 --numjobs=4 --time_based --group_reporting --name=iops-test-job --eta-newline=1 --readonly
iops-test-job: (g=0): rw=randread, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=libaio, iodepth=256
...
Rebuild が完了しても、性能は半分ほどのまま

RAID 4 から RAID 0 へ変更 ※rebuild 中は実行不可。完了まで待たないといけない

mdadm --grow /dev/md/mdadm-vol01 --level=raid0 --backup-file=/root/RAID0ArrayBackup.reshape

実行例

[root@lvm01 workdir]# mdadm --grow /dev/md/mdadm-vol01 --level=raid0 --backup-file=/root/RAID0ArrayBackup.reshape
mdadm: level of /dev/md/mdadm-vol01 changed to raid0
[root@lvm01 workdir]#

コマンド実行直後、すぐに RAID 0 になる

/dev/md/mdadm-vol01:
           Version : 1.2
     Creation Time : Sat Jul 11 15:24:41 2020
        Raid Level : raid0
        Array Size : 5032372224 (4799.24 GiB 5153.15 GB)
      Raid Devices : 6
     Total Devices : 6
       Persistence : Superblock is persistent

       Update Time : Sun Jul 12 05:36:07 2020
             State : clean
    Active Devices : 6
   Working Devices : 6
    Failed Devices : 0
     Spare Devices : 0

        Chunk Size : 4K

Consistency Policy : none

              Name : lvm01:mdadm-vol01  (local to host lvm01)
              UUID : 55cc11d3:a34ac1eb:8f391e0f:f6d62598
            Events : 1583

    Number   Major   Minor   RaidDevice State
       0       8      176        0      active sync   /dev/sdl
       1       8       64        1      active sync   /dev/sde
       2       8      160        2      active sync   /dev/sdk
       3       8      144        3      active sync   /dev/sdj
       4       8      128        4      active sync   /dev/sdi
       6       8      192        5      active sync   /dev/sdm
[root@lvm01 workdir]#

RAID 0 にした瞬間に、性能が向上する。元々出ていた性能に加えて、Disk 追加したときの性能となっている

[root@lvm01 workdir]# sudo fio --filename=/dev/md/mdadm-vol01 --direct=1 --rw=randread --bs=4k --ioengine=libaio --iodepth=256 --runtime=120 --numjobs=4 --time_based --group_reporting --name=iops-test-job --eta-newline=1 --readonly
iops-test-job: (g=0): rw=randread, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=libaio, iodepth=256
...

ここまでで、Disk を1本追加して、性能を向上する方法を確認しました。次に、追加した Disk を使って、容量を拡張します。

ファイルシステムの拡張

ファイルシステムの容量は、Disk 追加前の容量となっているため、XFS ファイルシステムの拡張をしていきます

[root@lvm01 workdir]# df -hT
Filesystem          Type      Size  Used Avail Use% Mounted on
devtmpfs            devtmpfs  158G     0  158G   0% /dev
tmpfs               tmpfs     158G     0  158G   0% /dev/shm
tmpfs               tmpfs     158G  8.9M  158G   1% /run
tmpfs               tmpfs     158G     0  158G   0% /sys/fs/cgroup
/dev/sda3           xfs        39G  2.2G   36G   6% /
/dev/sda1           vfat      512M   12M  501M   3% /boot/efi
/dev/sdd            xfs       800G  5.1G  795G   1% /mnt/singlevol01
/dev/mapper/vg1-lv1 xfs       4.0T  5.1G  3.9T   1% /mnt/lvmvol01
tmpfs               tmpfs      32G     0   32G   0% /run/user/1000
/dev/md127          xfs       4.0T   33M  4.0T   1% /mnt/mdadmvol01    <============ ここ

以下コマンドで拡張します

xfs_growfs /mnt/mdadmvol01

実行結果

[root@lvm01 workdir]# xfs_growfs /mnt/mdadmvol01
meta-data=/dev/md127             isize=512    agcount=4, agsize=262102720 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=1048410880, imaxpct=5
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=511919, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 1048410880 to 1258093056

拡張されています

[root@lvm01 workdir]# df -hT
Filesystem          Type      Size  Used Avail Use% Mounted on
devtmpfs            devtmpfs  158G     0  158G   0% /dev
tmpfs               tmpfs     158G     0  158G   0% /dev/shm
tmpfs               tmpfs     158G  8.9M  158G   1% /run
tmpfs               tmpfs     158G     0  158G   0% /sys/fs/cgroup
/dev/sda3           xfs        39G  2.1G   36G   6% /
/dev/sda1           vfat      512M   12M  501M   3% /boot/efi
/dev/sdd            xfs       800G  5.1G  795G   1% /mnt/singlevol01
/dev/mapper/vg1-lv1 xfs       4.0T  5.1G  3.9T   1% /mnt/lvmvol01
tmpfs               tmpfs      32G     0   32G   0% /run/user/1000
/dev/md127          xfs       4.7T   33M  4.7T   1% /mnt/mdadmvol01

参考URL

Ubuntu mdadm その122 - RAID 0アレイの物理ボリューム数(スロット数)を増やすコマンドの例
https://kledgeb.blogspot.com/2014/04/ubuntu-mdadm-122-raid-0.html

Ubuntu mdadm その133 - アレイのチャンクサイズを変更する・アレイのチャンクサイズを変更するコマンドの説明
https://kledgeb.blogspot.com/2014/05/ubuntu-mdadm-133.html

Ubuntu mdadm その134 - RAID 0アレイのチャンクサイズを変更するコマンドの例
https://kledgeb.blogspot.com/2014/05/ubuntu-mdadm-134-raid-0.html

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2