查看服務器RAID卡信息的SHELL腳本及MegaCLI命令介紹
目前維護的dDell服務器,大多使用的都是LSI的MegaRAID卡。
查看系統使用的什麼RAID卡,可以使用以下命令:
# dmesg |grep -i raid # cat /proc/scsi/scsi # lspci
MegaRAID卡,可以通過官方提供的工具MegaCli來進行檢查和控制。
下
#!/bin/sh Hostname=`/bin/hostname` Hostip=`ifconfig eth0|grep 'inet addr'|sed 's/.*addr:\(.*\) Bcast.*/\1/'` Battery=`/opt/MegaCli -AdpBbuCmd -GetBbuStatus -aALL|grep "Charger Status"|awk -F: '{print $1":"$2}'` raid=`/opt/MegaCli -cfgdsply -aALL|grep "RAID Level"|tail -1|awk -F: '{print $1" :"$2}'` Disknum=`/opt/MegaCli -cfgdsply -aALL|grep -c "Non Coerced Size"` Onlinedisk=`/opt/MegaCli -cfgdsply -aALL | grep “Online” | wc -l | sed 's/ //'` Faileddisk=`/opt/MegaCli -AdpAllInfo -aALL | grep "Failed Disks"|awk -F' ' '{print $4}'` echo "===================== Host Information =====================" echo "HostName : $Hostname" echo -e "HostIp : $Hostip\n" echo "===================== Raid Information =====================" #echo "$Raidmode" case "$raid" in "RAID Level : Primary-1, Secondary-0, RAID Level Qualifier-0") echo "Raid Level :Raid 1";; "RAID Level : Primary-0, Secondary-0, RAID Level Qualifier-0") echo "Raid Level :Raid 0";; "RAID Level : Primary-5, Secondary-0, RAID Level Qualifier-3") echo "Raid Level :Raid 5";; "RAID Level : Primary-1, Secondary-3, RAID Level Qualifier-0") echo "Raid Level :Raid 10";; esac if [ -z "$Battery" ];then echo "Battery :Null" else echo "$Battery" fi echo "Total Diak Number:$Disknum" echo "Online Disk Number:$Onlinedisk" echo "Failed Disk Number:$Faileddisk"
|
===================== Host Information ===================== HostName : vps.cszhi.com HostIp : 199.15.166.* ===================== Raid Information ===================== Raid Level :Raid 5 Charger Status: Complete Charger Status: Complete Total Diak Number:9 Online Disk Number:0 Failed Disk Number:0
MegaCli常用參數組合介紹:
MegaCli -cfgdsply -aALL | grep "Error" 【正常都是0】 MegaCli -LDGetProp -Cache -LALL -a0 【寫策略】 MegaCli -cfgdsply -aALL | grep "Memory" 【內存大小】 MegaCli -LDInfo -Lall -aALL 【查RAID級別】 MegaCli -AdpAllInfo -aALL 【查RAID卡信息】 MegaCli -PDList -aALL 【查看硬盤信息】 MegaCli -AdpBbuCmd -aAll 【查看電池信息】 MegaCli -FwTermLog -Dsply -aALL 【查看RAID卡日誌】 MegaCli -adpCount 【顯示適配器個數】 MegaCli -AdpGetTime –aALL 【顯示適配器時間】 MegaCli -AdpAllInfo -aAll 【顯示所有適配器信息】 MegaCli -LDInfo -LALL -aAll 【顯示所有邏輯磁盤組信息】 MegaCli -PDList -aAll 【顯示所有的物理信息】 MegaCli -AdpBbuCmd -GetBbuStatus -aALL |grep "Charger Status" 【查看充電狀態】 MegaCli -AdpBbuCmd -GetBbuStatus -aALL 【顯示BBU狀態信息】 MegaCli -AdpBbuCmd -GetBbuCapacityInfo -aALL 【顯示BBU容量信息】 MegaCli -AdpBbuCmd -GetBbuDesignInfo -aALL 【顯示BBU設計參數】 MegaCli -AdpBbuCmd -GetBbuProperties -aALL 【顯示當前BBU屬性】 MegaCli -cfgdsply -aALL 【顯示RAID卡型號,RAID設置,DISK相關信息】
磁帶狀態的變化,從拔盤,到插盤的過程中:
Device |Normal|Damage|Rebuild|Normal Virtual Drive |Optimal|Degraded|Degraded|Optimal Physical Drive |Online|Failed –> Unconfigured|Rebuild|Online
磁盤各個狀態說明:
A physical disk drive property indicating the status of the drive. A physical disk drive can be in one of the following states: >Unconfigured Good A disk accessible to the RAID controller but not configured as a part of a virtual disk or as a hotspare. >Online A physical disk can be accessed by the RAID controller and is part of the virtual disk. >rebuild A physical disk to which data is being written to restore full redundancy for a virtual disk. >failed A physical disk that was originally configured as Online but on which the firmware detects an unrecoverable error. >Unconfigured bad A physical disk on which the firmware detects an unrecoverable error; the physical disk was Unconfigured Good or the physical disk could not be initialized. Disks with a status of "Unconfigured bad" cannot be used for RAID configurations. >Missing A physical disk that was Online, but which has been removed from its location. >offline The drive is offline or absent. No actions can be performed on the drive until it is back online. >Global hotspare The drive will be used to repair any array in the system that had a drive failure, if the failed drive is equal to, or smaller than the hot spare drive. >Ready The drive is online and operating correctly. >Foreign The drive is part of an array created on a different controller, or created within one enclosure and moved to another on the same controller. It can be used to create a new array after clearing configuration. >None A physical disk with the unsupported flag set. An Unconfigured Good or Offline physical disk that has completed the prepare for removal operation. >copyback A bad physical disk replaced by a good one, then hotspare will copyback data to the good one and change back to hotspare