Linux 基础 之 Raid 磁盘阵列

在Linux内核中有一个md模块,可以通过mdadm指令在用户空间中对raid进行管理。

mdadm 模式

raidname   [options]   devdir:

-C 创建模式

 -n  number用于创建raid的设备个数

-x   number(1&0)1表示读得快,0表示写得快。

-l 指定raid级别

-a yes/no是否自动为创建的raid设备创建设备文件

步骤:

fdisk  /dev/vdb            ##创建三个分区,分区标示为raid


watch -n 1 cat /proc/mdstat                ##监控

扫描二维码关注公众号,回复: 910140 查看本文章


[root@localhost ~]# mdadm -C /dev/md0   -a yes     -l 1    -n 2      -x 1     /dev/vdb{1..3}       ##双磁盘的闲置

mdadm: Note: this array has metadata at the start and
    may not be suitable as a boot device.  If you plan to
    store '/boot' on this device please ensure that
    your boot-loader understands md/v1.x metadata, or use
    --metadata=0.90
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata

mdadm: array /dev/md0 started.


[root@localhost ~]# mkfs.xfs /dev/md0    ##格式化
meta-data=/dev/md0               isize=256    agcount=4, agsize=65500 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=262000, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=853, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@localhost ~]# mount /dev/md0 /mnt/                          ##挂载
[root@localhost ~]# df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/vda1       10473900 3760904   6712996  36% /
devtmpfs          469344       0    469344   0% /dev
tmpfs             484932      84    484848   1% /dev/shm
tmpfs             484932   12816    472116   3% /run
tmpfs             484932       0    484932   0% /sys/fs/cgroup

/dev/md0         1044588   32928   1011660   4% /mnt 

         

挂载成功

mdadm -D /dev/md0                               ##查看raid状态


mdadm  /dev/md0 -f /dev/vdb2            ##失效指定硬盘


mdadm  /dev/md0 -r /dev/vdb2             ##删除指定硬盘


mdadm  /dev/md0 -a /dev/vdb2            ##添加指定硬盘


umount /mnt/                    ##取消挂载

mdadm  -S  /dev/md0                ##停止使用


fdisk /dev/vdb                                  ##删除分区

partprobe                                       ##同步分区表



猜你喜欢

转载自blog.csdn.net/janenancy/article/details/80177413