MegaCli使用方法

JBOD

​ 一天小明做了个系统,要装ceph,也许是Raid卡不支持JBOD,就只能做Raid0咯,表面看着好像没区别,大佬还会跟你讲做Raid0有毛线用,我在想也许他还不知道Ceph是替代什么的吧,像我这种小白,连JBOD是什么都不知道,(之前Cisco UCS 做Raid的时候看到过这个选项)。

mark

​JBOD是存储领域中一类重要的存储设备,Low点的说法叫Raid卡直通,Just a Bunch Of Disks是JBOD的全名,奥,JBOD真的是只是一堆盘的缩写,23333。

​如果已经安装完系统,并且没有配置JBOD 而是做了RAID 插入新磁盘, 系统是看不到的,但是有些业务是不能重启的 ,但是你还想加盘,这就需要Megacli来搞事情了。

安装MegaCli

下载并安装

wegt https://docs.broadcom.com/docs-and-downloads/raid-controllers/raid-controllers-common-files/8-07-10_MegaCLI_Linux.zip
unzip 8-07-10_MegaCLI_Linux.zip 
yum localinstall 8.07.10_MegaCLI_Linux/Linux MegaCLI 8.07.10/MegaCli-8.07.10-1.noarch.rpm

目录根据情况修改

我们看下都生成了什么!!

rpm -ql  rpm -ql MegaCli
/opt/MegaRAID/MegaCli/MegaCli
/opt/MegaRAID/MegaCli/MegaCli64
/opt/MegaRAID/MegaCli/libstorelibir-2.so.14.07-0

/opt/MegaRAID/MegaCli/MegaCli64这个文件就是我们要用到的,

Megacli概念

适配器,物理驱动器和虚拟驱动器

在我们通过megacli命令之前,我们需要遵循megacli概念。

适配器 - 我们要使用的物理控制器,由id(通常为0)表示。

机柜 - 物理机箱所附的物理驱动器,以id为代表,例如254,252等。

物理驱动器 - 附加到控制器的物理硬盘,由id,0,1,2,3等代表

虚拟驱动器 - 这些驱动器包含物理驱动器,并等同于由id,0,1,2,3等代表的RAID设备。

例如,如果我们的RAID 0超过3个物理驱动器,我们得到:

物理驱动器ID:0,1,2

虚拟驱动器ID:0

虚拟驱动器包含物理驱动器0,1和2,并包括突袭设备的设置,如RAID级别,条带大小等。

我们可以通过一个物理驱动器看到具有RAID 0的虚拟驱动器中的配置,我们有这种设置,因为物理驱动器连接到RAID控制器,并且为了将设备表示给系统,我们必须将其设置为兆位。

默认情况下,我们将在RAID 0中看到虚拟驱动器的所有物理设备。

获取RAID控制器信息

使用lspci确保您的服务器已连接到RAID控制器。

 lspci | grep -i raid

我的输出

03:00.0 RAID bus controller: LSI Logic / Symbios Logic MegaRAID SAS 2208 [Thunderbolt] (rev 05)

这表明我这存在MegaRaid controller ;我可以愉快的使用MegaCli搞事!

获取RAID适配器的信息

 /opt/MegaRAID/MegaCli/MegaCli64  -AdpGetPciInfo -aAll

带上路径执行

我的输出

PCI information for Controller 0
--------------------------------
Bus Number      : 23c0
Device Number   : 0
Function Number : a0


Exit Code: 0x00

这里看到适配器信息,适配器id为0。

获取硬盘背板信息

/opt/MegaRAID/MegaCli/MegaCli64 -EncInfo -a0

我的输出

                                     
    Number of enclosures on adapter 0 -- 1

    Enclosure 0:
    Device ID                     : 252
    Number of Slots               : 8
    Number of Power Supplies      : 0
    Number of Fans                : 0
    Number of Temperature Sensors : 0
    Number of Alarms              : 0
    Number of SIM Modules         : 1
    Number of Physical Drives     : 8
    Status                        : Normal
    Position                      : 1
    Connector Name                : Unavailable
    Enclosure type                : SGPIO
    FRU Part Number               : N/A
    Enclosure Serial Number       : N/A 
    ESM Serial Number             : N/A 
    Enclosure Zoning Mode         : N/A 
    Partner Device Id             : Unavailable

    Inquiry data                  :
        Vendor Identification     : LSI     
        Product Identification    : SGPIO           
        Product Revision Level    : N/A 
        Vendor Specific           :                     


Exit Code: 0x00

记录下

Device ID 252
Number of Slots( 可以连接到这个背板的最大物理驱动器 8

获取物理驱动器的信息

/opt/MegaRAID/MegaCli/MegaCli64 -LdPdInfo -a0

因为我的盘比较多。这里输出就列出一个

PD: 0 Information
Enclosure Device ID: 252
Slot Number: 1
Drive's position: DiskGroup: 1, Span: 0, Arm: 0
Enclosure position: N/A
Device Id: 3
WWN: 500003963820BFE1
Sequence Number: 2
Media Error Count: 0
Other Error Count: 0
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0
PD Type: SAS

Raw Size: 279.396 GB [0x22ecb25c Sectors]
Non Coerced Size: 278.896 GB [0x22dcb25c Sectors]
Coerced Size: 278.875 GB [0x22dc0000 Sectors]
Sector Size:  512
Logical Sector Size:  512
Physical Sector Size:  512
Firmware state: Online, Spun Up
Commissioned Spare : No
Emergency Spare : No
Device Firmware Level: 1004
Shield Counter: 0
Successful diagnostics completion on :  N/A
SAS Address(0): 0x500003963820bfe2
SAS Address(1): 0x0
Connected Port Number: 1(path0) 
Inquiry Data: TOSHIBA AL13SEB300      100445O0A05KFWC9        
FDE Capable: Not Capable
FDE Enable: Disable
Secured: Unsecured
Locked: Unlocked
Needs EKM Attention: No
Foreign State: None 
Device Speed: 6.0Gb/s 
Link Speed: 6.0Gb/s 
Media Type: Hard Disk Device
Drive:  Not Certified
Drive Temperature :24C (75.20 F)
PI Eligibility:  No 
Drive is formatted for PI information:  No
PI: No PI
Port-0 :
Port status: Active
Port's Linkspeed: 6.0Gb/s 
Port-1 :
Port status: Active
Port's Linkspeed: 6.0Gb/s 
Drive has flagged a S.M.A.R.T alert : No



Virtual Drive: 2 (Target Id: 2)
Name                :
RAID Level          : Primary-0, Secondary-0, RAID Level Qualifier-0
Size                : 278.875 GB
Sector Size         : 512
Is VD emulated      : No
Parity Size         : 0
State               : Optimal
Strip Size          : 256 KB
Number Of Drives    : 1
Span Depth          : 1
Default Cache Policy: WriteThrough, ReadAhead, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteThrough, ReadAhead, 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
Number of Spans: 1
Span: 0 - Number of PDs: 1

PD: 0 Information
Enclosure Device ID: 252
Slot Number: 3
Drive's position: DiskGroup: 2, Span: 0, Arm: 0
Enclosure position: N/A
Device Id: 14
WWN: 500003963820C81D
Sequence Number: 2
Media Error Count: 0
Other Error Count: 0
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0
PD Type: SAS

Raw Size: 279.396 GB [0x22ecb25c Sectors]
Non Coerced Size: 278.896 GB [0x22dcb25c Sectors]
Coerced Size: 278.875 GB [0x22dc0000 Sectors]
Sector Size:  512
Logical Sector Size:  512
Physical Sector Size:  512
Firmware state: Online, Spun Up
Commissioned Spare : No
Emergency Spare : No
Device Firmware Level: 1004
Shield Counter: 0
Successful diagnostics completion on :  N/A
SAS Address(0): 0x500003963820c81e
SAS Address(1): 0x0
Connected Port Number: 3(path0) 
Inquiry Data: TOSHIBA AL13SEB300      100445O0A08RFWC9        
FDE Capable: Not Capable
FDE Enable: Disable
Secured: Unsecured
Locked: Unlocked
Needs EKM Attention: No
Foreign State: None
Device Speed: 6.0Gb/s
Link Speed: 6.0Gb/s
Media Type: Hard Disk Device
Drive:  Not Certified
Drive Temperature :26C (78.80 F)
PI Eligibility:  No
Drive is formatted for PI information:  No
PI: No PI
Port-0 :
Port status: Active
Port's Linkspeed: 6.0Gb/s
Port-1 :
Port status: Active
Port's Linkspeed: 6.0Gb/s
Drive has flagged a S.M.A.R.T alert : No



Virtual Drive: 3 (Target Id: 3)
Name                :
RAID Level          : Primary-0, Secondary-0, RAID Level Qualifier-0
Size                : 278.875 GB
Sector Size         : 512
Is VD emulated      : No
Parity Size         : 0
State               : Optimal
Strip Size          : 256 KB
Number Of Drives    : 1
Span Depth          : 1
Default Cache Policy: WriteThrough, ReadAhead, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteThrough, ReadAhead, 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
Number of Spans: 1
Span: 0 - Number of PDs: 1

PD: 0 Information
Enclosure Device ID: 252
Slot Number: 2
Drive's position: DiskGroup: 3, Span: 0, Arm: 0
Enclosure position: N/A
Device Id: 16
WWN: 500003963820C225
Sequence Number: 2
Media Error Count: 0
Other Error Count: 0
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0
PD Type: SAS

Raw Size: 279.396 GB [0x22ecb25c Sectors]
Non Coerced Size: 278.896 GB [0x22dcb25c Sectors]
Coerced Size: 278.875 GB [0x22dc0000 Sectors]
Sector Size:  512
Logical Sector Size:  512
Physical Sector Size:  512
Firmware state: Online, Spun Up
Commissioned Spare : No
Emergency Spare : No
Device Firmware Level: 1004
Shield Counter: 0
Successful diagnostics completion on :  N/A
SAS Address(0): 0x500003963820c226
SAS Address(1): 0x0
Connected Port Number: 2(path0) 
Inquiry Data: TOSHIBA AL13SEB300      100445O0A06AFWC9        
FDE Capable: Not Capable
FDE Enable: Disable
Secured: Unsecured
Locked: Unlocked
Needs EKM Attention: No
Foreign State: None 
Device Speed: 6.0Gb/s 
Link Speed: 6.0Gb/s 
Media Type: Hard Disk Device
Drive:  Not Certified
Drive Temperature :26C (78.80 F)
PI Eligibility:  No 
Drive is formatted for PI information:  No
PI: No PI
Port-0 :
Port status: Active
Port's Linkspeed: 6.0Gb/s
Port-1 :
Port status: Active
Port's Linkspeed: 6.0Gb/s 
Drive has flagged a S.M.A.R.T alert : No



Virtual Drive: 4 (Target Id: 4)
Name                :
RAID Level          : Primary-0, Secondary-0, RAID Level Qualifier-0
Size                : 837.843 GB
Sector Size         : 512
Is VD emulated      : No
Parity Size         : 0
State               : Optimal
Strip Size          : 256 KB
Number Of Drives    : 1
Span Depth          : 1
Default Cache Policy: WriteThrough, ReadAhead, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteThrough, ReadAhead, 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
Number of Spans: 1
Span: 0 - Number of PDs: 1

PD: 0 Information
Enclosure Device ID: 252
Slot Number: 4
Drive's position: DiskGroup: 4, Span: 0, Arm: 0
Enclosure position: N/A
Device Id: 15
WWN: 5000C500958D1EB8
Sequence Number: 2
Media Error Count: 0
Other Error Count: 0
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0
PD Type: SAS

Raw Size: 838.362 GB [0x68cb9e30 Sectors]
Non Coerced Size: 837.862 GB [0x68bb9e30 Sectors]
Coerced Size: 837.843 GB [0x68bb0000 Sectors]
Sector Size:  512
Logical Sector Size:  512
Physical Sector Size:  512
Firmware state: Online, Spun Up
Commissioned Spare : No
Emergency Spare : No
Device Firmware Level: L56Q
Shield Counter: 0
Successful diagnostics completion on :  N/A
SAS Address(0): 0x5000c500958d1eb9
SAS Address(1): 0x0
Connected Port Number: 4(path0) 
Inquiry Data: LENOVO-XST900MM0006     L56QS0N5129S0521B5C9    
FDE Capable: Not Capable
FDE Enable: Disable
Secured: Unsecured
Locked: Unlocked
Needs EKM Attention: No
Foreign State: None 
Device Speed: 6.0Gb/s 
Link Speed: 6.0Gb/s 
Media Type: Hard Disk Device
Drive:  Not Certified
Drive Temperature :28C (82.40 F)
PI Eligibility:  Yes 
Number of bytes of user data in LBA: 512 
Drive is formatted for PI information:  Yes 
PI: PI with type 2
Port-0 :
Port status: Active
Port's Linkspeed: 6.0Gb/s
Port-1 :
Port status: Active
Port's Linkspeed: 6.0Gb/s 
Drive has flagged a S.M.A.R.T alert : No



Virtual Drive: 5 (Target Id: 5)
Name                :
RAID Level          : Primary-0, Secondary-0, RAID Level Qualifier-0
Size                : 278.875 GB
Sector Size         : 512
Is VD emulated      : No
Parity Size         : 0
State               : Optimal
Strip Size          : 256 KB
Number Of Drives    : 1
Span Depth          : 1
Default Cache Policy: WriteBack, ReadAdaptive, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteThrough, ReadAdaptive, 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
Number of Spans: 1
Span: 0 - Number of PDs: 1

PD: 0 Information
Enclosure Device ID: 252
Slot Number: 5
Drive's position: DiskGroup: 5, Span: 0, Arm: 0
Enclosure position: N/A
Device Id: 18
WWN: 500003963820C429
Sequence Number: 2
Media Error Count: 0
Other Error Count: 0
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0
PD Type: SAS

Raw Size: 279.396 GB [0x22ecb25c Sectors]
Non Coerced Size: 278.896 GB [0x22dcb25c Sectors]
Coerced Size: 278.875 GB [0x22dc0000 Sectors]
Sector Size:  512
Logical Sector Size:  512
Physical Sector Size:  512
Firmware state: Online, Spun Up
Commissioned Spare : No
Emergency Spare : No
Device Firmware Level: 1004
Shield Counter: 0
Successful diagnostics completion on :  N/A
SAS Address(0): 0x500003963820c42a
SAS Address(1): 0x0
Connected Port Number: 5(path0) 
Inquiry Data: TOSHIBA AL13SEB300      100445O0A06TFWC9        
FDE Capable: Not Capable
FDE Enable: Disable
Secured: Unsecured
Locked: Unlocked
Needs EKM Attention: No
Foreign State: None 
Device Speed: 6.0Gb/s 
Link Speed: 6.0Gb/s 
Media Type: Hard Disk Device
Drive:  Not Certified
Drive Temperature :24C (75.20 F)
PI Eligibility:  No 
Drive is formatted for PI information:  No
PI: No PI
Port-0 :
Port status: Active
Port's Linkspeed: 6.0Gb/s 
Port-1 :
Port status: Active
Port's Linkspeed: 6.0Gb/s 
Drive has flagged a S.M.A.R.T alert : No



Virtual Drive: 6 (Target Id: 6)
Name                :
RAID Level          : Primary-0, Secondary-0, RAID Level Qualifier-0
Size                : 278.875 GB
Sector Size         : 512
Is VD emulated      : No
Parity Size         : 0
State               : Optimal
Strip Size          : 256 KB
Number Of Drives    : 1
Span Depth          : 1
Default Cache Policy: WriteBack, ReadAdaptive, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteThrough, ReadAdaptive, 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
Number of Spans: 1
Span: 0 - Number of PDs: 1

PD: 0 Information
Enclosure Device ID: 252
Slot Number: 6
Drive's position: DiskGroup: 6, Span: 0, Arm: 0
Enclosure position: N/A
Device Id: 19
WWN: 500003963820BFF1
Sequence Number: 2
Media Error Count: 0
Other Error Count: 0
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0
PD Type: SAS

Raw Size: 279.396 GB [0x22ecb25c Sectors]
Non Coerced Size: 278.896 GB [0x22dcb25c Sectors]
Coerced Size: 278.875 GB [0x22dc0000 Sectors]
Sector Size:  512
Logical Sector Size:  512
Physical Sector Size:  512
Firmware state: Online, Spun Up
Commissioned Spare : No
Emergency Spare : No
Device Firmware Level: 1004
Shield Counter: 0
Successful diagnostics completion on :  N/A
SAS Address(0): 0x500003963820bff2
SAS Address(1): 0x0
Connected Port Number: 6(path0) 
Inquiry Data: TOSHIBA AL13SEB300      100445O0A05MFWC9        
FDE Capable: Not Capable
FDE Enable: Disable
Secured: Unsecured
Locked: Unlocked
Needs EKM Attention: No
Foreign State: None 
Device Speed: 6.0Gb/s 
Link Speed: 6.0Gb/s 
Media Type: Hard Disk Device
Drive:  Not Certified
Drive Temperature :24C (75.20 F)
PI Eligibility:  No 
Drive is formatted for PI information:  No
PI: No PI
Port-0 :
Port status: Active
Port's Linkspeed: 6.0Gb/s 
Port-1 :
Port status: Active
Port's Linkspeed: 6.0Gb/s 
Drive has flagged a S.M.A.R.T alert : No



Virtual Drive: 7 (Target Id: 7)
Name                :
RAID Level          : Primary-0, Secondary-0, RAID Level Qualifier-0
Size                : 278.875 GB
Sector Size         : 512
Is VD emulated      : No
Parity Size         : 0
State               : Optimal
Strip Size          : 256 KB
Number Of Drives    : 1
Span Depth          : 1
Default Cache Policy: WriteBack, ReadAdaptive, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteThrough, ReadAdaptive, 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
Number of Spans: 1
Span: 0 - Number of PDs: 1

PD: 0 Information
Enclosure Device ID: 252
Slot Number: 7
Drive's position: DiskGroup: 7, Span: 0, Arm: 0
Enclosure position: N/A
Device Id: 20
WWN: 500003963820C2D1
Sequence Number: 2
Media Error Count: 0
Other Error Count: 0
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0
PD Type: SAS

Raw Size: 279.396 GB [0x22ecb25c Sectors]
Non Coerced Size: 278.896 GB [0x22dcb25c Sectors]
Coerced Size: 278.875 GB [0x22dc0000 Sectors]
Sector Size:  512
Logical Sector Size:  512
Physical Sector Size:  512
Firmware state: Online, Spun Up
Commissioned Spare : No
Emergency Spare : No
Device Firmware Level: 1004
Shield Counter: 0
Successful diagnostics completion on :  N/A
SAS Address(0): 0x500003963820c2d2
SAS Address(1): 0x0
Connected Port Number: 7(path0) 
Inquiry Data: TOSHIBA AL13SEB300      100445O0A06HFWC9        
FDE Capable: Not Capable
FDE Enable: Disable
Secured: Unsecured
Locked: Unlocked
Needs EKM Attention: No
Foreign State: None 
Device Speed: 6.0Gb/s 
Link Speed: 6.0Gb/s 
Media Type: Hard Disk Device
Drive:  Not Certified
Drive Temperature :24C (75.20 F)
PI Eligibility:  No 
Drive is formatted for PI information:  No
PI: No PI
Port-0 :
Port status: Active
Port's Linkspeed: 6.0Gb/s 
Port-1 :
Port status: Active
Port's Linkspeed: 6.0Gb/s 
Drive has flagged a S.M.A.R.T alert : No




Exit Code: 0x00

Slot Number是物理驱动器连接的插槽号,也就是对应物理驱动器id

获取Virtual drives信息

/opt/MegaRAID/MegaCli/MegaCli64  -LDInfo -Lall -a0

我的输出

                                     

Adapter 0 -- Virtual Drive Information:
Virtual Drive: 0 (Target Id: 0)
Name                :
RAID Level          : Primary-0, Secondary-0, RAID Level Qualifier-0
Size                : 185.781 GB
Sector Size         : 512
Is VD emulated      : Yes
Parity Size         : 0
State               : Optimal
Strip Size          : 256 KB
Number Of Drives    : 1
Span Depth          : 1
Default Cache Policy: WriteThrough, ReadAhead, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteThrough, ReadAhead, Direct, No Write Cache if Bad BBU
Default Access Policy: Read/Write
Current Access Policy: Read/Write
Disk Cache Policy   : Enabled
Encryption Type     : None
PI type: No PI

Is VD Cached: No


Virtual Drive: 1 (Target Id: 1)
Name                :
RAID Level          : Primary-0, Secondary-0, RAID Level Qualifier-0
Size                : 278.875 GB
Sector Size         : 512
Is VD emulated      : No
Parity Size         : 0
State               : Optimal
Strip Size          : 256 KB
Number Of Drives    : 1
Span Depth          : 1
Default Cache Policy: WriteThrough, ReadAhead, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteThrough, ReadAhead, 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


Virtual Drive: 2 (Target Id: 2)
Name                :
RAID Level          : Primary-0, Secondary-0, RAID Level Qualifier-0
Size                : 278.875 GB
Sector Size         : 512
Is VD emulated      : No
Parity Size         : 0
State               : Optimal
Strip Size          : 256 KB
Number Of Drives    : 1
Span Depth          : 1
Default Cache Policy: WriteThrough, ReadAhead, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteThrough, ReadAhead, 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


Virtual Drive: 3 (Target Id: 3)
Name                :
RAID Level          : Primary-0, Secondary-0, RAID Level Qualifier-0
Size                : 278.875 GB
Sector Size         : 512
Is VD emulated      : No
Parity Size         : 0
State               : Optimal
Strip Size          : 256 KB
Number Of Drives    : 1
Span Depth          : 1
Default Cache Policy: WriteThrough, ReadAhead, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteThrough, ReadAhead, 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


Virtual Drive: 4 (Target Id: 4)
Name                :
RAID Level          : Primary-0, Secondary-0, RAID Level Qualifier-0
Size                : 837.843 GB
Sector Size         : 512
Is VD emulated      : No
Parity Size         : 0
State               : Optimal
Strip Size          : 256 KB
Number Of Drives    : 1
Span Depth          : 1
Default Cache Policy: WriteThrough, ReadAhead, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteThrough, ReadAhead, 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


Virtual Drive: 5 (Target Id: 5)
Name                :
RAID Level          : Primary-0, Secondary-0, RAID Level Qualifier-0
Size                : 278.875 GB
Sector Size         : 512
Is VD emulated      : No
Parity Size         : 0
State               : Optimal
Strip Size          : 256 KB
Number Of Drives    : 1
Span Depth          : 1
Default Cache Policy: WriteBack, ReadAdaptive, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteThrough, ReadAdaptive, 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


Virtual Drive: 6 (Target Id: 6)
Name                :
RAID Level          : Primary-0, Secondary-0, RAID Level Qualifier-0
Size                : 278.875 GB
Sector Size         : 512
Is VD emulated      : No
Parity Size         : 0
State               : Optimal
Strip Size          : 256 KB
Number Of Drives    : 1
Span Depth          : 1
Default Cache Policy: WriteBack, ReadAdaptive, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteThrough, ReadAdaptive, 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


Virtual Drive: 7 (Target Id: 7)
Name                :
RAID Level          : Primary-0, Secondary-0, RAID Level Qualifier-0
Size                : 278.875 GB
Sector Size         : 512
Is VD emulated      : No
Parity Size         : 0
State               : Optimal
Strip Size          : 256 KB
Number Of Drives    : 1
Span Depth          : 1
Default Cache Policy: WriteBack, ReadAdaptive, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteThrough, ReadAdaptive, 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
Target ID 表RAID创建过程中 创建的虚拟驱动器
Size RAID设备的大小,这个大小是实际可分配的大小

获取Virtual drives内的物理驱动器信息

这就有点难了, 其实没什么卵用,记下来留着以后copy

/opt/MegaRAID/MegaCli/MegaCli64  -LdPdInfo -a0 | grep -E "Virtual Drive:|Slot Number:" | xargs | sed -r 's/(Slot Number:)(s[0-9]+)/2,/g' | sed 's/(Target Id: .)/Physical Drives ids:/g' | sed 's/Virtual Drive:/
Virtual Drive:/g'

我的输出

Virtual Drive: 0 Physical Drives ids:  0, 
Virtual Drive: 1 Physical Drives ids:  1, 
Virtual Drive: 2 Physical Drives ids:  3, 
Virtual Drive: 3 Physical Drives ids:  2, 
Virtual Drive: 4 Physical Drives ids:  4, 
Virtual Drive: 5 Physical Drives ids:  5, 
Virtual Drive: 6 Physical Drives ids:  6, 
Virtual Drive: 7 Physical Drives ids:  7,

或者使用这个工具 "megasasctl"

创建RAID设备(Virtual drives)

前面主要是收集信息,有信息,才可以准确的创建

比如我们来一个

Adpater id: 0
Enclosure id: 252
Physical Drive ids: 3
Raid Level: 0

命令参数

/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -rX[enclosure_id:physical_id,enclosure_id:physical_id] -aN

X 是 RAID级别

N 是 adapter ID

举个栗子

/opt/MegaRAID/MegaCli/MegaCli64  -CfgLdAdd -r0[252:3,252:4] -a0

设备编号为3和4的磁盘,创建RAID0

来个RAID10

/opt/MegaRAID/MegaCli/MegaCli64 -CfgSpanAdd -r10 -Array0 [252:2,252:3] -Array1 [252:4,252:5] -a0

删除RAID设备

删Virtual drives2

/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdDel -L2 -a0

常用选项

相关命令及其解析: 
查看机器型号    # dmidecode | grep "Product" 
查看厂商    # dmidecode| grep  "Manufacturer" 
查看序列号    # dmidecode | grep  "Serial Number" 
查看CPU信息    # dmidecode | grep  "CPU" 
查看CPU个数    # dmidecode | grep  "Socket Designation: CPU" |wc –l 
查看出厂日期    # dmidecode | grep "Date" 
查看充电状态    # MegaCli -AdpBbuCmd -GetBbuStatus -aALL |grep "Charger Status" 
显示BBU状态信息    # MegaCli -AdpBbuCmd -GetBbuStatus –aALL 
显示BBU容量信息    # MegaCli -AdpBbuCmd -GetBbuCapacityInfo –aALL 
显示BBU设计参数    # MegaCli -AdpBbuCmd -GetBbuDesignInfo –aALL 
显示当前BBU属性    # MegaCli -AdpBbuCmd -GetBbuProperties –aALL 
查看充电进度百分比    # MegaCli -AdpBbuCmd -GetBbuStatus -aALL |grep "Relative State of Charge" 
查询Raid阵列数    # MegaCli -cfgdsply -aALL |grep "Number of DISK GROUPS:" 
显示Raid卡型号,Raid设置,Disk相关信息      # MegaCli -cfgdsply –aALL 
显示所有物理信息    # MegaCli -PDList -aALL 
显示所有逻辑磁盘组信息    # MegaCli -LDInfo -LALL –aAll 
查看物理磁盘重建进度(重要)    # MegaCli -PDRbld -ShowProg -PhysDrv [1:5] -a0 
查看适配器个数    #MegaCli –adpCount 
查看适配器时间    #MegaCli -AdpGetTime –aALL 
显示所有适配器信息    #MegaCli -AdpAllInfo –aAll 
查看Cache 策略设置    # MegaCli -cfgdsply -aALL |grep Polic

硬盘方面:

1、查看所有物理磁盘信息 
MegaCli -PDList -aALL


2、查看磁盘缓存策略 
MegaCli -LDGetProp -Cache -L0 -a0
or 
MegaCli -LDGetProp -Cache -L1 -a0
or 
MegaCli -LDGetProp -Cache -LALL -a0
or 
MegaCli -LDGetProp -Cache -LALL -aALL
or 
MegaCli -LDGetProp -DskCache -LALL -aALL

3、设置磁盘缓存策略 
缓存策略解释: 
WT    (Write through 
WB    (Write back) 
NORA  (No read ahead) 
RA    (Read ahead) 
ADRA  (Adaptive read ahead) 
Cached 
Direct 
例子: 
MegaCli -LDSetProp WT|WB|NORA|RA|ADRA -L0 -a0 
or 
MegaCli -LDSetProp -Cached|-Direct -L0 -a0 
or 
enable / disable disk cache 
MegaCli -LDSetProp -EnDskCache|-DisDskCache -L0 -a0 
4、创建/删除 阵列 
    4.1 创建一个 raid5 阵列,由物理盘 2,3,4 构成,该阵列的热备盘是物理盘 5 
MegaCli -CfgLdAdd -r5 [1:2,1:3,1:4] WB Direct -Hsp[1:5] –a0 
    4.2 创建阵列,不指定热备 
MegaCli -CfgLdAdd -r5 [1:2,1:3,1:4] WB Direct –a0 
    4.3 删除阵列 
MegaCli -CfgLdDel -L1 –a0 
    4.4 在线添加磁盘 
MegaCli -LDRecon -Start -r5 -Add -PhysDrv[1:4] -L1 -a0 
意思是,重建逻辑磁盘组1,raid级别是5,添加物理磁盘号:1:4。重建完后,新添加的物理磁盘会自动处于重建(同步)状态,这个 时候 fdisk -l是看不到阵列的空间变大的,只有在系统重启后才能看见。 
5、查看阵列初始化信息 
    5.1 阵列创建完后,会有一个初始化同步块的过程,可以看看其进度。 
MegaCli -LDInit -ShowProg -LALL -aALL 
或者以动态可视化文字界面显示 
MegaCli -LDInit -ProgDsply -LALL –aALL 
    5.2 查看阵列后台初始化进度 
MegaCli -LDBI -ShowProg -LALL -aALL 
或者以动态可视化文字界面显示 
MegaCli -LDBI -ProgDsply -LALL -aALL 
6、创建全局热备 
指定第 5 块盘作为全局热备 
MegaCli -PDHSP -Set [-EnclAffinity] [-nonRevertible] -PhysDrv[1:5] -a0 
也可以指定为某个阵列的专用热备 
MegaCli -PDHSP -Set [-Dedicated [-Array1]] [-EnclAffinity] [-nonRevertible] -PhysDrv[1:5] -a0 
7、删除全局热备 
MegaCli -PDHSP -Rmv -PhysDrv[1:5] -a0 
8、将某块物理盘下线/上线 
MegaCli -PDOffline -PhysDrv [1:4] -a0 
MegaCli -PDOnline -PhysDrv [1:4] -a0 
9、查看物理磁盘重建进度 
MegaCli -PDRbld -ShowProg -PhysDrv [1:5] -a0
原文地址:https://www.cnblogs.com/xth0331/p/9655593.html