感谢支持
我们一直在努力

Centos7如何查看RAID,管理阵列卡。MegaCli命令使用详解

一、MegaCli命令介绍

MegaCli是一款管理维护硬件RAID软件,可以用来查看raid信息等
MegaCli 的Media Error Count: 0 Other Error Count: 0
Medai Error Count 表示磁盘可能错误,可能是磁盘有坏道,这个值不为0值得注意,数值越大,危险系数越高,
Other Error Count 表示磁盘可能存在松动,可能需要重新再插入。MegaCli 可以对阵列中所有的磁盘进行检测

二、安装过程

1、系统环境

dmidecode -t1 | egrep “Manufacturer|Product Name”
cat /etc/redhat-release
查看厂商和产品型号,以及”Serial Number”

2、下载和安装

rpm -qa | egrep ‘Lib_Utils|MegaCli’ //检查是否安装

https://raw.githubusercontent.com/crazy-zhangcong/tools/master/MegaCli8.07.10.tar.gz

下载地址:https://pan.baidu.com/s/1TAGHjTA19ZR8MGODaqy7Mg   提取密码:msbq

2.1 进行解压安装操作

[root@localhost ~]# wget https://raw.githubusercontent.com/crazy-zhangcong/tools/master/MegaCli8.07.10.tar.gz
--2019-02-26 16:04:43--  https://raw.githubusercontent.com/crazy-zhangcong/tools/master/MegaCli8.07.10.tar.gz
Resolving raw.githubusercontent.com... 151.101.128.133, 151.101.64.133, 151.101.0.133, ...
Connecting to raw.githubusercontent.com|151.101.128.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4148077 (4.0M) [application/octet-stream]
Saving to: “MegaCli8.07.10.tar.gz”
 
100%[=============================================================================================>] 4,148,077    520K/s   in 8.1s    
 
2019-02-26 16:04:52 (500 KB/s) - “MegaCli8.07.10.tar.gz” saved [4148077/4148077]
 
[root@localhost ~]# ls
anaconda-ks.cfg  install.log  install.log.syslog  MegaCli8.07.10.tar.gz  Python-2.7.8.tgz  test.txt
[root@localhost ~]# tar -xvf MegaCli8.07.10.tar.gz
MegaCli8.07.10/
MegaCli8.07.10/Linux/
MegaCli8.07.10/Linux/Lib_Utils-1.00-09.noarch.rpm
MegaCli8.07.10/Linux/MegaCli-8.02.21-1.noarch.rpm
MegaCli8.07.10/Linux/readme.txt
MegaCli8.07.10/Linux/Run-Linux-PERC.sh
MegaCli8.07.10/WINDOWS/
MegaCli8.07.10/WINDOWS/MegaCli.exe
MegaCli8.07.10/WINDOWS/MegaCli64.exe
MegaCli8.07.10/WINDOWS/readme.txt
MegaCli8.07.10/WINDOWS/X64.bat
MegaCli8.07.10/WINDOWS/X86.bat
[root@localhost ~]# ls
anaconda-ks.cfg  install.log  install.log.syslog  MegaCli8.07.10  MegaCli8.07.10.tar.gz  Python-2.7.8.tgz  test.txt
[root@localhost ~]# cd MegaCli8.07.10/Linux/
[root@localhost Linux]# ls
Lib_Utils-1.00-09.noarch.rpm  MegaCli-8.02.21-1.noarch.rpm  readme.txt  Run-Linux-PERC.sh
[root@localhost Linux]#  rpm -ivh Lib_Utils-1.00-09.noarch.rpm MegaCli-8.02.21-1.noarch.rpm
Preparing...                ########################################### [100%]
Installing....
   1:Lib_Utils              ########################################### [ 50%]
   2:MegaCli                ########################################### [100%]

说明:安装完毕之后MegaCli64所在路径为/opt/MegaRAID/MegaCli/MegaCli64,在此路径下可以运行MegaCli64工具,切换到其它路径下则不能执行,此时为了使用方便,可以考虑将/opt/MegaRAID/MegaCli/MegaCli64追加到系统PATH变量,或者像下面这样做(建议):

  1. [root@localhost Linux]# ln s /opt/MegaRAID/MegaCli/MegaCli64 /bin/MegaCli64
  2. [root@localhost Linux]# ln s /opt/MegaRAID/MegaCli/MegaCli64 /sbin/MegaCli64

 2.2 查看硬盘数量

  1. [root@localhost ~]# MegaCli64 PDList aALL | egrep ‘Enclosure Device ID|Slot Number’
  2. Enclosure Device ID: 32
  3. Slot Number: 0
  4. Enclosure Device ID: 32
  5. Slot Number: 1
  6. Enclosure Device ID: 32
  7. Slot Number: 2
  8. Enclosure Device ID: 32
  9. Slot Number: 3
  10. Enclosure Device ID: 32
  11. Slot Number: 4
  12. Enclosure Device ID: 32
  13. Slot Number: 5
  14. Enclosure Device ID: 32
  15. Slot Number: 6
  16. Enclosure Device ID: 32
  17. Slot Number: 7
  18. Enclosure Device ID: 32
  19. Slot Number: 8
  20. Enclosure Device ID: 32
  21. Slot Number: 9
  22. Enclosure Device ID: 32
  23. Slot Number: 10
  24. Enclosure Device ID: 32
  25. Slot Number: 11
  26. Enclosure Device ID: 32
  27. Slot Number: 12
  28. Enclosure Device ID: 32
  29. Slot Number: 13 

三、硬盘命令使用

1、常用查询命令

  1. /opt/MegaRAID/MegaCli/MegaCli64 LDInfo Lall aALL 【查raid级别】
  2. /opt/MegaRAID/MegaCli/MegaCli64 AdpAllInfo aALL 【查raid卡信息】
  3. /opt/MegaRAID/MegaCli/MegaCli64 PDList aALL 查看【硬盘信息】
  4. /opt/MegaRAID/MegaCli/MegaCli64 AdpBbuCmd aAll 【查看电池信息】
  5. /opt/MegaRAID/MegaCli/MegaCli64 FwTermLog Dsply aALL 【查看raid卡日志】
  6. /opt/MegaRAID/MegaCli/MegaCli64 adpCount 【显示适配器个数】
  7. /opt/MegaRAID/MegaCli/MegaCli64 AdpGetTime aALL 【显示适配器时间】
  8. /opt/MegaRAID/MegaCli/MegaCli64 AdpAllInfo aAll 【显示所有适配器信息】
  9. /opt/MegaRAID/MegaCli/MegaCli64 LDInfo LALL aAll 【显示所有逻辑磁盘组信息】
  10. /opt/MegaRAID/MegaCli/MegaCli64 PDList aAll 【显示所有的物理信息】
  11. /opt/MegaRAID/MegaCli/MegaCli64 AdpBbuCmd GetBbuStatus aALL |grep Charger Status 【查看充电状态】
  12. /opt/MegaRAID/MegaCli/MegaCli64 AdpBbuCmd GetBbuStatus aALL【显示BBU状态信息】
  13. /opt/MegaRAID/MegaCli/MegaCli64 AdpBbuCmd GetBbuCapacityInfo aALL【显示BBU容量信息】
  14. /opt/MegaRAID/MegaCli/MegaCli64 AdpBbuCmd GetBbuDesignInfo aALL 【显示BBU设计参数】
  15. /opt/MegaRAID/MegaCli/MegaCli64 AdpBbuCmd GetBbuProperties aALL 【显示当前BBU属性】
  16. /opt/MegaRAID/MegaCli/MegaCli64 cfgdsply aALL 【显示Raid卡型号,Raid设置,Disk相关信息】
  17. /opt/MegaRAID/MegaCli/MegaCli64 -LdPdInfo -aAll -NoLog | grep -iE “^Adapter|^Number of Virtual Disks|^Span:|Primary|^state|^Enclosure Device ID|^Slot|DiskGroup|^Raw” 【查看硬盘健康状态】

2、查看磁盘缓存策略

  1. /opt/MegaRAID/MegaCli/MegaCli64 LDGetProp Cache L0 a0【显示0 RAID 0 RAID组的缓存策略
  2. /opt/MegaRAID/MegaCli/MegaCli64 LDGetProp Cache L1 a0【显示1 RAID 0 RAID组的缓存策略】
  3. /opt/MegaRAID/MegaCli/MegaCli64 LDGetProp Cache LALL a0【显示所有RAID 0 RAID组的缓存策略】
  4. /opt/MegaRAID/MegaCli/MegaCli64 LDGetProp Cache LALL aALL【显示所有 RAID 所有 RAID组的缓存策略】
  5. /opt/MegaRAID/MegaCli/MegaCli64 LDGetProp DskCache LALL aALL

设置磁盘的缓存模式和访问方式 (Change Virtual Disk Cache and Access Parameters)

  1. Description Allows you to change the following virtual disk parameters:
  2. WT (Write through), WB (Write back): Selects write policy.
  3. NORA (No read ahead), RA (Read ahead), ADRA (Adaptive read ahead): Selects read policy.
  4. Cached, Direct: Selects cache policy.
  5. RW, RO, Blocked: Selects access policy.
  6. EnDskCache: Enables disk cache.
  7. DisDskCache: Disables disk cache.
  8. MegaCli LDSetProp { WT | WB|NORA |RA | ADRA|-Cached|Direct} |
  9. {-RW|RO|Blocked} |
  10. {-Name[string]} |
  11. {-EnDskCache|DisDskCache} Lx |
  12. L0,1,2|-Lall aN|-a0,1,2|-aALL
  13. MegaCli LDSetProp WT L0 a0

 

3、设置磁盘缓存策略

  1. 显示磁盘缓存和访问方式(Display Virtual Disk Cache and Access Parameters
  2.  
  3. MegaCli LDGetProp Cache | Access | Name | DskCache Lx|-L0,1,2|
  4. Lall aN|-a0,1,2|-aALL
  5. Displays the cache and access policies of the virtual disk(s):
  6. WT (Write through), WB (Write back): Selects write policy.
  7. NORA (No read ahead), RA (Read ahead), ADRA (Adaptive read ahead): Selects read policy.
  8. Cache, Cached, Direct: Displays cache policy.
  9. Access, RW, RO, Blocked: Displays access policy.
  10. DskCache: Displays physical disk cache policy.
  11. 缓存策略解释:
  12.  
  13. WT (Write through)
  14. WB (Write back)
  15. NORA (No read ahead)
  16. RA (Read ahead)
  17. ADRA (Adaptive read ahead)
  18. C (Cached)
  19. D (Direct)
  20. 例子:
  21. /opt/MegaRAID/MegaCli/MegaCli64 LDSetProp WT|WB|NORA|RA|ADRA L0 a0
  22. /opt/MegaRAID/MegaCli/MegaCli64 LDSetProp Cached|-Direct L0 a0
  23. enable / disable disk cache
  24. /opt/MegaRAID/MegaCli/MegaCli64 LDSetProp EnDskCache|-DisDskCache L0 a0

 

4、创建阵列

  1. 创建一个raid5阵列,由物理盘2,3,4构成,该阵列的热备盘是物理盘5
  2. /opt/MegaRAID/MegaCli/MegaCli64 CfgLdAdd r5 [1:2,1:3,1:4] WB Direct Hsp[1:5] a0
  3. 创建阵列,不指定热备
  4. /opt/MegaRAID/MegaCli/MegaCli64 CfgLdAdd r5 [1:2,1:3,1:4] WB Direct a0
  5. 创建一个raid10阵列,由物理盘2,34,5分别做raid1,在将两组raid1raid0
  6. /opt/MegaRAID/MegaCli/MegaCli64 CfgSpanAdd r10 Array0[1:2,1:3] Array1[1:4,1:5] WB Direct a0

5、删除阵列

  1. /opt/MegaRAID/MegaCli/MegaCli64 CfgLdDel L1 a0

6、在线添加磁盘

  1. /opt/MegaRAID/MegaCli/MegaCli64 LDRecon Start r5 Add PhysDrv[1:4] L1 a0

7、阵列创建完后,会有一个初始化同步块的过程,可以看看其进度。

  1. /opt/MegaRAID/MegaCli/MegaCli64 LDInit ShowProg LALL aALL
  2. 或者以动态可视化文字界面显示
  3. /opt/MegaRAID/MegaCli/MegaCli64 LDInit ProgDsply LALL aALL

8、查看阵列后台初始化进度

  1. /opt/MegaRAID/MegaCli/MegaCli64 LDBI ShowProg LALL aALL
  2. 或者以动态可视化文字界面显示
  3. /opt/MegaRAID/MegaCli/MegaCli64 LDBI ProgDsply LALL aALL

9、指定第5块盘作为全局热备

  1. /opt/MegaRAID/MegaCli/MegaCli64 PDHSP Set [-EnclAffinity] [-nonRevertible] PhysDrv[1:5] a0

10、指定为某个阵列的专用热备

  1. /opt/MegaRAID/MegaCli/MegaCli64 PDHSP Set [-Dedicated [-Array1]] [-EnclAffinity] [-nonRevertible] PhysDrv[1:5] a0

11、删除全局热备

  1. /opt/MegaRAID/MegaCli/MegaCli64 PDHSP Rmv PhysDrv[1:5] a0

12、将某块物理盘下线/上线

  1. /opt/MegaRAID/MegaCli/MegaCli64 PDOffline PhysDrv [1:4] a0
  2. /opt/MegaRAID/MegaCli/MegaCli64 PDOnline PhysDrv [1:4] a0

13、查看物理磁盘重建进度

  1. /opt/MegaRAID/MegaCli/MegaCli64 PDRbld ShowProg PhysDrv [1:5] a0
  2. 或者以动态可视化文字界面显示
  3. /opt/MegaRAID/MegaCli/MegaCli64 PDRbld ProgDsply PhysDrv [1:5] a0

14、磁盘状态的变化,从拔盘,到插盘过程中

  1. Device |Normal|Damage|Rebuild|Normal
  2. Virtual Drive |Optimal|Degraded|Degraded|Optimal
  3. Physical Drive |Online|Failed –> Unconfigured|Rebuild|Online

四、其他命令说明

1、当前raid缓存状态,raid缓存状态设置为wb的话要注意电池放电事宜,设置电池放电模式为自动学习模式

  1. /opt/MegaRAID/MegaCli/MegaCli64 ldgetprop dskcache lall aall

2、电池设置相关

查看电池状态信息(Display BBU Status Information)

  1. MegaCli AdpBbuCmd GetBbuStatus aN|-a0,1,2|-aALL
  2. MegaCli AdpBbuCmd GetBbuStatus aALL

查看电池容量(Display BBU Capacity Information)

  1. MegaCli AdpBbuCmd GetBbuCapacityInfo aN|-a0,1,2|-aALL
  2. MegaCli AdpBbuCmd GetBbuCapacityInfo aALL

查看电池设计参数(Display BBU Design Parameters)

  1. MegaCli AdpBbuCmd GetBbuDesignInfo aN|-a0,1,2|-aALL
  2. MegaCli AdpBbuCmd GetBbuDesignInfo aALL

查看电池属性(Display Current BBU Properties)

  1. MegaCli AdpBbuCmd GetBbuProperties aN|-a0,1,2|-aALL
  2. MegaCli AdpBbuCmd GetBbuProperties aALL

设置电池为学习模式为循环模式(Start BBU Learning Cycle)

  1. Description Starts the learning cycle on the BBU.
  2. No parameter is needed for this option.
  3. MegaCli AdpBbuCmd BbuLearn aN|-a0,1,2|-aALL

3、通过脚本检测RAID 磁盘状态

  1. MEGACLI=“/opt/MegaRAID/MegaCli/MegaCli64 “
  2. $MEGACLI pdlist aALL | grep “Firmware state” | awk F : ‘{print $2}’ | awk F , ‘{print $1}’
  3. $MEGACLI pdlist aALL | grep E “Media Error|Other Error” | awk F : ‘{print $2}’

4、raid图解

图1、图2

赞(3) 打赏
转载请注明出处:服务器评测 » Centos7如何查看RAID,管理阵列卡。MegaCli命令使用详解
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏