码迷,mamicode.com
首页 > 其他好文 > 详细

软RAID(0,1,5,10)

时间:2019-10-04 23:12:16      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:列块   raid1   date   level   local   localhost   nts   xfs   配置文件   

技术图片

 

 

 如上添加硬盘

raid 0

[root@localhost ~]# mdadm -C -v /dev/md0 -l 0 -n 2 /dev/sdb /dev/sdc
mdadm: chunk size defaults to 512K
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.

-C    创建一个新阵列

-v     显示详细信息

-l      设定磁盘阵列的等级

-n     设定阵列的成员

[root@localhost ~]# mdadm -D /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Fri Oct 4 18:49:02 2019
Raid Level : raid0
Array Size : 10475520 (9.99 GiB 10.73 GB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent

Update Time : Fri Oct 4 18:49:02 2019
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0

Chunk Size : 512K

Consistency Policy : none

Name : localhost.localdomain:0 (local to host localhost.localdomain)
UUID : b9e04e06:5aac7e99:25a0a306:58fded53
Events : 0

Number Major Minor RaidDevice State
0 8 16 0 active sync /dev/sdb
1 8 32 1 active sync /dev/sdc

[root@localhost ~]# mdadm -Dsv > /etc/mdadm.conf    #生成配置文件

[root@localhost ~]# mkfs.xfs /dev/md0     #格式化

[root@localhost ~]# mkdir /raid0    #挂载

[root@localhost ~]# df -h

文件系统   容量    已用    可用    已用%     挂载点

/dev/md0    10G   33M     10G      1%        /raid0

[root@localhost ~]# echo 123456 >> /raid0/aaa.txt
[root@localhost ~]# cat /raid0/aaa.txt
123456

[root@localhost ~]# blkid /dev/md0
/dev/md0: UUID="c4096f03-259b-44b3-88be-a6909315e591" TYPE="xfs"

[root@localhost ~]# echo "UUID=c4096f03-259b-44b3-88be-a6909315e591 /raid0/ xfs defaults 0 0" >> /etc/fstab             #将/dev/md0追加到/etc/fstab下,开机自动挂载

[root@localhost ~]# umount /raid0/

[root@localhost ~]# mount -a

RAID1

1)创建RAID1

[root@localhost ~]# mdadm -C -v /dev/md1 -l 1 -n 2 -x 1 /dev/sd[d,e,f]
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
mdadm: size set to 5237760K
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md1 started.

[root@localhost ~]# mdadm -Dsv > /etc/mdadm.conf    #生成配置文件

[root@localhost ~]# mdadm -D /dev/md1
/dev/md1:
Version : 1.2
Creation Time : Fri Oct 4 20:27:46 2019
Raid Level : raid1
Array Size : 5237760 (5.00 GiB 5.36 GB)
Used Dev Size : 5237760 (5.00 GiB 5.36 GB)

Consistency Policy : resync

Name : localhost.localdomain:1 (local to host localhost.localdomain)
UUID : 163d85c1:eabfbf27:507cad66:60017d38
Events : 17

Number Major Minor RaidDevice State
0 8 48 0 active sync /dev/sdd
1 8 64 1 active sync /dev/sde

2 8 80 - spare /dev/sdf

[root@localhost ~]# mkfs.xfs /dev/md1     #格式化

[root@localhost ~]# mkdir /raid1
[root@localhost ~]# mount /dev/md1 /raid1

[root@localhost ~]# cp /etc/passwd /raid1
[root@localhost ~]# cp -r /boot/grub /raid1

[root@localhost ~]# cp -r /etc/ /raid1/

[root@localhost ~]# df -h

/dev/md1     5.0G     75M     5.0G     2%      /raid1

2)模拟故障

[root@localhost ~]# mdadm  /dev/md1  -f   /dev/sdd 
mdadm: set /dev/sdd faulty in /dev/md1

[root@localhost ~]# mdadm -D /dev/md1

Number Major Minor RaidDevice State
2 8 80 0 active sync     /dev/sdf
1 8 64 1 active sync     /dev/sde

0 8 48 - faulty       /dev/sdd      #热备盘顶上

[root@localhost raid1]# mdadm -Dsv > /etc/mdadm.conf

[root@localhost ~]# mdadm -r /dev/md1 /dev/sdd      #移除损坏的磁盘

3)添加热备盘

[root@localhost ~]# mdadm -a /dev/md1 /dev/sdd     #添加热备盘

RAID5

1)创建RAID5,添加热备盘,制定chunk大小为32K

-x或--spare-devicds= 制定阵列中备用盘的数量

-c或--chunk= 设定阵列块chunk块的大小,单位为KB

[root@localhost ~]# mdadm -C -v /dev/md5 -l 5 -n 3 -x 1 -c32 /dev/sd[g,h,i,j]

[root@localhost ~]# mdadm -D /dev/md5

/dev/md5:
Version : 1.2
Creation Time : Fri Oct 4 20:59:12 2019
Raid Level : raid5
Array Size : 10475520 (9.99 GiB 10.73 GB)
Used Dev Size : 5237760 (5.00 GiB 5.36 GB)
Raid Devices : 3
Total Devices : 4
Persistence : Superblock is persistent

Update Time : Fri Oct 4 20:59:23 2019
State : clean, degraded, recovering
Active Devices : 2
Working Devices : 4
Failed Devices : 0
Spare Devices : 2

Layout : left-symmetric
Chunk Size : 32K

Consistency Policy : resync

Rebuild Status : 97% complete            #正在同步

Name : localhost.localdomain:5 (local to host localhost.localdomain)
UUID : 137e891d:8ba777fe:59d16fdf:9a5c68b4
Events : 16

Number Major Minor RaidDevice State
0 8 96 0 active sync   /dev/sdg
1 8 112 1 active sync /  dev/sdh
4 8 128 2 spare rebuilding    /dev/sdi

3 8 144 - spare    /dev/sdj         #热备盘

2)停止阵列,重新激活阵列

[root@localhost ~]# mdadm -S /dev/md5      #停止阵列

mdadm: stopped /dev/md5

[root@localhost ~]# mdadm -As      #会加载/etc/mdadm.conf文件来激活raid5
mdadm: /dev/md5 has been started with 3 drives and 1 spare.

 

3)使用热备盘,扩展阵列容量,从3个磁盘扩展到4个磁盘

[root@localhost ~]# mdadm -G /dev/md5 -n4 -c 32

-G或--grow 改变阵列大小或形态

[root@localhost ~]# mdadm -D /dev/md5

#待同步完毕

Number Major Minor RaidDevice State
0 8 96 0 active sync    /dev/sdg
1 8 112 1 active sync    /dev/sdh
4 8 128 2 active sync    /dev/sdi
3 8 144 3 active sync    /dev/sdj

RAID10

省略分区步骤。。。。。

[root@localhost ~]# ls /dev/sdk*
/dev/sdk    /dev/sdk1    /dev/sdk2    /dev/sdk3    /dev/sdk4

[root@localhost ~]# mdadm -C -v /dev/md10 -l 10 -n 4 /dev/sdk[1-4]

[root@localhost ~]# mdadm -Dsv > /etc/mdadm.conf

[root@localhost ~]# mdadm -D /dev/md10 


Number Major Minor RaidDevice State
0 8 161 0 active sync set-A    /dev/sdk1
1 8 162 1 active sync set-B    /dev/sdk2
2 8 163 2 active sync set-A    /dev/sdk3
3 8 164 3 active sync set-B    /dev/sdk4

---------------------------------------------------------------------------

清除阵列

[root@localhost ~]# umount /dev/md0 /raid0

[root@localhost ~]# mdadm -Ss

[root@localhost ~]# mdadm --zero-superblock /dev/sdb
[root@localhost ~]# mdadm --zero-superblock /dev/sdc

 

软RAID(0,1,5,10)

标签:列块   raid1   date   level   local   localhost   nts   xfs   配置文件   

原文地址:https://www.cnblogs.com/zsg-cdhk/p/11623410.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!