欢迎来到CloudService文涵的博客

人生三从境界:昨夜西风凋碧树,独上高楼,望尽天涯路。 衣带渐宽终不悔,为伊消得人憔悴。 众里寻他千百度,蓦然回首,那人却在灯火阑珊处。

制作raid0

raid0(速率好,数据保护不好)

1.添加3块磁盘

root@localhost ~]# lsblk 
NAMEMAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda   8:00   20G  0 disk 
├─sda18:101G  0 part /boot
└─sda28:20   19G  0 part 
  ├─centos-root 253:00   17G  0 lvm  /
  └─centos-swap 253:102G  0 lvm  [SWAP]
sdb   8:16   0  204M  0 disk 
sdc   8:32   0  204M  0 disk 
sdd   8:48   0  204M  0 disk 
sr0  11:01  4.3G  0 rom  /run/media/root/CentOS 7 x86_64

2.分区并设置类型(type)

[root@localhost ~]# fdisk /dev/sdb 
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x1ef994e2.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended

Select (default p): p
Partition number (1-4, default 1): 
First sector (2048-417791, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-417791, default 417791): 
Using default value 417791
Partition 1 of type Linux and of size 203 MiB is set

Command (m for help): 
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): fd
Changed type of partition 'Linux' to 'Linux raid autodetect'

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

3.创建raid0

[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.

4.查看md0的详情

[root@localhost ~]# mdadm -D /dev/md0 
/dev/md0:
           Version : 1.2
     Creation Time : Sun Apr  3 22:09:33 2022
        Raid Level : raid0
        Array Size : 933888 (912.00 MiB 956.30 MB)
      Raid Devices : 3
     Total Devices : 3
       Persistence : Superblock is persistent

       Update Time : Sun Apr  3 22:09:33 2022
             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 : d321970c:517740ba:f40b157a:6be49a35
            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

5.格式化md0

[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
58368 inodes, 233472 blocks
11673 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=239075328
8 block groups
32768 blocks per group, 32768 fragments per group
7296 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376

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

6.创建文件夹,挂载,测试

[root@localhost ~]# mkdir wenhan

[root@localhost ~]# mount /dev/md0 wenhan/

[root@localhost ~]# df -hT
Filesystem              Type      Size  Used Avail Use% Mounted on
/dev/mapper/centos-root xfs        17G  4.5G   13G  27% /
devtmpfs                devtmpfs  974M     0  974M   0% /dev
tmpfs                   tmpfs     991M     0  991M   0% /dev/shm
tmpfs                   tmpfs     991M   11M  980M   2% /run
tmpfs                   tmpfs     991M     0  991M   0% /sys/fs/cgroup
/dev/sda1               xfs      1014M  166M  849M  17% /boot
tmpfs                   tmpfs     199M  4.0K  199M   1% /run/user/42
tmpfs                   tmpfs     199M   20K  199M   1% /run/user/0
/dev/sr0                iso9660   4.3G  4.3G     0 100% /run/media/root/CentOS 7 x86_64
/dev/md0                ext4      882M  2.3M  818M   1% /root/wenhan

[root@localhost ~]# cd wenhan/
[root@localhost wenhan]# ls
lost+found
[root@localhost wenhan]# touch wenhan
[root@localhost wenhan]# ls
lost+found  wenhan

7.写入数据并测试raid0的速率(这次情况特殊,请使用redhat做)

[root@localhost ~]# time dd if=/dev/md0 of=txt bs=1M count=1000
912+0 records in
912+0 records out
956301312 bytes (956 MB) copied, 2.58295 s, 370 MB/s

real	0m2.639s
user	0m0.000s
sys	0m2.584s

[root@localhost ~]# time dd if=/dev/sda of=txt bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes (1.0 GB) copied, 2.0844 s, 503 MB/s

real	0m2.136s
user	0m0.000s
sys	0m1.203s
posted on 2022-04-03 14:21  Cloudservice  阅读(106)  评论(0编辑  收藏  举报