美文网首页
使用MegaCli64快速查看RAID和定位故障硬盘实践

使用MegaCli64快速查看RAID和定位故障硬盘实践

作者: 王奥OX | 来源:发表于2019-07-22 16:54 被阅读0次

前言

MegaCli 是 LSI 公司官方提供的 SCSI 卡管理工具,由于 LSI 被收购变成了现在的 Broadcom,所以想下载 MegaCli,需要去 Broadcom 官网查找。现在官方有 Storcli,整合了 LSI 和 3ware 所有产品,本文主要以 MegaCli64 为例,无论选择 MegaCli 还是 Storcli 只要在线上环境运行稳定可以获取正确数据就都是合适的方法。

使用MegaCli64快速查看RAID和定位故障硬盘实践

更新历史

2019年07月21日 - 初稿

阅读原文 - https://wsgzao.github.io/post/megacli64/

扩展阅读

MegaCLI vs tw_cli vs Storcli
Extracting the RAID-Controller Logs via MegaCLI


MegaCli简介

MegaRaid 阵列卡管理工具。他可以查看当前 RAID 卡的所有信息,包括 RAID 卡型号、类型、磁盘状态、电池状态等等。学会了如何使用 MegaCli,我们可以在硬盘没有彻底嗝屁(Failed)之前,监测到是否已经出现预告警报错,不需要现场逐台巡检磁盘状态灯。

  1. 使用Zabbix监控硬盘或者使用IPMI接入OOB(Out-of-Band)监控硬件状态
  2. 使用更加成熟的商业化工具管理如云霁科技CloudBoot,拒绝被单一厂商绑架

MegaCli64官网地址: http://docs.avagotech.com/docs/12351587

Linux下默认路径: /opt/MegaRAID/MegaCli/MegaCli64

MegaCli安装

  1. Download the MegaCli utility from the Broadcom support site

  2. Unzip the downloaded files and install them to any directory of your installed operating system (e.g.: Linux – /tmp/megacli)

  3. From a terminal window in Linux, install the using the the following command:

    Note: root priviledges required to install MegaCLI:

    rpm -i MegaCli-8.07.14-1.noarch.rpm

  4. Then change directory into /opt/MegaRAID/MegaCLI/ and run any of the commands from the table below:

Command Action
./MegaCli64 -FwTermLog -Dsply -aALL > /tmp/ttylog.txt Creates the RAID controller log (ttylog)
./MegaCli64 -PDList -aALL > /tmp/disks.txt Creates a list with information about the RAID controllers, virtual disks and hard disks installed
./MegaCli64 -LDInfo -LALL -aALL > /tmp/LDinfo.txt Creates a list with information about existing RAID volumes and configurations
./MegaCli64 -AdpAllInfo -aALL > /tmp/Adapterinfo.txt Creates a list with information about RAID controller settings
./MegaCli64 -AdpBbuCmd -aALL > /tmp/Battery.txt Creates a detailed list of the battery status of the RAID controller (state of charge, learning cycle, etc.)
./MegaCli64 -AdpEventLog -IncludeDeleted -f deleted.txt -aALL Creates the RAID controller log (ttylog) with all information since very first controller initialization( Note: This file will always be saved in the MegaCLI root folder)

使用MegaCli64查看硬盘信息

[root@localhost wangao]# MegaCli -ShowSummary -aALL

System
    Operating System:  Linux version 3.10.0-957.21.3.el7.x86_64
    Driver Version: 07.705.02.00-rh1
    CLI Version: 8.07.06

Hardware
        Controller
                 ProductName       : PERC H730P Mini(Bus 0, Dev 0)
                 SAS Address       : 51866da0a1306300
                 FW Package Version: 25.5.0.0018
                 Status            : Optimal
        BBU
                 BBU Type          : BBU
                 Status            : Healthy
        Enclosure
                 Product Id        : BP13G+EXP
                 Type              : SES
                 Status            : OK

        PD
                Connector          : 00<Internal><Encl Pos 1 >: Slot 0
                Vendor Id          : HGST
                Product Id         : HUS726060AL5214
                State              : Online
                Disk Type          : SAS,Hard Disk Device
                Capacity           : 5.457 TB
                Power State        : Active

                Connector          : 00<Internal><Encl Pos 1 >: Slot 1
                Vendor Id          : HGST
                Product Id         : HUS726060AL5214
                State              : Online
                Disk Type          : SAS,Hard Disk Device
                Capacity           : 5.457 TB
                Power State        : Active

                Connector          : 00<Internal><Encl Pos 1 >: Slot 2
                Vendor Id          : HGST
                Product Id         : HUS726060AL5214
                State              : Online
                Disk Type          : SAS,Hard Disk Device
                Capacity           : 5.457 TB
                Power State        : Active

                Connector          : 00<Internal><Encl Pos 1 >: Slot 3
                Vendor Id          : HGST
                Product Id         : HUS726060AL5214
                State              : Online
                Disk Type          : SAS,Hard Disk Device
                Capacity           : 5.457 TB
                Power State        : Active

                Connector          : 00<Internal><Encl Pos 1 >: Slot 4
                Vendor Id          : HGST
                Product Id         : HUS726060AL5214
                State              : Online
                Disk Type          : SAS,Hard Disk Device
                Capacity           : 5.457 TB
                Power State        : Active

                Connector          : 00<Internal><Encl Pos 1 >: Slot 5
                Vendor Id          : HGST
                Product Id         : HUS726060AL5214
                State              : Online
                Disk Type          : SAS,Hard Disk Device
                Capacity           : 5.457 TB
                Power State        : Active

                Connector          : 00<Internal><Encl Pos 1 >: Slot 6
                Vendor Id          : HGST
                Product Id         : HUS726060AL5214
                State              : Online
                Disk Type          : SAS,Hard Disk Device
                Capacity           : 5.457 TB
                Power State        : Active

                Connector          : 00<Internal><Encl Pos 1 >: Slot 7
                Vendor Id          : HGST
                Product Id         : HUS726060AL5214
                State              : Online
                Disk Type          : SAS,Hard Disk Device
                Capacity           : 5.457 TB
                Power State        : Active

                Connector          : 00<Internal><Encl Pos 1 >: Slot 8
                Vendor Id          : HGST
                Product Id         : HUS726060AL5214
                State              : Online
                Disk Type          : SAS,Hard Disk Device
                Capacity           : 5.457 TB
                Power State        : Active

                Connector          : 00<Internal><Encl Pos 1 >: Slot 9
                Vendor Id          : HGST
                Product Id         : HUS726060AL5214
                State              : Online
                Disk Type          : SAS,Hard Disk Device
                Capacity           : 5.457 TB
                Power State        : Active

                Connector          : 00<Internal><Encl Pos 1 >: Slot 10
                Vendor Id          : HGST
                Product Id         : HUS726060AL5214
                State              : Online
                Disk Type          : SAS,Hard Disk Device
                Capacity           : 5.457 TB
                Power State        : Active

                Connector          : 00<Internal><Encl Pos 1 >: Slot 11
                Vendor Id          : HGST
                Product Id         : HUS726060AL5214
                State              : Online
                Disk Type          : SAS,Hard Disk Device
                Capacity           : 5.457 TB
                Power State        : Active

                Connector          : 00<Internal><Encl Pos 1 >: Slot 12
                Vendor Id          : ATA
                Product Id         : ST9250610NS
                State              : Online
                Disk Type          : SATA,Hard Disk Device
                Capacity           : 232.375 GB
                Power State        : Active

                Connector          : 00<Internal><Encl Pos 1 >: Slot 13
                Vendor Id          : ATA
                Product Id         : ST9250610NS
                State              : Online
                Disk Type          : SATA,Hard Disk Device
                Capacity           : 232.375 GB
                Power State        : Active

                Connector          : 00<Internal><Encl Pos 1 >: Slot 14
                Vendor Id          : HGST
                Product Id         : HUS726060AL5214
                State              : Online
                Disk Type          : SAS,Hard Disk Device
                Capacity           : 5.457 TB
                Power State        : Active

                Connector          : 00<Internal><Encl Pos 1 >: Slot 15
                Vendor Id          : HGST
                Product Id         : HUS726060AL5214
                State              : Online
                Disk Type          : SAS,Hard Disk Device
                Capacity           : 5.457 TB
                Power State        : Active

                Connector          : 00<Internal><Encl Pos 1 >: Slot 16
                Vendor Id          : HGST
                Product Id         : HUS726060AL5214
                State              : Online
                Disk Type          : SAS,Hard Disk Device
                Capacity           : 5.457 TB
                Power State        : Active

                Connector          : 00<Internal><Encl Pos 1 >: Slot 17
                Vendor Id          : HGST
                Product Id         : HUS726060AL5214
                State              : Online
                Disk Type          : SAS,Hard Disk Device
                Capacity           : 5.457 TB
                Power State        : Active

Storage

       Virtual Drives
                Virtual drive      : Target Id 0 ,VD name
                Size               : 232.375 GB
                State              : Optimal
                RAID Level         : 1

                Virtual drive      : Target Id 1 ,VD name
                Size               : 81.862 TB
                State              : Optimal
                RAID Level         : 5


Exit Code: 0x00
# check virutal disk / raid info
if [[ -f /opt/MegaRAID/MegaCli/MegaCli64 ]]; then
    raidlevel=`sudo /opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -aALL -NoLog | grep 'RAID Level' | awk -F ":" '{print $2}' | awk -F "," {'print $1}' | awk -F "-" '{print $2}'`
    disk_number=`sudo /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL -NoLog | egrep 'Device Id' | awk 'BEGIN {RS=""; FS="\n"} {print NF}'`
    disk_type=`sudo /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL -NoLog | egrep 'Media Type' | head -1 | awk -F ":" '{print $2}'`
else
    raidlevel="none"
    disk_number="none"
    disk_type="none"
fi

# test
[root@localhost wangao]# echo $raidlevel
1 5
[root@localhost wangao]# echo $disk_number
18
[root@localhost wangao]# echo $disk_type
Hard Disk Device

Ansible安装MegaCLi64

---
- hosts: all
  become: yes
  gather_facts: no

  tasks:
    - name: upload MegaCli64
      copy:
        src: files/MegaCli-8.07.14-1.noarch.rpm
        dest: /tmp/MegaCli-8.07.14-1.noarch.rpm
        
    - name: install MegaCli64 rpm from a local file
      yum:
        name: /tmp/MegaCli-8.07.14-1.noarch.rpm
        state: present
        
    - name: create symlink for MegaCli64
      file:
        src: /opt/MegaRAID/MegaCli/MegaCli64
        dest: /usr/sbin/MegaCli
        state: link

Ansible使用MegaCli64检查故障硬盘

---
- hosts: all
  become: yes
  gather_facts: no

  tasks:
    - name: Check Disk Status
      command: ./MegaCli64 -ShowSummary -aALL
      args:
        chdir: /opt/MegaRAID/MegaCli/
      register: result
    
    - name: Log check info
      lineinfile:
        dest: "{{inventory_dir}}/ansible.log"
        line: '[Ansiable Tasks: Disk Failure info] host={{inventory_hostname}}'
        insertafter: EOF 
        create: yes
      when: '"Failed" in result.stdout'
      delegate_to: localhost
      become: no

# check log
cat ansible.log
[Ansiable Tasks: Disk Failure info] host=10.71.12.89

相关文章

  • 使用MegaCli64快速查看RAID和定位故障硬盘实践

    前言 MegaCli 是 LSI 公司官方提供的 SCSI 卡管理工具,由于 LSI 被收购变成了现在的 Broa...

  • Linux_119_raid10故障修复

    当raid10故障了一块硬盘怎么办?1.模拟挂掉一块硬盘,从raid10的四块硬盘组中,剔除一块磁盘查看: fd...

  • linux磁盘排查总结

    storcli64 show all 查看raid信息 storcli64 /c0 show 查看硬件故障信息 =...

  • 周考(1)

    2019-04-03 1:简述常见的 raid 级别(4 分) 答:raid0 和 raid1 硬盘数量/性...

  • 【Linux基础】内存和硬盘管理

    1. 内存和硬盘使用率查看 查看内存使用率 常用命令:freetop 查看硬盘使用率 常用命令:fdiskfids...

  • linux添加硬盘

    使用 df -l 查看各个分区的挂载和使用情况; 使用 fdisk -l 查看目前的硬盘信息; 对新增硬盘分区并格...

  • 为什么说电缆故障测试仪必不可少

    电缆故障测试仪可以快速定位故障位置,使用效果更好。但是,在使用它来简化操作之前,您必须首先了解它。 GD-2133...

  • 常用 Linux 命令集(多图)

    1、df df 查看硬盘空间的使用情况 查看本机硬盘空间的使用情况: 2、du du 查看 目录 和 文件 所占磁...

  • Apply Raid in vSAN

    什么是RAID 独立硬盘冗余阵列(RAID, Redundant Array of Independent Dis...

  • 运维命令记录

    通过命令行获取硬件信息: 型号: CPU信息: 内存信息: raid卡信息: 硬盘信息: 查看磁盘的错误日志: 查...

网友评论

      本文标题:使用MegaCli64快速查看RAID和定位故障硬盘实践

      本文链接:https://www.haomeiwen.com/subject/vsiwlctx.html