整理在CentOS 7.9和Ubuntu 24.04上,MegaCLI 工具的安裝與常用命令。
1. 參考
下載和安裝MegaCLI工具
MegaCli RAID管理工具
Megacli 批量磁盤巡檢
ubuntu24.04 No such file libncursesw.so.5
dell服務器硬盤的狀態變成外來(foreign)命令行修復
2. 下載
-
下載頁:
8-07-14_MegaCLI的下載鏈接: https://docs.broadcom.com/docs/12351587
https://www.broadcom.com/site-search?q=MegaCLI -
下載鏈接:
https://docs.broadcom.com/docs-and-downloads/raid-controllers/raid-controllers-common-files/8-07-14_MegaCLI.zip
3. 安裝
3.1 Centos系統
下載工具
登錄BROADCOM網站上MegaCli工具的下載頁面。
下載最新版本的MegaCLI工具。
解壓后得到適用于不同操作系統的工具包。
安裝工具
不同操作系統下,MegaCLI工具的安裝方法不同,此處僅以Windows、Linux、VMware為例進行說明。LSI SoftRAID適配的MegaCLI工具為“MegaCLI64”。Windows系統下安裝MegaCLI工具。
將適用Windows的工具包上傳到服務器操作系統。
打開命令行工具。
使用命令行工具進入MegaCLI工具包所在目錄。
Windows下的MegaCLI工具不需安裝,此時可執行RAID卡命令。Linux系統下安裝MegaCLI工具。
使用文件傳輸工具(例如Putty)將適用Linux的工具包上傳到服務器操作系統。
執行rpm -ivh MegaCli -xxx.rpm命令安裝MegaCLI工具。
安裝完畢后,即可執行RAID卡命令。VMware系統下安裝MegaCLI工具。
使用文件傳輸工具(例如Putty)將適用VMware的工具包上傳到服務器操作系統。
執行esxcli software vib install -v=vmware-xxx-MegaCli.vib命令安裝MegaCLI工具。
安裝完畢后,即可執行RAID卡命令。
3.2 Ubuntu系統
3.2.1 Ubuntu安裝說明
https://www.broadcom.com/support/knowledgebase/1211161500661/installing-megacli-in-debian-or-ubuntu
ID: 1211161500661
Question
Installing MegaCLI in Debian or Ubuntu.
Answer
Debian and Ubuntu do not support rpm packages, which is how LSI distributes MegaCLI. The MegaCLI rpm package can be converted for use with Debian and Ubuntu by following these steps:apt-get install alien
# Convert to .debalien -k --scripts filename.rpm# Install .debdpkg -i filename.deb# run itcd /opt/megaraid
3.2.2 Ubuntu安裝步驟
- 轉換
apt-get install alien
alien -k --scripts MegaCli-8.07.14-1.noarch.rpm
root@test:/home/software/MegaCLI/8-07-14_MegaCLI/Linux# ll
total 2640
drwxr-xr-x 2 root root 4096 May 9 14:46 ./
drwxr-xr-x 7 root root 4096 May 9 14:41 ../
-rw-r--r-- 1 root root 1549650 Dec 16 2013 MegaCli-8.07.14-1.noarch.rpm
-rw-r--r-- 1 root root 1141908 May 9 14:46 megacli_8.07.14-1_all.deb
- 安裝
dpkg -i megacli_8.07.14-1_all.debcd /opt/MegaRAID/MegaCli/ && llroot@test:/home/software/MegaCLI/8-07-14_MegaCLI/Linux# cd /opt/MegaRAID/MegaCli/ && ll
total 3196
drwxr-xr-x 2 root root 4096 May 9 14:47 ./
drwxr-xr-x 3 root root 4096 May 9 14:47 ../
-rwxr-xr-x 1 root root 2720320 Dec 16 2013 MegaCli64*
-rw-r--r-- 1 root root 0 May 9 14:47 install.log
lrwxrwxrwx 1 root root 48 May 9 14:47 libstorelibir-2.so -> /opt/MegaRAID/MegaCli/libstorelibir-2.so.14.07-0*
-rwx------ 1 root root 540512 Dec 16 2013 libstorelibir-2.so.14.07-0*
- Ubuntu 24.04缺少libncurses.so.5解決方法
# 執行命令會報找不到 libncurses.so.5文件
/opt/MegaRAID/MegaCli/MegaCli64 -h
# 編輯源文件
cd /etc/apt/sources.list.d/ && cp ubuntu.sources ubuntu.sources.bak
vim ubuntu.sources
# 增加官方源 http://archive.ubuntu.com/ubuntu/
Types: deb
URIs: http://archive.ubuntu.com/ubuntu/
Suites: trusty
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpgTypes: deb
URIs: http://mirrors.aliyun.com/ubuntu/
Suites: noble noble-updates noble-backports
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpgTypes: deb
URIs: http://security.ubuntu.com/ubuntu/
Suites: noble-security
Components: main restricted universe multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
apt-get update
# 安裝舊版兼容庫
apt-get install libncursesw5
root@test:/etc/apt/sources.list.d# find / -name libncurses.so.5
/usr/lib/x86_64-linux-gnu/libncurses.so.5
root@test:/etc/apt/sources.list.d# ldconfig -p | grep libncurseslibncursesw.so.6 (libc6,x86-64) => /lib/x86_64-linux-gnu/libncursesw.so.6libncursesw.so.5 (libc6,x86-64) => /lib/x86_64-linux-gnu/libncursesw.so.5libncurses.so.5 (libc6,x86-64) => /lib/x86_64-linux-gnu/libncurses.so.5
root@test:/etc/apt/sources.list.d# ln -s /lib/x86_64-linux-gnu/libncurses.so.5.9 /usr/lib/libncurses.so.5
root@test:/etc/apt/sources.list.d# ll /usr/lib/libncurses.so.5
lrwxrwxrwx 1 root root 39 May 9 16:38 /usr/lib/libncurses.so.5 -> /lib/x86_64-linux-gnu/libncurses.so.5.9
# 測試命令執行正常
root@test:/opt/MegaRAID/MegaCli# /opt/MegaRAID/MegaCli/MegaCli64 -hMegaCLI SAS RAID Management Tool Ver 8.07.14 Dec 16, 2013(c)Copyright 2013, LSI Corporation, All Rights Reserved.
......
4. 使用
[root@localhost Linux]# ln -s /opt/MegaRAID/MegaCli/MegaCli64 /bin/
[root@localhost Linux]# ln -s /opt/MegaRAID/MegaCli/MegaCli /bin/
- 查看硬盤是否在線
/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL |grep "Firmware state"
- 查看硬盤錯誤信息
/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL |grep -i error
/opt/MegaRAID/MegaCli/MegaCli64 -fwtermlog -dsply -aALL | grep -E "error|Error|ERROR|fail|Fail|FAIL"
5. 處理
5.1 處理硬盤狀態為Unconfigured(good)
-
DELL IDRAC看到有一塊硬盤顯示為“外來”
-
查詢硬盤狀態
root@test:/opt/MegaRAID/MegaCli# /opt/MegaRAID/MegaCli/MegaCli64 -pdlist -aall |grep 'Firmware state'
Firmware state: Online, Spun Up
Firmware state: Online, Spun Up
Firmware state: Online, Spun Up
Firmware state: Online, Spun Up
Firmware state: Online, Spun Up
Firmware state: Online, Spun Up
Firmware state: Online, Spun Up
Firmware state: Online, Spun Up
Firmware state: Unconfigured(good), Spun Up
Firmware state: Online, Spun Up
Firmware state: Online, Spun Up
Firmware state: Hotspare, Spun Up
# 顯示沒有diskgroup,并且 Firmware state: Unconfigured(good), Spun Up
root@test:/opt/MegaRAID/MegaCli# /opt/MegaRAID/MegaCli/MegaCli64 -pdlist -aall |more
Enclosure Device ID: 32
Slot Number: 8
Enclosure position: 1
Device Id: 8
WWN: 5000C50025EDAF6C
Sequence Number: 1
Media Error Count: 0
Other Error Count: 0
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0
PD Type: SASRaw Size: 1.819 TB [0xe8e088b0 Sectors]
Non Coerced Size: 1.818 TB [0xe8d088b0 Sectors]
Coerced Size: 1.818 TB [0xe8d00000 Sectors]
Sector Size: 0
Firmware state: Unconfigured(good), Spun Up
Device Firmware Level: KS68
Shield Counter: 0
Successful diagnostics completion on : N/A
SAS Address(0): 0x5000c50025edaf6d
SAS Address(1): 0x0
Connected Port Number: 0(path0)
Inquiry Data: SEAGATE ST32000444SS KS689WM38SN9
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 Temperature :35C (95.00 F)
PI Eligibility: No
Drive is formatted for PI information: No
PI: No PI
- 清除foreign配置
# 掃描外來配置的個數:
/opt/MegaRAID/MegaCli/MegaCli64 -cfgforeign -scan -a0There is 1 foreign configuration on controller 0.#清除外來配置:
/opt/MegaRAID/MegaCli/MegaCli64 -cfgforeign -clear -a0#再次掃描外來配置的個數:
/opt/MegaRAID/MegaCli/MegaCli64 -cfgforeign -scan -a0 There is no foreign configuration on controller 0.
- 手動設置為全局熱備盤,下次啟動時生效