介绍
MegaCli是一款管理维护硬件RAID软件,可以通过它来了解当前raid卡的所有信息,包括 raid卡的型号,raid的阵列类型,raid 上各磁盘状态,等等。通常,我们对硬盘当前的状态不太好确定,一般通过机房人员巡检来完成,有没有通过软件的方式来检查确定这个问题呢。MegaCli就可以做到,一般通过 MegaCli 的Media Error Count: 0 Other Error Count: 0 这两个数值来确定阵列中磁盘是否有问题;Medai Error Count 表示磁盘可能错误,可能是磁盘有坏道,这个值不为0值得注意,数值越大,危险系数越高,Other Error Count 表示磁盘可能存在松动,可能需要重新再插入。
下载MegCli,目前针对公司DB数据库是IBM的服务器,直接从IBM官方下载,如果
其它服务器的,使用各官方下载或者 LSI网站上进行相关下载。一般来说,是通用的。这个包适用32 /64位操作系统平台
Dell服务器常用管理命令总结
准备
新版本的 MegaCli-1.01.24-0.i386.rpm 会把程序安装在/opt下,可以自定义安装目录,例如:
rpm --relocate /opt/=/usr/sbin/ -i MegaCli-1.01.24-0.i386.rpm
即把安装目录 /opt 替换成 /usr/sbin。
下载地址:/downloads/Public/MegaRAID%20Common%20Files/8.02.16_MegaCLI.zip ;
(linux文件夹下有个MegaCli文件里面有I386 RPM)
ftp://download2./ecc/sar/CMA/XSA/ibm_utl_sraidmr_megacli-8.00.48_linux_32-64.zip
raid卡的盘有4种基本状态
Failed 基本无救,联系dell保修。Online 正常装填。Foreign 逻辑有错误,这个盘未识别,解决方法:从硬盘重新导入raid卡的逻辑数据。Unconfigd 第一种情况就是这个盘没有配置在raid中,第二种情况就是逻辑有错误,这个盘未识别。解决方法:从硬盘重新导入raid卡的逻辑数据。第一种情况下,重新从硬盘导入逻辑数据也没办法,第二种情况下是可以的。
注意 :
spans值 1,2,3,4做raid0,八块盘做raid1形成1、2、3、4Drive's position: DiskGroup: 0, Span: 0, Arm: 1如果盘坏在不同的raid1上,就可以,如果坏在相同的raid1上数据就完了,所以最大可以坏4块盘。PD值 0、1、2、3、4、5、6、7
RAID级别和对应硬盘数量
RAID0 至少2块盘RAID1 至少2块盘(空间利用率 :1/2)RAID5 至少需要2块盘(空间利用率 :1/2) RAID10 至少需要4块盘 (空间利用率 :1/2) RAID01 至少需要4块盘(空间利用率 :1/2) RAID50 至少需要6块盘 空间利用率 :(n-2)/n
Raid 0:一块硬盘或者以上就可做raid0
Raid 1:至少2快硬盘可做raid1
RAID 4 3块盘
Raid5 : 至少需要3块硬盘raid5
Raid6 : 至少需要4块硬盘做raid6
Raid10 : 至少需要4快硬盘。raid10是2快硬盘组成raid1,2组raid1组成raid0,所以必须需要4块硬盘。
注意 : 4盘的raid5,只允许单盘故障,
先做条带化,后做镜像
0表示条带,1表示镜像
硬RAID与软RAID的区别:
硬RAID:通过用硬件来实现RAID功能的就是硬RAID,比如:各种RAID卡,还有主板集成能够做的RAID都是硬RAID。软RAID:通过用操作系统来完成RAID功能的就是软RAID,比如:在Linux操作系统下,用3块硬盘做的RAID5。
RAID识别方式: IDE、SATA、USB、SCSI、SAS
主流的RAID级别有,0、1、5、10等。数字越高,其安全等级越高,防止数据丢失能力越强
查看机器型号 # 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检测raid是否有降级:MegaCli -AdpAllInfo -aALL -NoLog | grep "Degraded"Degraded : 0 检测是否有坏盘MegaCli -AdpAllInfo -aALL -NoLog | grep "Failed Disks" Failed Disks : 0
命令使用:
#/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -aALL 查raid级别#/opt/MegaRAID/MegaCli/MegaCli64 -AdpAllInfo -aALL 查raid卡信息#/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL查看硬盘信息#/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -aAll 查看电池信息#/opt/MegaRAID/MegaCli/MegaCli64 -FwTermLog -Dsply -aALL 查看raid卡日志#/opt/MegaRAID/MegaCli/MegaCli64 -adpCount【显示适配器个数】#/opt/MegaRAID/MegaCli/MegaCli64 -AdpGetTime –aALL 【显示适配器时间】#/opt/MegaRAID/MegaCli/MegaCli64 -AdpAllInfo -aAll 【显示所有适配器信息】#/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -LALL -aAll 【显示所有逻辑磁盘组信息】#/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aAll 【显示所有的物理信息】#/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuStatus -aALL |grep ‘Charger Status’ 【查看充电状态】#/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuStatus -aALL 【显示BBU状态信息】#/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuCapacityInfo -aALL 【显示BBU容量信息】#/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuDesignInfo -aALL【显示BBU设计参数】#/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuProperties -aALL【显示当前BBU属性】#/opt/MegaRAID/MegaCli/MegaCli64 -cfgdsply -aALL 【显示Raid卡型号,Raid设置,Disk相关信息】
磁带状态的变化,从拔盘,到插盘的过程中。
Device |Normal|Damage|Rebuild|NormalVirtual Drive |Optimal|Degraded|Degraded|OptimalPhysical Drive |Online|Failed –> Unconfigured|Rebuild|Online
查看磁盘缓存策略
#/opt/MegaRAID/MegaCli/MegaCli64 -LDGetProp -Cache -L0 -a0or#/opt/MegaRAID/MegaCli/MegaCli64 -LDGetProp -Cache -L1 -a0or#/opt/MegaRAID/MegaCli/MegaCli64 -LDGetProp -Cache -LALL -a0ro#/opt/MegaRAID/MegaCli/MegaCli64 -LDGetProp -Cache -LALL -aALLro#/opt/MegaRAID/MegaCli/MegaCli64 -LDGetProp -DskCache -LALL -aALL
设置磁盘缓存策略
缓存策略解释:
WT (Write throughWB (Write back)NORA (No read ahead)RA (Read ahead)ADRA (Adaptive read ahead)CachedDirect例子:#/opt/MegaRAID/MegaCli/MegaCli64 -LDSetProp WT|WB|NORA|RA|ADRA -L0 -a0or#/opt/MegaRAID/MegaCli/MegaCli64 -LDSetProp -Cached|-Direct -L0 -a0orenable / disable disk cache
创建RAID阵列
#/opt/MegaRAID/MegaCli/MegaCli64 -LDSetProp -EnDskCache|-DisDskCache -L0 -a06.创建一个 raid5 阵列,由物理盘 2,3,4 构成,该阵列的热备盘是物理盘 5#/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r5 [1:2,1:3,1:4] WB Direct -Hsp[1:5] -a07.创建阵列,不指定热备#/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r5 [1:2,1:3,1:4] WB Direct -a08.删除阵列#/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdDel -L1 -a09.在线添加磁盘#/opt/MegaRAID/MegaCli/MegaCli64 -LDRecon -Start -r5 -Add -PhysDrv[1:4] -L1 -a010.阵列创建完后,会有一个初始化同步块的过程,可以看看其进度。#/opt/MegaRAID/MegaCli/MegaCli64 -LDInit -ShowProg -LALL -aALL或者以动态可视化文字界面显示#/opt/MegaRAID/MegaCli/MegaCli64 -LDInit -ProgDsply -LALL -aALL11.查看阵列后台初始化进度#/opt/MegaRAID/MegaCli/MegaCli64 -LDBI -ShowProg -LALL -aALL或者以动态可视化文字界面显示#/opt/MegaRAID/MegaCli/MegaCli64 -LDBI -ProgDsply -LALL -aALL12.指定第 5 块盘作为全局热备#/opt/MegaRAID/MegaCli/MegaCli64 -PDHSP -Set [-EnclAffinity] [-nonRevertible] -PhysDrv[1:5] -a013.指定为某个阵列的专用热备#/opt/MegaRAID/MegaCli/MegaCli64 -PDHSP -Set [-Dedicated [-Array1]] [-EnclAffinity] [-nonRevertible] -PhysDrv[1:5] -a014.删除全局热备#/opt/MegaRAID/MegaCli/MegaCli64 -PDHSP -Rmv -PhysDrv[1:5] -a015.将某块物理盘下线/上线#/opt/MegaRAID/MegaCli/MegaCli64 -PDOffline -PhysDrv [1:4] -a0#/opt/MegaRAID/MegaCli/MegaCli64 -PDOnline -PhysDrv [1:4] -a016.查看物理磁盘重建进度#/opt/MegaRAID/MegaCli/MegaCli64 -PDRbld -ShowProg -PhysDrv [1:5] -a0或者以动态可视化文字界面显示#/opt/MegaRAID/MegaCli/MegaCli64 -PDRbld -ProgDsply -PhysDrv [1:5] -a0磁带状态的变化,从拔盘,到插盘的过程中:Device |Normal|Damage|Rebuild|NormalVirtual Drive |Optimal|Degraded|Degraded|OptimalPhysical Drive |Online|Failed –> Unconfigured|Rebuild|Online
1、查看所有物理磁盘信息
MegaCli -PDList -aALLAdapter #0Enclosure Number: 1Slot Number: 5Device Id: 5Sequence Number: 2Media Error Count: 0Other Error Count: 0Predictive Failure Count: 0Last Predictive Failure Event Seq Number: 0Raw Size: 140014MB [0x11177328 Sectors]Non Coerced Size: 139502MB [0x11077328 Sectors]Coerced Size: 139392MB [0x11040000 Sectors]Firmware state: HotspareSAS Address(0): 0x5000c50008e5cca9SAS Address(1): 0x0Inquiry Data: SEAGATE ST3146855SSS5273LN4Y1X0
2、查看磁盘缓存策略
MegaCli -LDGetProp -Cache -L0 -a0Adapter 0-VD 0: Cache Policy:WriteBack, ReadAheadNone, DirectorMegaCli -LDGetProp -Cache -L1 -a0Adapter 0-VD 1: Cache Policy:WriteBack, ReadAheadNone, DirectorMegaCli -LDGetProp -Cache -LALL -a0Adapter 0-VD 0: Cache Policy:WriteBack, ReadAheadNone, DirectAdapter 0-VD 1: Cache Policy:WriteBack, ReadAheadNone, DirectorMegaCli -LDGetProp -Cache -LALL -aALLAdapter 0-VD 0: Cache Policy:WriteBack, ReadAheadNone, DirectAdapter 0-VD 1: Cache Policy:WriteBack, ReadAheadNone, DirectorMegaCli -LDGetProp -DskCache -LALL -aALLAdapter 0-VD 0: Disk Write Cache : Disk's DefaultAdapter 0-VD 1: Disk Write Cache : Disk's Default
3、设置磁盘缓存策略
缓存策略解释:WT (Write throughWB (Write back)NORA (No read ahead)RA (Read ahead)ADRA (Adaptive read ahead)CachedDirect例子:MegaCli -LDSetProp WT|WB|NORA|RA|ADRA -L0 -a0orMegaCli -LDSetProp -Cached|-Direct -L0 -a0orenable / disable disk cacheMegaCli -LDSetProp -EnDskCache|-DisDskCache -L0 -a0
4、创建/删除 阵列
4.1 创建一个 raid5 阵列,由物理盘 2,3,4 构成,该阵列的热备盘是物理盘 5MegaCli -CfgLdAdd -r5 [1:2,1:3,1:4] WB Direct -Hsp[1:5] -a04.2 创建阵列,不指定热备MegaCli -CfgLdAdd -r5 [1:2,1:3,1:4] WB Direct -a04.3 删除阵列MegaCli -CfgLdDel -L1 -a04.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] -a0MegaCli -PDOnline -PhysDrv [1:4] -a0
9、查看物理磁盘重建进度
MegaCli -PDRbld -ShowProg -PhysDrv [1:5] -a0
查看raid 电池状态
查看当前raid缓存状态,raid缓存状态设置为wb的话要注意电池放电事宜,设置电池放电模式为自动学习模式/opt/MegaRAID/MegaCli/MegaCli64 -ldgetprop -dskcache -lall -aallraid 电池设置相关查看电池状态信息(Display BBU Status Information)MegaCli -AdpBbuCmd -GetBbuStatus -aN|-a0,1,2|-aALLMegaCli -AdpBbuCmd -GetBbuStatus -aALL查看电池容量(Display BBU Capacity Information)MegaCli -AdpBbuCmd -GetBbuCapacityInfo -aN|-a0,1,2|-aALLMegaCli -AdpBbuCmd -GetBbuCapacityInfo –aALL查看电池设计参数(Display BBU Design Parameters)MegaCli -AdpBbuCmd -GetBbuDesignInfo -aN|-a0,1,2|-aALLMegaCli -AdpBbuCmd -GetBbuDesignInfo –aALL查看电池属性(Display Current BBU Properties)MegaCli -AdpBbuCmd -GetBbuProperties -aN|-a0,1,2|-aALLMegaCli -AdpBbuCmd -GetBbuProperties –aALL设置电池为学习模式为循环模式(Start BBU Learning Cycle)Description Starts the learning cycle on the BBU.No parameter is needed for this option.MegaCli -AdpBbuCmd -BbuLearn -aN|-a0,1,2|-aALL设置磁盘的缓存模式和访问方式 (Change Virtual Disk Cache and Access Parameters)Description Allows you to change the following virtual disk parameters:-WT (Write through), WB (Write back): Selects write policy.-NORA (No read ahead), RA (Read ahead), ADRA (Adaptive read ahead): Selects read policy.-Cached, -Direct: Selects cache policy.-RW, -RO, Blocked: Selects access policy.-EnDskCache: Enables disk cache.-DisDskCache: Disables disk cache.MegaCli -LDSetProp { WT | WB|NORA |RA | ADRA|-Cached|Direct} |{-RW|RO|Blocked} |{-Name[string]} |{-EnDskCache|DisDskCache} –Lx |-L0,1,2|-Lall -aN|-a0,1,2|-aALLMegaCli -LDSetProp WT -L0 -a0显示磁盘缓存和访问方式(Display Virtual Disk Cache and Access Parameters)MegaCli -LDGetProp -Cache | -Access | -Name | -DskCache -Lx|-L0,1,2|-Lall -aN|-a0,1,2|-aALLDisplays the cache and access policies of the virtual disk(s):-WT (Write through), WB (Write back): Selects write policy.-NORA (No read ahead), RA (Read ahead), ADRA (Adaptive read ahead): Selects read policy.-Cache, -Cached, Direct: Displays cache policy.-Access, -RW, -RO, Blocked: Displays access policy.-DskCache: Displays physical disk cache policy.Megaraid 必知必会 使用LSI的megaraid可以对raid进行有效监控。别的厂商比如HP,IBM也有自己的raid APIMegaCli -ldinfo -lall -aall查询raid级别,磁盘数量,容量,条带大小。MegaCli -cfgdsply -aALL |grep Policy查询控制器cache策略MegaCli -LDSetProp WB -L0 -a0设置write back功能MegaCli -LDSetProp CachedBadBBU -L0 -a0设置即使电池坏了还是保持WB功能MegaCli -AdpBbuCmd -BbuLearn a0手动充电MegaCli -FwTermLog -Dsply -aALL 查询日志显示适配器个数: MegaCli -adpCount显示所有适配器信息: MegaCli -AdpAllInfo -aAllCritical Disks : 0 Failed Disks : 0 显示所有逻辑磁盘组信息: MegaCli -LDInfo -LALL -aAll显示所有的物理信息: MegaCli -PDList -aAllMedia Error Count: 0Other Error Count: 0查看充电状态: MegaCli -AdpBbuCmd -GetBbuStatus -aALLLearn Cycle Requested : NoFully Charged : Yes显示BBU(后备电池)状态信息: MegaCli -AdpBbuCmd -GetBbuStatus -aALL显示BBU容量信息: MegaCli -AdpBbuCmd -GetBbuCapacityInfo -aALL显示BBU设计参数: MegaCli -AdpBbuCmd -GetBbuDesignInfo -aALL显示当前BBU属性: MegaCli -AdpBbuCmd -GetBbuProperties -aALL显示Raid卡型号,Raid设置,Disk相关信息: MegaCli -cfgdsply -aALL查看Cache 策略设置: MegaCli -cfgdsply -aALL |grep -i PolicyCurrent Cache Policy: WriteBack, ReadAheadNone, Direct, Write Cache OK if Bad BBU查看充电进度百分比: MegaCli -AdpBbuCmd -GetBbuStatus -aALL 各种设备和磁盘的不同状态:Device |Normal|Damage|Rebuild|NormalVirtual Drive |Optimal|Degraded|Degraded|OptimalPhysical Drive |Online|Failed –> Unconfigured|Rebuild|Online
通过脚本检测RAID 磁盘状态
Linux下脚本
#!/bin/bash#check raid disk statusMEGACLI="/opt/MegaRAID/MegaCli/MegaCli64 "$MEGACLI -pdlist -aALL | grep "Firmware state" | awk -F : '{print $2}' | awk -F , '{print $1}' >/tmp/fireware.log$MEGACLI -pdlist -aALL | grep -E "Media Error|Other Error" | awk -F : '{print $2}' >/tmp/disk.logfor i in `cat < /tmp/disk.log`doif [ $i -ne 0 ]thencurl "http://xxxxxxB&state=ALARM&description=raid_disk_error"fidonefor i in `cat < /tmp/fireware.log`doif [ $i != Online ]thencurl "http://xxxxxxstate=ALARM&description=raid_disk_offline"fidone
CentOS安装megacli
yum install megacli -y 查看Raid卡信息megacli -LDInfo -Lall -aALL 查看硬盘信息:megacli -PDList -aALL
查看Raid卡信息
[root@ robin]# megacli -LDInfo -Lall -aALL OSSpecificInitialize: Failed to load libsysfs.so.2.0.2 Please ensure that libsfs is present in the system.The dependent library libsysfs.so.2.0.1 not available. Please contact LSI for distribution of the packageAdapter 0 -- Virtual Drive Information:Virtual Drive: 0 (Target Id: 0)Name:RAID Level: Primary-1, Secondary-0, RAID Level Qualifier-0Size: 930.5 GBMirror Data : 930.5 GBState: Optimal <<<< 这是正常的状态。Strip Size: 64 KBNumber Of Drives per span:2 <<<< RAID组包含2块磁盘(但实际是4块500G的SSD做Raid10)。Span Depth: 2 <<<< 深度若是1,说明实际只是RAID 1。2表示可以是RAID 10Default Cache Policy: WriteBack, ReadAdaptive, Direct, No Write Cache if Bad BBUCurrent Cache Policy: WriteBack, ReadAdaptive, Direct, No Write Cache if Bad BBUDefault Access Policy: Read/WriteCurrent Access Policy: Read/WriteDisk Cache Policy : Disk's DefaultOngoing Progresses:Background Initialization: Completed 41%, Taken 190 min.Encryption Type: NoneDefault Power Savings Policy: Controller DefinedCurrent Power Savings Policy: NoneCan spin up in 1 minute: NoLD has drives that support T10 power conditions: NoLD's IO profile supports MAX power savings with cached writes: NoBad Blocks Exist: NoIs VD Cached: No
查看硬盘信息:
[root@localhost ~]# megacli -PDList -aALL###有如下样式的几段,说明实际有几块硬盘(下面是一块500G的SSD的信息)Enclosure Device ID: 32Slot Number: 3Drive's postion: DiskGroup: 0, Span: 1, Arm: 1Enclosure position: 0Device Id: 3WWN: 50025388A0061518Sequence Number: 2Media Error Count: 0Other Error Count: 0Predictive Failure Count: 0Last Predictive Failure Event Seq Number: 0PD Type: SATARaw Size: 465.761 GB [0x3a386030 Sectors]Non Coerced Size: 465.261 GB [0x3a286030 Sectors]Coerced Size: 465.25 GB [0x3a280000 Sectors]Firmware state: Online, Spun UpDevice Firmware Level: BB0QShield Counter: 0Successful diagnostics completion on : N/ASAS Address(0): 0x4433221107000000Connected Port Number: 3(path0) Inquiry Data: S1DHNSADA04008BSamsung SSD 840 EVO 500GBEXT0BB0QFDE Enable: DisableSecured: UnsecuredLocked: UnlockedNeeds EKM Attention: NoForeign State: None Device Speed: 6.0Gb/s Link Speed: 6.0Gb/s Media Type: Solid State DeviceDrive: Not CertifiedDrive Temperature :32C (89.60 F)PI Eligibility: No Drive is formatted for PI information: NoPI: No PIDrive's write cache : DisabledDrive's NCQ setting : DisabledPort-0 :Port status: ActivePort's Linkspeed: 6.0Gb/s Drive has flagged a S.M.A.R.T alert : No
备注:
RAID型号对应表信息如下:
RAID Level : Primary-1, Secondary-0, RAID Level Qualifier-0" #代表Raid 1RAID Level : Primary-0, Secondary-0, RAID Level Qualifier-0" #代表Raid 0RAID Level : Primary-5, Secondary-0, RAID Level Qualifier-3" #代表Raid 5RAID Level : Primary-1, Secondary-3, RAID Level Qualifier-0" #代表Raid10
命令行模式举例如下:
lsiutil –p1 –a 21,1,0,0,0 和上边菜单操作一样,只不过不用手动去选择菜单项了lsiutil -p 1 -i –s 显示端口1的设置和连接的设备lsiutil –s 显示所有端口上连接的设备lsiutil -p 2 -l 1 强制HBA卡端口2连接速度为1Gb
案例 :
1、MegaCli操作1—创建与删除raid0
服务器DELL R710加硬盘,准备在线做raid。
用MegaCli做阵列,最重要是就是这三个系数:
Adapter #0
Enclosure Device ID: 32
Slot Number: 0
分别代表了 -PhysDrv[E0:S0,E1:S1,…] -aN #物理磁盘的 enclosure号:slot号 -a是阵列卡号
这些参数可以通过下面的命令得到。
查看阵列卡信息
lspci -v/opt/MegaRAID/MegaCli/MegaCli64 -AdpAllInfo -aALL
查看所有物理硬盘状态
/opt/MegaRAID/MegaCli/MegaCli64 -PDList -a0 # /opt/MegaRAID/MegaCli/MegaCli64 help |grep -i pdinfoMegaCli -pdInfo -PhysDrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL MegaCli -LdPdInfo -aN|-a0,1,2|-aALL
查看逻辑盘详细信息
# /opt/MegaRAID/MegaCli/MegaCli64 -LdPdInfo -aALL
查看单个盘的详细信息
# /opt/MegaRAID/MegaCli/MegaCli64 -pdInfo -PhysDrv[32:3] -aALLAdapter 0: Device at Enclosure - 32, Slot - 3 is not found.
像我新增加的硬盘就是 [32:2]
这里我的硬盘被标记为“Foreign”外来配置,要清除一下,不然会报下面这个错误:
The specified physical disk does not have the appropriate attributes to complete the requested command.Exit Code: 0x26
扫描外来配置的个数:
# /opt/MegaRAID/MegaCli/MegaCli64 -cfgforeign -scan -a0 There are 1 foreign configuration(s) on controller 0.Exit Code: 0x00
清除外来配置:
# /opt/MegaRAID/MegaCli/MegaCli64 -cfgforeign -clear -a0Foreign configuration 0 is cleared on controller 0.Exit Code: 0x00
再次扫描外来配置的个数:
# /opt/MegaRAID/MegaCli/MegaCli64 -cfgforeign -scan -a0 There is no foreign configuration on controller 0.Exit Code: 0x00
创建Raid0
# /opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r0[32:2] WB Direct -a0Adapter 0: Created VD 2Adapter 0: Configured the Adapter!!Exit Code: 0x00
删除阵列:
# /opt/MegaRAID/MegaCli/MegaCli6 -cfgclr -a0 清除所有的raid组的配置# /opt/MegaRAID/MegaCli/MegaCli6 -cfglddel -L0 -a0 删除指定的raid组(Target Id: 0)的raid组,可以通过上面的“查看逻辑盘详细信息”得到。
查看硬盘的重建情况:
# /opt/MegaRAID/MegaCli/MegaCli64 -PDRbld -ProgDsply -PhysDrv [12:7] -aALLDevice(Encl-12 Slot-7) is not in rebuild process
2、MegaCli使用方法
查看磁盘使用情况
[root@ ~]# MegaCli -PDList -Aall Enclosure Device ID: 32Slot Number: 0Enclosure position: 0Device Id: 0Sequence Number: 2Media Error Count: 0Other Error Count: 0Predictive Failure Count: 0Last Predictive Failure Event Seq Number: 0PD Type: SASRaw Size: 931.512 GB [0x74706db0 Sectors]Non Coerced Size: 931.012 GB [0x74606db0 Sectors]Coerced Size: 931.0 GB [0x74600000 Sectors]Firmware state: Online, Spun Up 在线Enclosure Device ID: 32Slot Number: 1Enclosure position: 0Device Id: 1Sequence Number: 2Media Error Count: 0Other Error Count: 0Predictive Failure Count: 0Last Predictive Failure Event Seq Number: 0PD Type: SASRaw Size: 931.512 GB [0x74706db0 Sectors]Non Coerced Size: 931.012 GB [0x74606db0 Sectors]Coerced Size: 931.0 GB [0x74600000 Sectors]Firmware state: Online, Spun UpSAS Address(0): 0x5000c500586e6559Enclosure Device ID: 32Slot Number: 2Enclosure position: 0Device Id: 2Sequence Number: 3Media Error Count: 0Other Error Count: 0Predictive Failure Count: 0Last Predictive Failure Event Seq Number: 0PD Type: SASRaw Size: 1.819 TB [0xe8e088b0 Sectors]Non Coerced Size: 1.818 TB [0xe8d088b0 Sectors]Coerced Size: 1.818 TB [0xe8d00000 Sectors]Firmware state: Unconfigured(good), Spun Up 安装了磁盘,但是没有使用Enclosure Device ID: 32Slot Number: 3Enclosure position: 0Device Id: 3Sequence Number: 3Media Error Count: 0Other Error Count: 0Predictive Failure Count: 0Last Predictive Failure Event Seq Number: 0PD Type: SASRaw Size: 1.819 TB [0xe8e088b0 Sectors]Non Coerced Size: 1.818 TB [0xe8d088b0 Sectors]Coerced Size: 1.818 TB [0xe8d00000 Sectors]Firmware state: Unconfigured(good), Spun Up 安装了磁盘,但是没有使用
2块2T磁盘使用MegaCli做raid0
[root@ZAMPDMP-08 ~]# MegaCli -CfgLdAdd -r0 [32:2,32:3] WB Direct -a0Adapter 0: Created VD 1Adapter 0: Configured the Adapter!!Exit Code: 0x00
单块4T磁盘做raid0
对7号槽的单块4T硬盘做raid0
MegaCli -CfgLdAdd -r0 [32:6] WB Direct -a0
单块盘要么调整raid 为jbod模式
要么就做成raid0 才能作为单块盘使用
无实际意义
只是raid卡的限制
查看raid
[root@ZAMPDMP-08 ~]# MegaCli -LdPdInfo -aALL Adapter #0
Number of Virtual Disks: 2
Virtual Drive: 0 (Target Id: 0) 第一个raid,包括slot 0,1,对应插槽0和1,级别raid0
Name:RAID Level: Primary-1, Secondary-0, RAID Level Qualifier-0Size: 931.0 GBState: OptimalStrip Size: 64 KBNumber Of Drives : 2Span Depth: 1Default Cache Policy: WriteThrough, ReadAheadNone, Direct, No Write Cache if Bad BBUCurrent Cache Policy: WriteThrough, ReadAheadNone, Direct, No Write Cache if Bad BBUAccess Policy : Read/WriteDisk Cache Policy : Disk's DefaultEncryption Type: NoneDefault Power Savings Policy: Controller DefinedCurrent Power Savings Policy: NoneCan spin up in 1 minute: YesLD has drives that support T10 power conditions: YesLD's IO profile supports MAX power savings with cached writes: NoBad Blocks Exist: NoNumber of Spans: 1Span: 0 - Number of PDs: 2
PD: 0 InformationEnclosure Device ID: 32Slot Number: 0Enclosure position: 0Device Id: 0Sequence Number: 2Media Error Count: 0Other Error Count: 0Predictive Failure Count: 0Last Predictive Failure Event Seq Number: 0PD Type: SASRaw Size: 931.512 GB [0x74706db0 Sectors]Non Coerced Size: 931.012 GB [0x74606db0 Sectors]Coerced Size: 931.0 GB [0x74600000 Sectors]Firmware state: Online, Spun UpSAS Address(0): 0x5000c500586e2169SAS Address(1): 0x0Connected Port Number: 0(path0) Inquiry Data: SEAGATE ST1000NM0023 GS0DZ1W1SRX0 FDE Capable: Not CapableFDE Enable: DisableSecured: UnsecuredLocked: UnlockedNeeds EKM Attention: NoForeign State: None Device Speed: 6.0Gb/s Link Speed: 6.0Gb/s Media Type: Hard Disk DeviceDrive Temperature :37C (98.60 F)
PD: 1 InformationEnclosure Device ID: 32Slot Number: 1Enclosure position: 0Device Id: 1Sequence Number: 2Media Error Count: 0Other Error Count: 0Predictive Failure Count: 0Last Predictive Failure Event Seq Number: 0PD Type: SASRaw Size: 931.512 GB [0x74706db0 Sectors]Non Coerced Size: 931.012 GB [0x74606db0 Sectors]Coerced Size: 931.0 GB [0x74600000 Sectors]Firmware state: Online, Spun UpSAS Address(0): 0x5000c500586e6559SAS Address(1): 0x0Connected Port Number: 1(path0) Inquiry Data: SEAGATE ST1000NM0023 GS0DZ1W1SQS1 FDE Capable: Not CapableFDE Enable: DisableSecured: UnsecuredLocked: UnlockedNeeds EKM Attention: NoForeign State: None Device Speed: 6.0Gb/s Link Speed: 6.0Gb/s Media Type: Hard Disk DeviceDrive Temperature :38C (100.40 F)
Virtual Drive: 1 (Target Id: 1) 第二个raid,包括slot 2,3,对应插槽2和4、3,级别raid0
Name:RAID Level: Primary-0, Secondary-0, RAID Level Qualifier-0Size: 3.637 TBState: OptimalStrip Size: 64 KBNumber Of Drives : 2Span Depth: 1Default Cache Policy: WriteThrough, ReadAheadNone, Direct, No Write Cache if Bad BBUCurrent Cache Policy: WriteThrough, ReadAheadNone, Direct, No Write Cache if Bad BBUAccess Policy : Read/WriteDisk Cache Policy : Disk's DefaultEncryption Type: NoneDefault Power Savings Policy: Controller DefinedCurrent Power Savings Policy: NoneCan spin up in 1 minute: YesLD has drives that support T10 power conditions: NoLD's IO profile supports MAX power savings with cached writes: NoBad Blocks Exist: NoNumber of Spans: 1Span: 0 - Number of PDs: 2
PD: 0 InformationEnclosure Device ID: 32Slot Number: 2Enclosure position: 0Device Id: 2Sequence Number: 4Media Error Count: 0Other Error Count: 0Predictive Failure Count: 0Last Predictive Failure Event Seq Number: 0PD Type: SASRaw Size: 1.819 TB [0xe8e088b0 Sectors]Non Coerced Size: 1.818 TB [0xe8d088b0 Sectors]Coerced Size: 1.818 TB [0xe8d00000 Sectors]Firmware state: Online, Spun UpSAS Address(0): 0x5000c50055f63469SAS Address(1): 0x0Connected Port Number: 2(path0) Inquiry Data: SEAGATE ST32000645SS RS12Z1K0ESPZ FDE Capable: Not CapableFDE Enable: DisableSecured: UnsecuredLocked: UnlockedNeeds EKM Attention: NoForeign State: None Device Speed: 6.0Gb/s Link Speed: 6.0Gb/s Media Type: Hard Disk DeviceDrive Temperature :42C (107.60 F)
PD: 1 InformationEnclosure Device ID: 32Slot Number: 3Enclosure position: 0Device Id: 3Sequence Number: 4Media Error Count: 0Other Error Count: 0Predictive Failure Count: 0Last Predictive Failure Event Seq Number: 0PD Type: SASRaw Size: 1.819 TB [0xe8e088b0 Sectors]Non Coerced Size: 1.818 TB [0xe8d088b0 Sectors]Coerced Size: 1.818 TB [0xe8d00000 Sectors]Firmware state: Online, Spun UpSAS Address(0): 0x5000c50055f60145SAS Address(1): 0x0Connected Port Number: 3(path0) Inquiry Data: SEAGATE ST32000645SS RS12Z1K0ETDN FDE Capable: Not CapableFDE Enable: DisableSecured: UnsecuredLocked: UnlockedNeeds EKM Attention: NoForeign State: None Device Speed: 6.0Gb/s Link Speed: 6.0Gb/s Media Type: Hard Disk DeviceDrive Temperature :44C (111.20 F)Exit Code: 0x00
删除raid0
[root@ZAMPDMP-08 ~]# MegaCli -cfglddel -L1 -a0 Adapter 0: Deleted Virtual Drive-1(target id-1)Exit Code: 0x00
L指的是删除vm组1 也就是第二个raid,a0是控制卡,如果是L0,则对应第一个raid。
root@ZAMPDMP-11 data1]# dmidecode -t 1# dmidecode 2.12SMBIOS 2.7 present.Handle 0x0100, DMI type 1, 27 bytesSystem InformationManufacturer: Dell Inc.Product Name: PowerEdge R420Version: Not SpecifiedSerial Number: 429PKY1 #机器序列号UUID: 4C4C4544-0032-3910-8050-B4C04F4B5931Wake-up Type: Power SwitchSKU Number: SKU=NotProvided;ModelName=PowerEdge R420Family: Not Specified
清楚外键
否则不能单块磁盘做raid0
root@deptest29:/home/chinadep# megacli -cfgforeign scan -a0 There are 1 foreign configuration(s) on controller 0.Exit Code: 0x00root@deptest29:/home/chinadep# megacli -cfgforeign clear -a0 Foreign configuration 0 is cleared on controller 0.Exit Code: 0x00root@deptest29:/home/chinadep# megacli -cfgforeign -scan -a0 There is no foreign configuration on controller 0.Exit Code: 0x00
新添加的大于等于2T的磁盘,需要使用parted去分区,fdisk分区4T盘,最多使用2T
这里测试使用parted 格式化10块4T盘,测试结果ok
[root@ZAMPDMP-08 ~]# vim parted.sh#!/bin/bash #Used to fomat 10 disks /dev/sdb /dev/sdc ....../dev/sdk 10PATH=/bin:/sbin:/usr/bin:/usr/sbinexport PATH i=1while [ $i -lt 11 ] doj=`echo $i|awk '{printf "%c",97+$i}'`parted /dev/sd$j <<ESXUmklabel gptmkpart primary 0 -1ignorequitESXUecho "/n/n******/dev/sd${j} __was Fdisked! Waiting For 10 Second*****/n/n" sleep 1smkfs.ext4 /dev/sd${j}1if [ "$?" = "0" ];thenecho "/n/n*****sd${j}1 _________________was Formated, Waiting For 5 Second****/n/n" filet i+=1sleep 1sdone
常见问题 :
1、Dell服务器MegaCli命令只返回Exit Code: 0x00问题分析
没有找到raid信息,不过看了一下SCSI控制器的信息,根据SAS1068E上网一查,得出SAS1068E的raid卡是SAS 6i/R。
MegaCli命令不支持SAS 6/iR的RAID卡
解决办法:下载lsiutil工具
参考链接 :
ftp:///pub/LSI/LSIUtil_1.62.zip
如果你是debian/ubuntu系统,则可以下载相应的deb包
wget ‘http://hwraid.le-/debian/pool-wheezy/lsiutil_1.60-1_amd64.deb’
dpkg -i lsiutil_1.60-1_amd64.deb
Linux系统下安装MegaCli64工具查看和管理raid卡: /lufeisan/article/details/53398756
Dell服务器MegaCli命令只返回Exit Code: 0x00问题分析 : /Linux/-04/142970.htm
megacli 查看Raid卡和硬盘信息 :/weixin_34331102/article/details/89798230
ubuntu安装megacli :/weixin_34092370/article/details/89801764
Dell服务器各种RAID卡介绍及监控方法 : /yjken/articles/3843216.html
/link?url=xALdxWDu3b_5ZEIjfgFLyi_airDL0oJ0UBFkjQiM8RxLVqyw1KJmQvCTt_5A7n7OqZ4pl9TxDivKz2ZVD8T1YmKYqfBO_DMm33W0OTMoqRa&wd=&eqid=9568c816003eeb0e000000045daeaff2
MegaCli操作1—创建与删除raid0 :/s/blog_57c70e190101ebl9.html
如果觉得《Dell服务器RAID常用管理命令总结》对你有帮助,请点赞、收藏,并留下你的观点哦!