RAID:冗余磁盘阵列
极大地增强Linux磁盘的I/O性能和可靠性磁盘阵列实现方式:
1.软件阵列 2.硬件阵列
RAID 0:无数据冗余的存储空间条带化,具有成本低、读取性能极高、存储空间利用率高等特点。但是由于没有数据冗余,其安全性大大降低,只是提高了磁盘读写性能和整个服务器的磁盘容量,构成阵列的任何一块硬盘损坏都将带来灾难性的数据损失。
RAID 1:两块硬盘数据完全镜像,安全性好,技术简单,管理方便,读写性能均好。缺点是无法单块硬盘扩展,必须同时对镜像双方进行同容量的扩展,实际上只利用了一半的磁盘容量。数据空间浪费大。
RAID 0 + 1:结合READ 0 和 READ 1 的特点,独立磁盘配置成READ 0,两套完整的READ 0互成镜像。读写性能出色,安全性高。缺点是构建阵列的成本投入大,数据空间利用率低。
READ 5:目前应用最广泛的READ技术,个快独立硬盘进行条带化分割,相同的条带区进行奇偶校验(异或运算),校验数据平均分布在每块磁盘上。N块硬盘构建的READ 5阵列可以有N -1块硬盘的容量,存储空间利用率非常高。任何一块硬盘数据丢失,都可以通过奇偶校验数据推算出来。缺点是 如果一块硬盘出现故障以后,整个系统的性能将会大大降低。
1. 查看可用插槽slot和encloseure、adapter(可用qdatamgr获取)
/usr/local/bin/MegaCli64 -PDList -aALL egrep ‘Adapter Enclosure Slot’
[root@localhost packages]# MegaCli64 -PDList -aALL | egrep 'Adapter|Enclosure|Slot'
Adapter #0
Enclosure Device ID: 8
Slot Number: 0
Enclosure position: 1
Enclosure Device ID: 8
Slot Number: 1
Enclosure position: 1
Enclosure Device ID: 8
Slot Number: 2
Enclosure position: 1
说明:一个raid适配器(adapter)后面有个编号,这个信息输出的就是0。 一个槽位(slot)便是一块盘,这个信息表示有3个槽位,表示有三个盘。 Enclosure这个是在创建盘的时候要用。
2. 删除raid缓存和逻辑磁盘
删除所有适配器的逻辑磁盘:
- 清除外部设备
/usr/local/bin/MegaCli64 ‘-CfgForeign -Clear’ -a0
- 检查jbod,清除jbod,这里找出jbod的盘,然后使用这个命令,将格式改正为good格式
/usr/local/bin/MegaCli64 PDMakeGood -PhysDrv[8:5] -Force -a0
- 清除逻辑盘
/usr/local/bin/MegaCli64 -CfgLdDel -LAll -aAll
- 清除unconfigure(bad)
/usr/local/bin/MegaCli64 -LDMakeGood -PhysDrv[8:5] -Force -a0
3.创建硬raid命令
MegaCli -CfgLdAdd -rX[E0:S0,E1:S1,...] [WT|WB] [NORA|RA] [Direct|Cached]
[CachedBadBBU|NoCachedBadBBU] [-szXXX [-szYYY ...]]
[-strpszM] [-Hsp[E0:S0,...]] [-AfterLdX] | [FDE|CtrlBased]
[-Default| -Automatic| -None| -Maximum| -MaximumWithoutCaching] [-Cache] [-enblPI] [-Force]-aN
创建raid0命令
这里的adapte和slot enclosure是从qdatamgr中拿的
/usr/local/bin/MegaCli64 -CfgLdAdd -r0[8:0,8:1] WT NORA -a0
Adapter 0: Created VD 0
Adapter 0: Configured the Adapter!!
Exit Code: 0x00
配置成功之后进行初始化操作,一般只要初始化条带化的raid
/opt/MegaRAID/MegaCli/MegaCli64 -LDInit -Start -L0 -a0 这里面的初始化有两种,一种是fast,还有一种是full
查看配置之后的信息
[root@localhost packages]# /usr/local/bin/MegaCli64 -LDInfo -Lall -aAll
Adapter 0 -- Virtual Drive Information:
Virtual Drive: 0 (Target Id: 0)
Name :
RAID Level : Primary-0, Secondary-0, RAID Level Qualifier-0
Size : 3.637 TB
Sector Size : 512
Is VD emulated : No
Parity Size : 0
State : Optimal
Strip Size : 256 KB
Number Of Drives : 2
Span Depth : 1
Default Cache Policy: WriteThrough, ReadAheadNone, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteThrough, ReadAheadNone, Direct, No Write Cache if Bad BBU
Default Access Policy: Read/Write
Current Access Policy: Read/Write
Disk Cache Policy : Disk's Default
Encryption Type : None
PI type: No PI
Is VD Cached: No
创建raid1命令
/usr/local/bin/MegaCli64 -CfgLdAdd -r1 [8:0,8:1] WB NORA -a0
Adapter 0: Created VD 0
Adapter 0: Configured the Adapter!!
Exit Code: 0x00
查询创建的raid1
[root@localhost packages]# MegaCli64 -LDInfo -lAll -aAll
Adapter 0 -- Virtual Drive Information:
Virtual Drive: 0 (Target Id: 0)
Name :
RAID Level : Primary-1, Secondary-0, RAID Level Qualifier-0
Size : 1.818 TB
Sector Size : 512
Is VD emulated : No
Mirror Data : 1.818 TB
State : Optimal
Strip Size : 256 KB
Number Of Drives : 2
Span Depth : 1
Default Cache Policy: WriteBack, ReadAheadNone, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteThrough, ReadAheadNone, Direct, No Write Cache if Bad BBU
Default Access Policy: Read/Write
Current Access Policy: Read/Write
Disk Cache Policy : Disk's Default
Encryption Type : None
PI type: No PI
Is VD Cached: No
Exit Code: 0x00
创建raid5命令
/usr/local/bin/MegaCli64 -CfgLdAdd -r5 [8:0,8:1,8:2] WB NORA -a0
Adapter 0: Created VD 0
Adapter 0: Configured the Adapter!!
Exit Code: 0x00
查询创建的raid5
[root@localhost packages]# MegaCli64 -LDInfo -LAll -aAll
Adapter 0 -- Virtual Drive Information:
Virtual Drive: 0 (Target Id: 0)
Name :
RAID Level : Primary-5, Secondary-0, RAID Level Qualifier-3
Size : 3.637 TB
Sector Size : 512
Is VD emulated : No
Parity Size : 1.818 TB
State : Optimal
Strip Size : 256 KB
Number Of Drives : 3
Span Depth : 1
Default Cache Policy: WriteBack, ReadAheadNone, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteThrough, ReadAheadNone, Direct, No Write Cache if Bad BBU
Default Access Policy: Read/Write
Current Access Policy: Read/Write
Disk Cache Policy : Disk's Default
Encryption Type : None
PI type: No PI
Is VD Cached: No
Exit Code: 0x00
创建RAID10的命令
/usr/local/bin/MegaCli64 -CfgSpanAdd -r10 -Array0[8:0,8:1] -Array1[8:2,8:5] WB NORA -a0
查询创建的raid10
/usr/local/bin/MegaCli64 -LDInfo -LAll -aAll
Adapter 0 -- Virtual Drive Information:
Virtual Drive: 0 (Target Id: 0)
Name :
RAID Level : Primary-1, Secondary-0, RAID Level Qualifier-0
Size : 930.5 GB
Sector Size : 512
Is VD emulated : Yes
Mirror Data : 930.5 GB
State : Optimal
Strip Size : 256 KB
Number Of Drives per span:2
Span Depth : 2
Default Cache Policy: WriteThrough, ReadAheadNone, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteThrough, ReadAheadNone, Direct, No Write Cache if Bad BBU
Default Access Policy: Read/Write
Current Access Policy: Read/Write
Disk Cache Policy : Disk's Default
Encryption Type : None
PI type: No PI
Is VD Cached: No
验证
通过qdatamgr来获取,可以sleep几秒钟,然后校验输出信息,如果有路径就是可以的。
RAID Level对应关系
RAID Level : Primary-1, Secondary-0, RAID Level Qualifier-0
RAID 1
RAID Level : Primary-0, Secondary-0, RAID Level Qualifier-0 RAID 0
RAID Level : Primary-5, Secondary-0, RAID Level Qualifier-3 RAID 5
RAID Level : Primary-1, Secondary-3, RAID Level Qualifier-0 RAID 10
缓存策略解释:
写缓存:WT (Write through )、WB (Write back)
读缓存:NORA (No read ahead)、 RA (Read ahead)、 ADRA (Adaptive read ahead)
I/O: Direct
特殊状况
firmware status:状态是JBOD,如果想要配置是unconfigure(good) [root@localhost MegaCli]# MegaCli64 PDMakeGood -PhysDrv[8:5] -Force -a0