使用MegaCLI管理PC伺服器本地磁碟陣列

尛樣兒發表於2014-09-19

    寫這篇文章的原因是在部署Oracle Exadata x4-2的過程中有部分和MegaCli64命令相關的內容,之後在安裝部署IBM X3850 X5的時候,發現它和Exadata中SUN伺服器使用的是相同的陣列卡,HP,DELL的PC伺服器等大都也使用LSI的陣列卡,該型別的陣列卡透過MegaCli工具可以在作業系統層面對磁碟陣列進行非常方便的管理。

    從IBM X3850 X5來說,當RAID磁碟組中的某個磁碟的磁碟被替換掉,通常需要重啟伺服器進入WEBBIOS才能夠看到新磁碟Rebuild的進度,有了MegaCli工具能夠在不停止業務的情況下,線上的觀察新磁碟是否Rebuild完成;透過MegaCli還可以檢查RAID組的狀態,檢查磁碟的狀態,給RAID組增加、刪除磁碟等等,這篇文章非常膚淺的介紹了MegaCli工具,網上有非常詳盡的介紹可以深入研究。

1.環境介紹。

[root@hisdb02 MegaCli]# dmidecode -s system-product-name
System x3850 X5 -[71437Y5]-

伺服器是IBM x3850 X5。

[root@hisdb02 MegaCli]# lspci | grep RAID
09:00.0 RAID bus controller: LSI Logic / Symbios Logic MegaRAID SAS 2208 [Thunderbolt] (rev 03)

[root@hisdb02 MegaCli]# dmesg | grep "RAID"
scsi0 : LSI SAS based MegaRAID driver
scsi 0:0:0:0: Direct-Access     IBM      ServeRAID M5016  3.27 PQ: 0 ANSI: 5
scsi 0:2:0:0: Direct-Access     IBM      ServeRAID M5016  3.27 PQ: 0 ANSI: 5
md: Autodetecting RAID arrays.

2.安裝MegaCli工具。

    MegaCli工具在系統光碟中沒有自帶,可以從伺服器廠家的網站上下載,也可以直接到LSI的網站上下載最新的MegaCli工具。下面是LSI網站下載MegaCli工具的地址:,當前最新版本是:8.07.14。

執行下面的步驟安裝MegaCli工具:

[root@hisdb02 Server]# cd /opt
[root@hisdb02 opt]# ls
8.07.14_MegaCLI.zip
[root@hisdb02 opt]# unzip 8.07.14_MegaCLI.zip 
Archive:  8.07.14_MegaCLI.zip
  inflating: 8.07.14_MegaCLI.txt     
  inflating: DOS/MegaCLI.exe         
 extracting: FreeBSD/MegaCLI.zip     
 extracting: FreeBSD/MegaCli64.zip   
  inflating: Linux/MegaCli-8.07.14-1.noarch.rpm  
  inflating: Solaris/MegaCli.pkg     
  inflating: Windows/MegaCli.exe     
  inflating: Windows/MegaCli64.exe   
[root@hisdb02 opt]# ls
8.07.14_MegaCLI.txt  8.07.14_MegaCLI.zip  DOS  FreeBSD  Linux  Solaris  Windows
[root@hisdb02 opt]# cd Linux/
[root@hisdb02 Linux]# ls
MegaCli-8.07.14-1.noarch.rpm
[root@hisdb02 Linux]# rpm -ivh MegaCli-8.07.14-1.noarch.rpm 
Preparing...                ########################################### [100%]
   1:MegaCli                ########################################### [100%]
[root@hisdb02 opt]# ls
8.07.14_MegaCLI.txt  8.07.14_MegaCLI.zip  DOS  FreeBSD  Linux  MegaRAID  Solaris  Windows
[root@hisdb02 opt]# cd MegaRAID/MegaCli
[root@hisdb02 MegaCli]# ls
install.log  libstorelibir-2.so  libstorelibir-2.so.14.07-0  MegaCli64

MegaCli64就是我們要用到的MegaCli命令,64表示是64位的工具。

3.常用命令。

1).檢視RAID級別:
[root@hisdb02 MegaCli]# ./MegaCli64 -LdInfo -lAll -a0
                                     
Adapter 0 -- Virtual Drive Information:
Virtual Drive: 0 (Target Id: 0)
Name                :
RAID Level          : Primary-1, Secondary-0, RAID Level Qualifier-0    <<<< RAID級別是RAID10。
Size                : 557.861 GB
Sector Size         : 512
Is VD emulated      : No
Mirror Data         : 557.861 GB
State               : Optimal    <<<< 這是正常的狀態。
Strip Size          : 128 KB
Number Of Drives    : 2    <<<< RAID組包含2塊磁碟。
Span Depth          : 1    <<<< 深度是1,說明實際只是RAID 1。
Default Cache Policy: WriteBack, ReadAhead, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteBack, ReadAhead, Direct, No Write Cache if Bad BBU
Default Access Policy: Read/Write
Current Access Policy: Read/Write
Disk Cache Policy   : Disabled
Encryption Type     : None
PI type: No PI

Is VD Cached: No

這條命令檢視的也是邏輯(虛擬)磁碟的狀態,執行./MegaCli64 -LDInfo -LAll -aAll命令可以檢視所有介面卡的虛擬磁碟資訊。

2).檢視RAID控制器個數:
[root@hisdb02 MegaCli]#  ./MegaCli64 -adpCount
                                     
Controller Count: 1.

只有1個控制器。執行./MegaCli64 -AdpAllInfo -aAll命令可以檢視所有介面卡的詳細資訊。

3).檢視物理磁碟資訊:
[root@hisdb02 MegaCli]# ./MegaCli64 -Pdlist -a0
                                     
Adapter #0

第一塊盤資訊:

Enclosure Device ID: 252
Slot Number: 0
Drive's position: DiskGroup: 0, Span: 0, Arm: 0
Enclosure position: N/A
Device Id: 10
WWN: 5000C5007266557C
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: 558.911 GB [0x45dd2fb0 Sectors]
Non Coerced Size: 558.411 GB [0x45cd2fb0 Sectors]
Coerced Size: 557.861 GB [0x45bb9000 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: B56M
Shield Counter: 0
Successful diagnostics completion on :  N/A
SAS Address(0): 0x5000c5007266557d
SAS Address(1): 0x0
Connected Port Number: 1(path0) 
Inquiry Data: IBM-ESXSST600MM0006     B56MS0M2FFKB0221B5C5    
IBM FRU/CRU: 49Y2004     
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 :32C (89.60 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


第二塊盤資訊:

Enclosure Device ID: 252
Slot Number: 1
Drive's position: DiskGroup: 0, Span: 0, Arm: 1
Enclosure position: N/A
Device Id: 9
WWN: 5000C50072665134
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: 558.911 GB [0x45dd2fb0 Sectors]
Non Coerced Size: 558.411 GB [0x45cd2fb0 Sectors]
Coerced Size: 557.861 GB [0x45bb9000 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: B56M
Shield Counter: 0
Successful diagnostics completion on :  N/A
SAS Address(0): 0x5000c50072665135
SAS Address(1): 0x0
Connected Port Number: 0(path0) 
Inquiry Data: IBM-ESXSST600MM0006     B56MS0M2F9130221B5C5    
IBM FRU/CRU: 49Y2004     
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 :32C (89.60 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

    ./MegaCli64 -PDList -aALL命令顯示的是所有介面卡的資訊,因為當前伺服器只有一個介面卡,所以該命令的輸出結果和./MegaCli64 -Pdlist -a0命令一致。

4).檢查物理磁碟狀態:

[root@hisdb02 MegaCli]# ./MegaCli64 -Pdlist -a0|grep "Slot\|Firmware state"
Slot Number: 0
Firmware state: Online, Spun Up
Slot Number: 1
Firmware state: Online, Spun Up

5).檢視當前RAID快取狀態:
[root@hisdb02 MegaCli]# ./MegaCli64 -ldgetprop -dskcache -lall -aall
                                     
Adapter 0-VD 0(target id: 0): Disk Write Cache : Disabled

6).各種磁碟裝置的不同狀態:
Device :         Normal|Damage|Rebuild|Normal
Virtual Drive :  Optimal|Degraded|Degraded|Optimal
Physical Drive : Online|Failed –> Unconfigured|Rebuild|Online

注意觀察不同型別裝置的狀態,以判斷裝置是否出現故障;另外,當裝置出現故障,在作業系統日誌應該是有記錄的。更多MegaCli64命令的用法等待你去發現。

參考文章:
    http://blog.chinaunix.net/uid-25135004-id-3139293.html
    http://blog.sina.com.cn/s/blog_506ed9e60100yc2a.html

--end--

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23135684/viewspace-1274701/,如需轉載,請註明出處,否則將追究法律責任。

相關文章