在CentOS-7.0下高级硬盘管理RAID 1+0方案

简介:

企业经常用到的RAID+LVM管理模式

用到的软件:VMware Workstation 10

系统环境:

1
2
3
4
5
[root@localhost~] # cat /etc/centos-release 
CentOSLinux release 7.0.1406 (Core) 
[root@localhost~] # rpm -qi mdadm
Name        : mdadm
Version     : 3.2.6


RAID 1+0方案

简介

先对磁盘做mirror,然后对整个mirror组做条带化;比如8块盘需要分成4个基组,每个基组2块盘;每个基组先做raid1,再做raid0,4条条带化。

所以:

允许所有磁盘基组中的磁盘各损坏一个,但是不允许同一基组中的磁盘同时有坏的。

优点:数据安全性好,只要不是1个条带上的2个硬盘同时坏,没有问题,还可以继续跑数据。数据恢复快。

缺点 :写性能稍微比RAID 0+1 差(读性能一样)


我的思路

在新添加的硬盘上划分4个1G的区域分别为1,2,3,5

每两个转化为一个RAID 1 卷 /dev/md{1,2}

将这两个RAID 1 卷转化为一个RAID 0卷/dev/md0

将RAID 0转化为pv,vg

之后通过lv创建自己的空间

这个空间就具有RAID 1+0的性质


详细实施过程



wKioL1PswEeQho-hAAB1JDjGTu4177.jpg

我们这里添加一块用作实验的硬盘2

我们不想重启来读取新添加的硬盘,我们输入下面命令进行扫描

1
2
3
4
5
6
7
8
[root@localhost~] # echo "- - -" > /sys/class/scsi_host/host0/scan
[root@localhost~] # echo "- - -" > /sys/class/scsi_host/host1/scan
[root@localhost~] # echo "- - -" > /sys/class/scsi_host/host2/scan
[root@localhost~] # fdisk -l
Disk  /dev/sdb : 21.5 GB, 21474836480 bytes, 41943040sectors
Units= sectors of 1 * 512 = 512 bytes
Sectorsize (logical /physical ): 512 bytes / 512 bytes
I /Osize  (minimum /optimal ): 512 bytes / 512 bytes


发现新添加的sdb

 

下面开始具体的实验过程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#fdisk/dev/sdb
Command(m  for  help): n
Partitiontype:
    p  primary (0 primary, 0 extended, 4  free )
    e  extended
Select(default p): 
Usingdefault response p
Partitionnumber (1-4, default 1): 
Firstsector (2048-41943039, default 2048): 
Usingdefault value 2048
Lastsector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +1G
Partition1 of  type  Linux and of size 1 GiB is  set
Command(m  for  help): n
Partitiontype:
    p  primary (1 primary, 0 extended, 3  free )
    e  extended
Select(default p): 
Usingdefault response p
Partitionnumber (2-4, default 2): 
Firstsector (2099200-41943039, default 2099200): 
Usingdefault value 2099200
Lastsector, +sectors or +size{K,M,G} (2099200-41943039, default 41943039): +1G
Partition2 of  type  Linux and of size 1 GiB is  set
Command(m  for  help): n
Partitiontype:
    p  primary (2 primary, 0 extended, 2  free )
    e  extended
Select(default p): 
Usingdefault response p
Partitionnumber (3,4, default 3): 
Firstsector (4196352-41943039, default 4196352): 
Usingdefault value 4196352
Lastsector, +sectors or +size{K,M,G} (4196352-41943039, default 41943039): +1G
Partition3 of  type  Linux and of size 1 GiB is  set
Command(m  for  help): n
Partitiontype:
    p  primary (3 primary, 0 extended, 1  free )
    e  extended
Select (default e): 
Usingdefault response e
Selectedpartition 4
Firstsector (6293504-41943039, default 6293504): 
Usingdefault value 6293504
Lastsector, +sectors or +size{K,M,G} (6293504-41943039, default 41943039): 
Usingdefault value 41943039
Partition4 of  type  Extended and of size 17 GiB is  set


将剩余的所有空间划给扩展区,之后再划分区间用l命令即逻辑盘区

此后的区间号就从5开始往后加

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
Command(m  for  help): n
Allprimary partitions are  in  use
Addinglogical partition 5
Firstsector (6295552-41943039, default 6295552): 
Usingdefault value 6295552
Lastsector, +sectors or +size{K,M,G} (6295552-41943039, default 41943039): +1G
Partition5 of  type  Linux and of size 1 GiB is  set
Command(m  for  help): p
  
Disk /dev/sdb : 21.5 GB, 21474836480 bytes, 41943040 sectors
Units= sectors of 1 * 512 = 512 bytes
Sectorsize (logical /physical ): 512 bytes / 512 bytes
I /Osize  (minimum /optimal ): 512 bytes / 512 bytes
Disklabel  type : dos
Diskidentifier: 0x8e9a9326
  
    Device Boot      Start         End      Blocks  Id  System
/dev/sdb1             2048     2099199    1048576   83 Linux
/dev/sdb2          2099200     4196351    1048576   83  Linux
/dev/sdb3          4196352     6293503    1048576   83  Linux
/dev/sdb4          6293504    41943039   17824768    5  Extended
/dev/sdb5          6295552     8392703    1048576   83  Linux
/dev/sdb6          8394752    10491903    1048576   83  Linux
[root@localhost ~] # mdadm -C /dev/md1-a yes -l 1 -n 2 /dev/sdb{1,2}
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 ensurethat
     your boot-loader understands md /v1 .xmetadata, or use
     --metadata=0.90
Continuecreating array? 
Continuecreating array? (y /n ) y
mdadm:Defaulting to version 1.2 metadata
mdadm:array  /dev/md1  started.
  [root@localhost ~] # mdadm -C /dev/md2 -a yes-l 1 -n 2 /dev/sdb{3,5}
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 ensurethat
     your boot-loader understands md /v1 .xmetadata, or use
     --metadata=0.90
Continuecreating array? 
Continuecreating array? (y /n ) y
mdadm:Defaulting to version 1.2 metadata
mdadm:array  /dev/md2  started.
  [root@localhost ~] # mdadm -C /dev/md0 -a yes-l 1 -n 2 /dev/md{1,2}(将RAID1转化为RAID0)
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 ensurethat
     your boot-loader understands md /v1 .xmetadata, or use
     --metadata=0.90
Continuecreating array? 
Continuecreating array? (y /n ) y
mdadm:Defaulting to version 1.2 metadata
mdadm:array  /dev/md0  started.
[root@localhost ~] # pvcreate /dev/md0(变PV)
   Physical volume  "/dev/md0" successfully created
[root@localhost ~] # vgcreate first/dev/md0(变VG)
   Volume group  "first"  successfullycreated
[root@localhost~] # lvcreate -L 1G -n data1 first
   Volume group  "first"  hasinsufficient  free  space (255 extents): 256 required.
[root@localhost ~] # lvcreate -L +500M-n data1 first(划分自己想要的区域大小)
   Logical volume  "data1"  created
  
[root@localhost ~] # mkfs.ext4/dev/first/data1(格式化)
mke2fs1.42.9 (28-Dec-2013)
Filesystemlabel=
OStype: Linux
Blocksize=1024 (log=0)
Fragmentsize=1024 (log=0)
Stride=0blocks, Stripe width=0 blocks
128016inodes, 512000 blocks
25600blocks (5.00%) reserved  for  the super user
Firstdata block=1
Maximumfilesystem blocks=34078720
63block  groups
8192blocks per group, 8192 fragments per group
2032inodes per group
Superblockbackups stored on blocks: 
         8193, 24577, 40961, 57345, 73729,204801, 221185, 401409
  
Allocatinggroup tables:  done                           
Writinginode tables:  done                           
Creatingjournal (8192 blocks):  done
Writingsuperblocks and filesystem accounting information:  done
  
[root@localhost~] # mkdir /lvm1
[root@localhost~] # mount /dev/first/data1 /lvm1
[root@localhost~] # cd /lvm1
[root@localhostlvm1] # ll
total12
drwx------2 root root 12288 Aug 12 21:21 lost+found


挂载后即可对划分出的新空间进行使用。

举例

这里举个例子,20个硬盘

做RAID 1+0,共10个条带,每个条带2个硬盘做MIRROR,如果坏了1个硬盘,没关系,其它19个硬盘还要同时工作,只要不是坏在一个MIRROR里面的,就没事。

建议,硬盘很多时,同时坏的几率就比较大,建议使用安全系数高的RAID 1+0,宁愿损失点性能(其实差不多)。

后语:

新手,如有错误,欢迎指正。











本文转自 紫色的茶碗 51CTO博客,原文链接:http://blog.51cto.com/chawan/1540190,如需转载请自行联系原作者
目录
相关文章
|
Linux
Centos7 系列:磁盘挂载和磁盘扩容(新加硬盘方式)
在Centos 7 系统中,新添加硬盘,并将其挂载到自定义的新目录下;新添加硬盘,并为已有硬盘扩容。
2401 0
Centos7 系列:磁盘挂载和磁盘扩容(新加硬盘方式)
|
存储 安全 Linux
CentOS7 部署 RAID 磁盘阵列
RAID (Redundant Array of lndependent Disk 独立冗余磁盘阵列)就是把多块独立的物理磁盘按不同的方式组合起来形成一个磁盘组(逻辑硬盘)。从而提供比单个磁盘更高的存储性能和提供数据备份技术。
729 0
CentOS7 部署 RAID 磁盘阵列
|
存储 Shell Linux
centos 6.5挂载硬盘
很多朋友对于LINUX的主机挂载经常询问我,现在把挂载教程进行分享,大家共同学习交流
346 0
centos 6.5挂载硬盘
|
Linux
阿里云CentOS添加硬盘
阿里云CentOS添加硬盘
414 0
阿里云CentOS添加硬盘
|
固态存储 Linux Shell
在以 CentOS7.6 为基础镜像的 Docker 容器中通过 NFS 将内存挂载成高速硬盘使用
在以 CentOS7.6 为基础镜像的 Docker 容器中通过 NFS 将内存挂载成高速硬盘使用 一 背景 这是最近项目中遇到的一个问题。在已知的部署在 docker 容器云上某个应用中,读写非常频繁,对磁盘的性能要求极高,但是又不能在同一个容器内进行高强度读写。
2566 0

热门文章

最新文章