整理在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.
- 手动设置为全局热备盘,下次启动时生效