Megacli常用命令汇总

Megacli常用命令汇总

1.显示Rebuid进度


/opt/MegaRAID/MegaCli/MegaCli64 -PDRbld -ShowProg -physdrv[20:2] -aALL

2.查看E S


/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aAll -NoLog | grep -Ei "(enclosure|slot)"

3.查看所有硬盘的状态


/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aAll -NoLog 

4.查看所有Virtual Disk的状态


/opt/MegaRAID/MegaCli/MegaCli64 -LdPdInfo -aAll -NoLog

RAID Level对应关系:


RAID Level : Primary-1, Secondary-0, RAID Level Qualifier-0RAID 1

RAID Level : Primary-0, Secondary-0, RAID Level Qualifier-0RAID 0

RAID Level : Primary-5, Secondary-0, RAID Level Qualifier-3RAID 5

RAID Level : Primary-1, Secondary-3, RAID Level Qualifier-0RAID 10

5.在线做Raid


/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r0[0:11] WB NORA Direct CachedBadBBU -strpsz64 -a0 -NoLog

/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r5 [12:2,12:3,12:4,12:5,12:6,12:7] WB Direct -a0 

6.点亮指定硬盘(定位)


/opt/MegaRAID/MegaCli/MegaCli64 -PdLocate -start -physdrv[252:2] -a0 

7.清除Foreign状态


/opt/MegaRAID/MegaCli/MegaCli64 -CfgForeign -Clear -a0 

8.查看RAID阵列中掉线的盘


/opt/MegaRAID/MegaCli/MegaCli64 -pdgetmissing -a0 

9.替换坏掉的模块


/opt/MegaRAID/MegaCli/MegaCli64 -pdreplacemissing -physdrv[12:10] -Array5 -row0 -a0 

10.手动开启rebuid


/opt/MegaRAID/MegaCli/MegaCli64 -pdrbld -start -physdrv[12:10] -a0 

11.查看Megacli的log


/opt/MegaRAID/MegaCli/MegaCli64 -FwTermLog dsply -a0 > adp2.log 

12.设置HotSpare


/opt/MegaRAID/MegaCli/MegaCli64 -pdhsp -set [-Dedicated [-Array2]] [-EnclAffinity] [-nonRevertible] -PhysDrv[4:11] -a0


/opt/MegaRAID/MegaCli/MegaCli64 -pdhsp -set [-EnclAffinity] [-nonRevertible] -PhysDrv[32:1}] -a0

13.关闭Rebuild


/opt/MegaRAID/MegaCli/MegaCli64 -AdpAutoRbld -Dsbl -a0 

14.设置rebuild的速率


/opt/MegaRAID/MegaCli/MegaCli64 -AdpSetProp RebuildRate -30 -a0 




15.用于查看各个磁盘的状态,并高亮的megacli脚本


  1. /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aAll -NoLog| grep -Ei '(enclosure|slot|error|firmware|pre|Foreign|^PD type|^Raw Size)' | awk '{if($0 ~ /Slot Number/ || $0 ~ /Enclosure/){printf("\033[32m%s ",$0);if($0 ~/Slot Number/) printf("\033[0m \n")}else if($0 ~ /bad/||$0 ~/Failed/||$0 ~ /Foreign State: Foreign/){print "\033[31m"$0"\033[0m"}else{print "\033[33m"$0"\033[0m"}}'


2.用于查看各个RAID Logical Disk的Megacli脚本


  1. /opt/MegaRAID/MegaCli/MegaCli64 -LdPdInfo -aAll -NoLog|grep -Ei '(^Virtual Disk|^RAID Level|^PD type|^Raw Size|^Enclosure|^Slot|error|firmware)' | awk '{if($0~/^Virtual/||$0~/^RAID/){printf("\033[35m%s\033[0m\n",$0)}else if($0 ~ /^Enclosure/){printf("\033[31m%s: %s\033[0m ",$1,$4)}else if($0 ~ /^Slot/){printf("\033[31m%s\033[0m\n",$0)}else if($0~/^Other/||$0~/Firmware/){printf("\033[33m%s\033[0m\n",$0)}else if($0~/^Raw/){printf("\033[33m%s%s\033[0m\n",$2,$3)}else{printf("\033[33m%s\033[0m ",$0)}}'






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

硬盘方面:

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

Adapter #0

Enclosure Number: 1 
Slot Number: 5 
Device Id: 5 
Sequence Number: 2 
Media Error Count: 0 
Other Error Count: 0 
Predictive Failure Count: 0 
Last Predictive Failure Event Seq Number: 0 
Raw Size: 140014MB [0x11177328 Sectors] 
Non Coerced Size: 139502MB [0x11077328 Sectors] 
Coerced Size: 139392MB [0x11040000 Sectors] 
Firmware state: Hotspare 
SAS Address(0): 0x5000c50008e5cca9 
SAS Address(1): 0x0 
Inquiry Data: SEAGATE ST3146855SS     S5273LN4Y1X0 
..... 
2、查看磁盘缓存策略 
MegaCli -LDGetProp -Cache -L0 -a0

Adapter 0-VD 0: Cache Policy:WriteBack, ReadAheadNone, Direct 
or 
MegaCli -LDGetProp -Cache -L1 -a0

Adapter 0-VD 1: Cache Policy:WriteBack, ReadAheadNone, Direct 
or 
MegaCli -LDGetProp -Cache -LALL -a0

Adapter 0-VD 0: Cache Policy:WriteBack, ReadAheadNone, Direct 
Adapter 0-VD 1: Cache Policy:WriteBack, ReadAheadNone, Direct 
or 
MegaCli -LDGetProp -Cache -LALL -aALL

Adapter 0-VD 0: Cache Policy:WriteBack, ReadAheadNone, Direct 
Adapter 0-VD 1: Cache Policy:WriteBack, ReadAheadNone, Direct 
or 
MegaCli -LDGetProp -DskCache -LALL -aALL

Adapter 0-VD 0: Disk Write Cache : Disk's Default 
Adapter 0-VD 1: Disk Write Cache : Disk's Default 
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] �Ca0 
    4.2 创建阵列,不指定热备 
MegaCli -CfgLdAdd -r5 [1:2,1:3,1:4] WB Direct �Ca0 
    4.3 删除阵列 
MegaCli -CfgLdDel -L1 �Ca0 
    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 �CaALL 
    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



本文出自 “~” 博客,谢绝转载!

你可能感兴趣的:(命令,汇总,megacli)