RAID模拟测试

RAID模拟测试
问题:测试RAID 0、1、5、10,写入磁盘的速度
一、添加磁盘sdb、sdc、sdd三块磁盘容量为20G

[root@localhost ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINT
sda               8:0    0   60G  0 disk  
├─sda1            8:1    0    2G  0 part  /boot
└─sda2            8:2    0   58G  0 part  
  ├─centos-root 253:0    0   20G  0 lvm   /
  ├─centos-swap 253:1    0    4G  0 lvm   [SWAP]
  └─centos-home 253:2    0   34G  0 lvm   /home
sdb               8:16   0   20G  0 disk  
├─sdb1            8:17   0    2G  0 part  
│ └─md0           9:0    0    6G  0 raid0 /test_raid0
└─sdb2            8:18   0    2G  0 part  
sdc               8:32   0   20G  0 disk  
├─sdc1            8:33   0    2G  0 part  
│ └─md0           9:0    0    6G  0 raid0 /test_raid0
└─sdc2            8:34   0    2G  0 part  
sdd               8:48   0   20G  0 disk  
├─sdd1            8:49   0    2G  0 part  
│ └─md0           9:0    0    6G  0 raid0 /test_raid0
└─sdd2            8:50   0    2G  0 part  
sr0              11:0    1  4.3G  0 rom   /mnt

二、创建名称为md0的RAID 0设备,

[root@localhost ~]# mdadm -C /dev/md0 -l 0 -n 3 /dev/sdb1 /dev/sdc1 /dev/sdd1
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.

三、查看md0详细信息

[root@localhost ~]# mdadm --detail /dev/md0
/dev/md0:
           Version : 1.2
     Creation Time : Sat Nov 23 07:17:10 2019 #创建时间
        Raid Level : raid0 #RAID级别
        Array Size : 6282240 (5.99 GiB 6.43 GB) #RAID磁盘空间
      Raid Devices : 3 #磁盘个数
     Total Devices : 3
       Persistence : Superblock is persistent

       Update Time : Sat Nov 23 07:17:10 2019
             State : clean 
    Active Devices : 3 #活动磁盘个数
   Working Devices : 3 #工作磁盘个数
    Failed Devices : 0 #错误磁盘个数
     Spare Devices : 0 #备用磁盘个数

        Chunk Size : 512K #组块大小

Consistency Policy : none

              Name : localhost.localdomain:0  (local to host localhost.localdomain)
              UUID : 550027da:6155c2e9:3498d18a:b50674dc #设备UUID
            Events : 0

    Number   Major   Minor   RaidDevice State
       0       8       17        0      active sync   /dev/sdb1
       1       8       33        1      active sync   /dev/sdc1
       2       8       49        2      active sync   /dev/sdd1

四、格式化与开机自动挂载

[root@localhost ~]# mkfs.ext4 /dev/md0
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=128 blocks, Stripe width=384 blocks
393216 inodes, 1570560 blocks
78528 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1608515584
48 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done 

[root@localhost ~]# mkdir /test_raid0
[root@localhost ~]# mount /dev/md0 /test_raid0
[root@localhost ~]# mount -av
/                        : ignored
/boot                    : already mounted
/home                    : already mounted
swap                     : ignored
/mnt                     : already mounted
/test_raid0              : already mounted
[root@localhost ~]# cat /etc/mdadm.conf  #开机读取磁盘阵列文件以启动RAID设备
DEVICE /dev/sdb1 /dev/sdc1 /dev/sdd1 #填写所有磁盘阵列设备名称
[root@localhost ~]# mdadm -Evs > /dev/mdadm.conf 
[root@localhost ~]# cat /dev/mdadm.conf #描述磁盘阵列具体基本信息,名称、级别、UUID
ARRAY /dev/md/0  level=raid0 metadata=1.2 num-devices=3 UUID=550027da:6155c2e9:3498d18a:b50674dc name=localhost.localdomain:0
   devices=/dev/sdb1,/dev/sdc1,/dev/sdd1

五、测试

(一)本地磁盘与RAID 0同时写入3G文件测试
[root@localhost ~]# time dd if=/dev/zero of=test_zhang bs=3M count=1000
1000+0 records in
1000+0 records out
3145728000 bytes (3.1 GB) copied, 89.9371 s, 35.0 MB/s
real	1m30.492s
user	0m0.034s
sys	0m40.085s
[root@localhost ~]# cd /test_raid0/
[root@localhost test_raid0]# time dd if=/dev/zero of=test_zhang bs=3M count=1000
1000+0 records in
1000+0 records out
3145728000 bytes (3.1 GB) copied, 4.27539 s, 736 MB/s

real	0m4.279s
user	0m0.008s
sys	0m4.132s
写入3G文件,本地磁盘用时real	1m30.492s,写入RAID 0用时real	0m4.279s
[root@localhost test_raid0]# time dd if=/dev/zero of=test_raid0 bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes (1.0 GB) copied, 0.85595 s, 1.2 GB/s

real	0m0.979s
user	0m0.005s
sys	0m0.958s
写入1G文件RAID 0用时real	0m0.979s
(二)本地磁盘与RAID 1同时写入1G文件
[root@localhost ~]# time dd if=/dev/zero of=test_zhang2 bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes (1.0 GB) copied, 9.5321 s, 110 MB/s

real	0m12.533s
user	0m0.014s
sys	0m1.770s
[root@localhost ~]# cd /test_raid1
[root@localhost test_raid1]# time dd if=/dev/zero of=test_zhang2 bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes (1.0 GB) copied, 1.24787 s, 840 MB/s

real	0m1.277s
user	0m0.005s
sys	0m1.122s
本地用时real	0m12.533s,RAID 1用时real	0m1.277s
(三)本地磁盘与RAID 5同时写入1G文件
[root@localhost ~]# time dd if=/dev/zero of=test-zhang5 bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes (1.0 GB) copied, 11.6886 s, 89.7 MB/s

real	0m11.841s
user	0m0.002s
sys	0m1.858s
[root@localhost ~]# cd /test-zhang5/
[root@localhost test-zhang5]# time dd if=/dev/zero of=test-zhang5 bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes (1.0 GB) copied, 1.79836 s, 583 MB/s

real	0m1.802s
user	0m0.013s
sys	0m1.260s
本地用时real	0m11.841s,RAID 5用时real	0m1.802s
(四)本地磁盘与RAID10同时写入1G文件
创建RAID 10
[root@localhost ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE   MOUNTPOINT

sdb               8:16   0   20G  0 disk   
├─sdb1            8:17   0    2G  0 part   
│ └─md10          9:10   0    4G  0 raid10 
└─sdb2            8:18   0    2G  0 part   
  
sdd               8:48   0   20G  0 disk   
├─sdd1            8:49   0    2G  0 part   
│ └─md10          9:10   0    4G  0 raid10 
└─sdd2            8:50   0    2G  0 part   
sde               8:64   0   20G  0 disk   
└─sde1            8:65   0    2G  0 part   
  └─md10          9:10   0    4G  0 raid10 
sdf               8:80   0   20G  0 disk   
└─sdf1            8:81   0    2G  0 part   
  └─md10          9:10   0    4G  0 raid10 
  [root@localhost ~]# mdadm -D /dev/md10  #查看RAID 10详细信息
/dev/md10:
           Version : 1.2
     Creation Time : Sat Nov 23 08:36:22 2019
        Raid Level : raid10
        Array Size : 4188160 (3.99 GiB 4.29 GB)
     Used Dev Size : 2094080 (2045.00 MiB 2144.34 MB)
      Raid Devices : 4
     Total Devices : 4
       Persistence : Superblock is persistent

       Update Time : Sat Nov 23 08:36:47 2019
             State : clean 
    Active Devices : 4
   Working Devices : 4
    Failed Devices : 0
     Spare Devices : 0

            Layout : near=2
        Chunk Size : 512K

Consistency Policy : resync

              Name : localhost.localdomain:10  (local to host localhost.localdomain)
              UUID : 87ef7c71:c85f797d:5ea3d083:76398dbe
            Events : 17

    Number   Major   Minor   RaidDevice State
       0       8       17        0      active sync set-A   /dev/sdb1
       1       8       49        1      active sync set-B   /dev/sdd1
       2       8       65        2      active sync set-A   /dev/sde1
       3       8       81        3      active sync set-B   /dev/sdf1
[root@localhost ~]# time dd if=/dev/zero of=test_zhang10 bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes (1.0 GB) copied, 14.7305 s, 71.2 MB/s

real	0m14.896s
user	0m0.002s
sys	0m0.808s
[root@localhost ~]# cd /test_raid10
[root@localhost test_raid10]# time dd if=/dev/zero of=test_zhang10 bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes (1.0 GB) copied, 0.88417 s, 1.2 GB/s

real	0m0.895s
user	0m0.004s
sys	0m0.856s
本地用时0m14.896s,RAID 10用时real	0m0.895s

总结:相同条件下,1G文件写速度分别是:

RAID 0用时real	0m0.979s
RAID 1用时real	0m1.277s
RAID 5用时real	0m1.802s
RAID 10用时real	0m0.895s

RAID读取速度下回见

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

河 静

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值