MegaCli 監控raid狀態

簡介

MegaCli是一款管理維護硬件RAID軟件,可以通過它來了解當前raid卡的所有信息,包括 raid卡的型號,raid的陣列類型,raid 上各磁盤狀態,等等。通常,我們對硬盤當前的狀態不太好確定,一般通過機房人員巡檢來完成,有沒有通過軟件的方式來檢查確定這個問題呢。MegaCli就可以做到,一般通過 MegaCli Media Error Count: 0 Other Error Count: 0 這兩個數值來確定陣列中磁盤是否有問題;Medai Error Count 表示磁盤可能錯誤,可能是磁盤有壞道,這個值不爲0值得注意,數值越大,危險係數越高,Other Error Count 表示磁盤可能存在鬆動,可能需要重新再插入。MegaCli 可以對陣列中所有的磁盤進行檢測,我們可以通過腳本的方式來檢測相關參數,從而通知管理人員。

一、 下載MegCli,目前針對公司DB數據庫是IBM的服務器,直接從IBM官方下載,如果

其它服務器的,使用各官方下載或者 LSI網站上進行相關下載。一般來說,是通用的。這個包適用32 /64位操作系統平臺 

下載地址:ftp://download2.boulder.ibm.com/ecc/sar/CMA/XSA/ibm_utl_sraidmr_megacli-8.00.48_linux_32-64.zip

二、 安裝 

#unzip ibm_utl_sraidmr_megacli-8.00.48_linux_32-64.zip

#cd linux

# rpm -ivh Lib_Utils-1.00-09.noarch.rpm  MegaCli-8.00.48-1.i386.rpm

三 使用命令及參數 



點擊(此處)摺疊或打開




1、 查看RAID級別


2、 查看RAID卡信息,主要輸出RAID卡的一些配置信息


RAID Level : Primary-1, Secondary-0, RAID Level Qualifier-0
Size : 1.086 TB
State : Optimal
Strip Size : 128 KB
Number Of Drives per span:4 //表示每4個物理盤做成一個RAID1盤組
Span Depth : 2 //表示共2個RAID1盤組做成了RAID10


3、 查看所有硬盤的信息

/opt/MegaCli64  -pdlist –aALL


4、 查看當前raid緩存狀態,raid緩存狀態設置爲wb的話要注意電池放電事宜,設置電池放電模式爲自動學習模式

/opt/MegaRAID/MegaCli/MegaCli64   -ldgetprop  -dskcache -lall  -aall


5、 raid 電池設置相關

查看電池狀態信息(Display BBU Status Information)
MegaCli -AdpBbuCmd -GetBbuStatus -aN|-a0,1,2|-aALL
MegaCli -AdpBbuCmd -GetBbuStatus -aALL

查看電池容量Display BBU Capacity Information
MegaCli -AdpBbuCmd -GetBbuCapacityInfo -aN|-a0,1,2|-aALL
MegaCli -AdpBbuCmd -GetBbuCapacityInfo –aALL

查看電池設計參數(Display BBU Design Parameters)
MegaCli -AdpBbuCmd -GetBbuDesignInfo -aN|-a0,1,2|-aALL
MegaCli -AdpBbuCmd -GetBbuDesignInfo –aALL

查看電池屬性(Display Current BBU Properties
MegaCli -AdpBbuCmd -GetBbuProperties -aN|-a0,1,2|-aALL
MegaCli -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|-aALL
MegaCli -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|-aALL
Displays 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 API
MegaCli -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 -aAll
Critical Disks : 0 
Failed Disks : 0 


顯示所有邏輯磁盤組信息: MegaCli -LDInfo -LALL -aAll
顯示所有的物理信息: MegaCli -PDList -aAll
Media Error Count: 0
Other Error Count: 0

查看充電狀態: MegaCli -AdpBbuCmd -GetBbuStatus -aALL
Learn Cycle Requested : No
Fully 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 Policy
Current Cache Policy: WriteBack, ReadAheadNone, Direct, Write Cache OK if Bad BBU
查看充電進度百分比: MegaCli -AdpBbuCmd -GetBbuStatus -aALL 

各種設備和磁盤的不同狀態:
Device |Normal|Damage|Rebuild|Normal
Virtual Drive |Optimal|Degraded|Degraded|Optimal
Physical Drive |Online|Failed –> Unconfigured|Rebuild|Online

6、 通過腳本檢測RAID 磁盤狀態

Linux下腳本

#!/bin/bash

#check raid disk status

MEGACLI="/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.log

for i in `cat < /tmp/disk.log`

do

if [ $i -ne 0 ]

        then

curl "http://xxxxxxB&state=ALARM&description=raid_disk_error"

fi

done

for i in `cat < /tmp/fireware.log`

do

if [ $i !=  Online ]

        then

curl "http://xxxxxxstate=ALARM&description=raid_disk_offline"

fi

done

Windows 下腳本

Windows下腳本用的工具是gnu for windows平臺的一些軟件,如 bash grep awk cat

通過bash直接調用腳本

如:G:\raid_check\unixtools>bash.exe  G:\disk.sh

#check raid disk status

MEGACLI="//G/raid_check/MegaCli.exe"

GREP="//G/raid_check/unixtools/grep.exe"

AWK="//G/raid_check/unixtools/awk.exe"

CAT="//G/raid_check/unixtools/cat.exe"

CURL="//G/raid_check/unixtools/curl.exe"

$MEGACLI -pdlist -aALL  | $GREP "Firmware state" |$AWK -F: '{print $2}' |$AWK -F , '{print $1}' >//c/fireware.log

$MEGACLI -pdlist -aALL  | $GREP -E "Media Error|Other Error" | $AWK -F : '{print $2}' > //c/disk.log

for i in `$CAT c:/disk.log`

do

if [ $i -ne 0 ]

        then

$CURL "http://xxxxxx&description=raid_disk_error"

fi

done

for i in `$CAT c:/fireware.log`

do

if [ $i != Online ]

        then

$CURL "http://xxxxx&state=ALARM&description=raid_disk_offline"

fi



原文轉自:

http://blog.chinaunix.net/uid-25135004-id-3139293.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章