柴少的官方网站 技术在学习中进步,水平在分享中升华

MegaCLI 工具的使用

一、Megacli介绍

工作中偶尔会用到MegaCli这个工具,之前的博文里面也提到过这个工具,这里对于用法详细的记录一下。

通过LSI公司提供的MegaCli工具, 可以实现对RAID卡和硬盘的监控。

2013年12月: Avago公司以66亿美元收购LSI,2015年5月: Avago公司以370亿美元收购博通,因为MegaCLI 工具原来是LSI的,所以现在官方的下载地址也发生了变化。

1.1、下载与安装

线上使用的工具一定要确保来源的安全,尽量官网下载,虽然可能在找的时候稍微有点麻烦。如果有些技巧的话,可能会稍快,下面说两种方式。

第一个下载方式:

http://www.dell.com/support/article/cn/zh/cndhs1/SLN292232  #通过dell官网进行搜索找到包含有下载链接的页面

blob.png

www.avagotech.com/docs-and-downloads/raid-controllers/raid-controllers-common-files/8-07-14_MegaCLI.zip  #最新版本下载地址

第二种下载方式:

https://www.broadcom.com/support/download-search #进入官网搜索页面,这是官网跳转过来的搜索页面

blob.png

blob.png

blob.png

好了安装包已经下载下来了,这个zip包里面有不同系统的目录,我们找到Linux目录。

# rpm -ivh Linux/MegaCli-8.07.14-1.noarch.rpm  #安装一下软件

# rpm -qa|grep MegaCli  #查看包已经安装成功

MegaCli-8.07.14-1.noarch

# /opt/MegaRAID/MegaCli/MegaCli64 -help  #可以查看版本以及相关的命令使用说明。默认命令装在了:/opt/MegaRAID/MegaCli/MegaCli64这里

#/opt/MegaRAID/MegaCli/MegaCli64  -cfgdsply -aALL|grep 'Product Name'  #通过命令可以看出我们的RAID卡的型号为:PERC H730 Mini

Product Name: PERC H730 Mini

二、MegaCli命令罗列

#/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -aALL  #查看raid级别

#/opt/MegaRAID/MegaCli/MegaCli64 -AdpAllInfo -aALL #查看raid卡信息

#/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL #查看硬盘信息

#/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -aAll #查看电池信息

#/opt/MegaRAID/MegaCli/MegaCli64 -FwTermLog -Dsply -aALL #查看raid卡日志

#/opt/MegaRAID/MegaCli/MegaCli64 -adpCount #显示适配器个数

#/opt/MegaRAID/MegaCli/MegaCli64 -AdpGetTime –aALL #显示适配器时间

#/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -LALL -aAll  #显示所有逻辑磁盘组信息

#/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuStatus -aALL |grep 'Charger Status' #查看电池充电状态

#/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuStatus -aALL #显示BBU状态信息

#/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuCapacityInfo -aALL #显示BBU容量信息

#/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuDesignInfo -aALL #显示BBU设计参数

#/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuProperties -aALL #显示当前BBU属性

#/opt/MegaRAID/MegaCli/MegaCli64 -cfgdsply -aALL #显示raid卡型号,raid设置,disk相关信息

博文来自:www.51niux.com

三、常用命令详解

3.1 查看磁盘是否有问题:

#/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL|grep Error 

#这是查看所有磁盘信息的命令,然后grep错误信息,看下面过滤出来的信息,这是我一个R720的机器,有个磁盘有问题准备要更换呢。Media Error Count: 0 Other Error Count: 0 这两个数值来确定阵列中磁盘是否有问题;Medai Error Count 表示磁盘可能错误,可能是磁盘有坏道,这个值不为0值得注意,数值越大,危险系数越高,Other Error Count 表示磁盘可能存在松动,可能需要重新再插入。

Media Error Count: 0
Other Error Count: 1
Media Error Count: 98139
Other Error Count: 26672
Media Error Count: 0
Other Error Count: 0
Media Error Count: 0
Other Error Count: 0
Media Error Count: 0
Other Error Count: 0
Media Error Count: 0
Other Error Count: 0
Media Error Count: 0
Other Error Count: 0
Media Error Count: 4
Other Error Count: 68
Media Error Count: 0
Other Error Count: 1
Media Error Count: 0
Other Error Count: 0
Media Error Count: 2872
Other Error Count: 20
Media Error Count: 0
Other Error Count: 0

#当然实际生产环境中,如果想长期的检查磁盘是否可能要出问题了,还是建议去/var/log/message里面去检测信息,因为用MegaCli这种方式检测硬盘,当然硬盘出问题了可以报出来,但是就算你换了硬盘,再次检测会发现计数器还是没有清零,这是因为raid缓存的问题,但是这个问题需要重启服务器才能解决,所以说用这种方式做一个常规性的监控方式的话,这个问题还是要考虑进来的。

3.2 查看磁盘的缓存策略

#/opt/MegaRAID/MegaCli/MegaCli64 -LDGetProp -Cache -L0 -a0    #我这是DELLR730XD的服务器                                

Adapter 0-VD 0(target id: 0): Cache Policy:WriteBack, ReadAhead, Direct, No Write Cache if bad BBU

#L0表示磁盘组0, a0表示适配器号

#/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -LAll -aAll|grep 'Target'

Virtual Drive: 0 (Target Id: 0)
Virtual Drive: 1 (Target Id: 1)
Virtual Drive: 2 (Target Id: 2)
Virtual Drive: 3 (Target Id: 3)
Virtual Drive: 4 (Target Id: 4)
Virtual Drive: 5 (Target Id: 5)
Virtual Drive: 6 (Target Id: 6)
Virtual Drive: 7 (Target Id: 7)
Virtual Drive: 8 (Target Id: 8)
Virtual Drive: 9 (Target Id: 9)
Virtual Drive: 10 (Target Id: 10)
Virtual Drive: 11 (Target Id: 11)

#下面是查看适配器的命令:

#/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL|grep Adapter

Adapter #0

#结果为0,第一块raid卡适配器就为0,一般服务器就一个raid适配器,所以一般都是a0。

#/opt/MegaRAID/MegaCli/MegaCli64 -LDGetProp -Cache -LALL -aALL  # 查看所有磁盘的缓存策略 ,我这是十二块硬盘                                

Adapter 0-VD 0(target id: 0): Cache Policy:WriteBack, ReadAhead, Direct, No Write Cache if bad BBU
Adapter 0-VD 1(target id: 1): Cache Policy:WriteBack, ReadAhead, Direct, No Write Cache if bad BBU
Adapter 0-VD 2(target id: 2): Cache Policy:WriteBack, ReadAhead, Direct, No Write Cache if bad BBU
Adapter 0-VD 3(target id: 3): Cache Policy:WriteBack, ReadAhead, Direct, No Write Cache if bad BBU
Adapter 0-VD 4(target id: 4): Cache Policy:WriteBack, ReadAhead, Direct, No Write Cache if bad BBU
Adapter 0-VD 5(target id: 5): Cache Policy:WriteBack, ReadAhead, Direct, No Write Cache if bad BBU
Adapter 0-VD 6(target id: 6): Cache Policy:WriteBack, ReadAhead, Direct, No Write Cache if bad BBU
Adapter 0-VD 7(target id: 7): Cache Policy:WriteBack, ReadAhead, Direct, No Write Cache if bad BBU
Adapter 0-VD 8(target id: 8): Cache Policy:WriteBack, ReadAhead, Direct, No Write Cache if bad BBU
Adapter 0-VD 9(target id: 9): Cache Policy:WriteBack, ReadAhead, Direct, No Write Cache if bad BBU
Adapter 0-VD 10(target id: 10): Cache Policy:WriteBack, ReadAhead, Direct, No Write Cache if bad BBU
Adapter 0-VD 11(target id: 11): Cache Policy:WriteBack, ReadAhead, Direct, No Write Cache if bad BBU

#/opt/MegaRAID/MegaCli/MegaCli64 -LDGetProp -Cache -L0 -a0      #不同型号的服务器默认缓存策略也是不一样的,我这是dell FX2的服务器                    

Adapter 0-VD 0(target id: 0): Cache Policy:WriteThrough, ReadAheadNone, Direct, No Write Cache if bad BBU

#输出内容表示的意思:Adapter 0-VD 0(target id: 0):  为磁盘适配器号,0代表第一个,Cache Policy:后面是缓存策略

一:WriteBack与WriteThrough
1.WriteBack:进行写操作时,将数据写入RAID卡缓存,并直接返回,RAID卡控制器将在系统负载低或者Cache满了的情况下把数据写 入 硬盘。该设置会大大提升RAID卡写性能,绝大多数的情况下会降低系统IO负载。 数据的可靠性由BBU(Battery Backup Unit)电池 进行保证
2.WriteThrough: 数据写操作不使用缓存,数据直接写入磁盘。RAID卡写性能下降,在大多数情况下该设置会造成系统IO负载上升; 

二: ReadAheadNone, ReadAdaptive, ReadAhead.
ReadAheadNone: 不开启预读。这是默认的设置
ReadAhead: 在读操作时,预先把后面顺序的数据加载入Cache,在顺序读取时,能提高性能,相反会降低随机读的性能。
ReadAdaptive: 自适应预读,当Cache memory和IO空闲时,采取顺序预读,平衡了连续读性能及随机读的性能,需要消耗一定的计算能力。

三、WT(Write through),WB(Write back),NORA(No read ahead),RA(Read ahead),ADRA(Adaptive read ahead),Cached,Direct

Write Policy(写入策略) 将高速缓存方法设置为回写或通过写。

* 在Write-through(通过写)高速缓存中,当磁盘子系统已接收到一个事务中的所有数据时,该控制器将数据传输完成信号发送给主机。

* 在Write-back(回写)高速缓存中,当控制器高速缓存已接收到某个事务中的所有数据时,该控制器将数据传输完成信号发送给主机。

Read-ahead(预读)启用逻辑驱动器的SCSI预读功能。 可将此参数设为No-Read-Ahead(非预读)、Read-ahead(预读)或Adaptive(自适应)。 默认设置为Adaptive(自适应)。

* No-Read-Ahead(非预读)指定控制器在当前逻辑驱动器中不使用预读方式。

* Read-ahead(预读)在读操作时,预先把后面顺序的数据加载入Cache,在顺序读取时,能提高性能,相反会降低随机读的性能。

* Adaptive(自适应)指定如果最近两次的磁盘访问出现在连续的扇区内,则控制器开始采用Read-ahead(预读)。 如果所有的读取请求都是随机的,则该算法回复到No-Read-Ahead(非预读),但仍要判断所有的读取请求是否有按顺序操作的可能。当Cache memory和IO空闲时,采取顺序预读,平衡了连续读性能及随机读的性能,需要消耗一定的计算能力。

Cache Policy(高速缓存策略) 适合在特定逻辑驱动器上读取。 它并不影响Read ahead(预读)高速缓存。
* Cached I/O(高速缓存I/O)指定所有读取数据在高速缓存存储器中缓存。
* Direct I/O(直接I/O)指定读取数据不在高速缓存存储器中缓存。 此为默认设置。 它不会代替高速缓存策略设置。数据被同时传送到高速缓存和主机。 如果再次读取同一数据块,则从高速缓存存储器读取

四、Write Cache OK if Bad BBU和 No Write Cache if Bad BBU

No Write Cache if Bad BBU: 如果BBU出问题,则关闭Write Cache。由WriteBack自动切换到WriteThrough模式。如果没有特殊要求,强烈建议采用该设置,以确保数据的安全。

Write Cache OK if Bad BBU: 如果BBU出问题,依然启用Write Cache. 这是不推荐的设置,BBU出问题将无法保证断电情况下数据的正常,如果此时依然采用WriteBack模式,遇到断电将发生数据丢失。除非有UPS作额外保证,不然不推荐采用这个设置。

博文来自:www.51niux.com

3.3 RAID卡策略的更改

修改WriteBack:

/opt/MegaRAID/MegaCli/MegaCli64 -LDSetProp -WB -Lall -aAll

修改WriteThrough:

/opt/MegaRAID/MegaCli/MegaCli64 -LDSetProp -WT -Lall -aAll

修改No Write Cache if Bad BBU:

/opt/MegaRAID/MegaCli/MegaCli64 -LDSetProp -NoCachedBadBBU -Lall -aAll

修改Write Cache OK if Bad BBU:

/opt/MegaRAID/MegaCli/MegaCli64 -LDSetProp -CachedBadBBU -Lall -aAll

或者其他:

/opt/MegaRAID/MegaCli/MegaCli64 -LDSetProp WT|WB|NORA|RA|ADRA -L0 -a0

/opt/MegaRAID/MegaCli/MegaCli64 -LDSetProp -Cached|-Direct -L0 -a0

3.4 在线创建raid阵列,删除阵列,查看进度

创建一个raid5阵列,由物理盘号为,3,4,5构成,该阵列的热备盘是物理盘号6:

/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r5 [32:3,32:4,32:5] WB Direct -Hsp[32:6] -a0 

#r5代表的就是raid5,[32:5]里面32代表的是Enclosure Device ID,5代表的是Slot Number,WB和Direct缓存策略前面提到了,Hsp[32:6] 指定第七块物理硬盘为热备盘,a0表示陈列卡号。


在线更换raid0硬盘,原硬盘损坏。如盘号为5的硬盘损坏之前做了raid0,现在更换之后需要对新硬盘做raid0:

/opt/MegaRAID/MegaCli/MegaCli64  -DiscardPreservedCache -L5 -a0 

#如果全是单盘raid0的话,清空磁盘组5的一般是第六块物理硬盘的raid缓存,不然就要重启服务器生效,L5是通过MegaCli64 -LDInfo -Lall -aALL得到的raid组对应的ID号,如Virtual Drive: 5 (Target Id: 5),ID号是从0开始的。

#/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r0 [32:5] -a0 #将盘号为5的硬盘做成raid0模式,其他参数使用默认。

清空所有的缓存:(一般不要这么干)

#/opt/MegaRAID/MegaCli/MegaCli64 -DiscardPreservedCache -Lall -a0 -NoLOG

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

#/opt/MegaRAID/MegaCli/MegaCli64 -LDInit -ShowProg -LALL -aALL

以动态可视化文字界面显示 :

#/opt/MegaRAID/MegaCli/MegaCli64 -LDInit -ProgDsply -LALL –aALL 

查看阵列后台初始化进度 :

#/opt/MegaRAID/MegaCli/MegaCli64 -LDBI -ShowProg -LALL -aALL 

以动态可视化文字界面显示 :

#/opt/MegaRAID/MegaCli/MegaCli64 -LDBI -ProgDsply -LALL -aALL 

查看某个物理磁盘重建进度:

#/opt/MegaRAID/MegaCli/MegaCli64 -PDRbld -ShowProg -PhysDrv [32:5] -a0

以动态可视化文字界面显示:

#/opt/MegaRAID/MegaCli/MegaCli64 -PDRbld -ProgDsply -PhysDrv [32:5] -a0

删除raid阵列:

#/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdDel -L5 -a0  #删除阵列

3.5 其他的一些raid操作

指定第 5 块盘作为全局热备
#/opt/MegaRAID/MegaCli/MegaCli64 -PDHSP -Set [-EnclAffinity] [-nonRevertible] -PhysDrv[32:5] -a0

指定为某个阵列的专用热备
#/opt/MegaRAID/MegaCli/MegaCli64 -PDHSP -Set [-Dedicated [-Array1]] [-EnclAffinity] [-nonRevertible] -PhysDrv[32:5] -a0

删除全局热备
#/opt/MegaRAID/MegaCli/MegaCli64 -PDHSP -Rmv -PhysDrv[32:5] -a0

将某块物理盘下线/上线
#/opt/MegaRAID/MegaCli/MegaCli64 -PDOffline -PhysDrv [32:4] -a0
#/opt/MegaRAID/MegaCli/MegaCli64 -PDOnline -PhysDrv [32:4] -a0

手工配置初始化

#/opt/MegaRAID/MegaCli/MegaCli64 -LDInit  -start –L0  -a0               #快速初始化

#/opt/MegaRAID/MegaCli/MegaCli64 -LDInit  -start  -full –L0 -a0        #完全初始化

#/opt/MegaRAID/MegaCli/MegaCli64 -LDInit  -progdsply -L0 -a0        #显示初始化的进度

#/opt/MegaRAID/MegaCli/MegaCli64 -LDInit  -abort  -L0  -a0               #结束完全初始化

raid电池操作:

#/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -BbuLearn a0  #手动充电

#/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuStatus -aALL #查看充电状态

#/opt/MegaRAID/MegaCli/MegaCli64 -AdpBbuCmd -GetBbuStatus -aALL #查看充电进度百分比

查看raid陈列中掉线的硬盘:

#/opt/MegaRAID/MegaCli/MegaCli64 -pdgetmissing -a0

查看Megacli的log

#/opt/MegaRAID/MegaCli/MegaCli64 -FwTermLog dsply -a0 > /tmp/Megacli.log

博文来自:www.51niux.com

3.6 查看磁盘的raid级别

RAID Level对应关系:

RAID Level : Primary-1, Secondary-0, RAID Level Qualifier-0   #RAID 1

RAID Level : Primary-0, Secondary-0, RAID Level Qualifier-0   #RAID 0

RAID Level : Primary-5, Secondary-0, RAID Level Qualifier-3   #RAID 5

如何判断一块硬盘是否做了raid呢?

#(新的机器可以通过下面命令来判断,之前的不太清楚,应为raid0和不做raid显示的信息很难判断)

#/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -LAll -aAll|grep 'Is VD emulated'

Is VD emulated      : No   #No就是没做raid

#/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -LAll -aAll|grep 'Is VD emulated'

Is VD emulated      : Yes  #yes就是做了raid

#如果是旧的服务器,如果我们上线服务器之前都会配置raid的话,一般会有名字,所以可以根据(但是这种方式也不是绝对的,可能不设置名称):

#/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -LAll -aAll|grep Name  

Name                :raid1 #有名字的说明做了raid系统
Name                :  #没有名字的说明就是一块裸盘
Name                :
Name                :
Name                :
Name                :

博文来自:www.51niux.com

3.7 如何判断磁盘的raid级别:

双盘做了raid1的举例:

#/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -LAll -aAll                              

Adapter 0 -- Virtual Drive Information:
Virtual Drive: 0 (Target Id: 0)
Name                :raid1
RAID Level          : Primary-1, Secondary-0, RAID Level Qualifier-0  #通过RAID Level可以看到这是raid1的盘
Size                : 278.875 GB  #磁盘大小为300G
State               : Optimal  #最佳状态
Strip Size          : 64 KB
Number Of Drives    : 2  #2 说明是两块盘组成
Span Depth          : 1  #说明实际只是raid 1

全盘做了raid5的举例:

#/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -LAll -aAll                                     

Adapter 0 -- Virtual Drive Information:
Virtual Drive: 0 (Target Id: 0)
Name                :raid5
RAID Level          : Primary-5, Secondary-0, RAID Level Qualifier-3  #通过RAID Level  可以看出这是raid5
Size                : 60.032 TB #总大小60T
Sector Size         : 512
Is VD emulated      : Yes  
Parity Size         : 5.457 TB #单盘大小是6T
State               : Optimal
Strip Size          : 64 KB
Number Of Drives    : 12  #由12块盘组成
Span Depth          : 1  #深度为1

注:如果是做了热备盘的情况呢,再最下面会有两行信息:
Number of Dedicated Hot Spares: 1  #有1块盘做了热备
    0 : EnclId - 32 SlotId - 11   #[32:11]盘做的热备

raid10的举例:

#/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -LAll -aAll

Virtual Drive: 1 (Target Id: 1)
Name                :raid10-01
RAID Level          : Primary-1, Secondary-0, RAID Level Qualifier-0
Size                : 556.929 GB  #总大小600G
State               : Optimal
Strip Size          : 64 KB
Number Of Drives per span:2  #表示每2个物理盘做成一个RAID1盘组
Span Depth          : 2 #2个RAID1盘组做成了RAID10

3.8 raid的各种创建

对一台R720XD的服务器做下RAID演示一下(单盘2T,12个插槽):

blob.png

#这块服务器的特性就是不做硬盘不做raid,系统识别不到硬盘。

[root@localhost Linux]# /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL |egrep  "Enclosure Device ID|Slot Number" 

#用命令查看一下可以看出,Enclosure Device ID为32,Slot Number是从0到11,也就是12块盘。

Enclosure Device ID: 32
Slot Number: 0
Enclosure Device ID: 32
Slot Number: 1
Enclosure Device ID: 32
Slot Number: 2
Enclosure Device ID: 32
Slot Number: 3
Enclosure Device ID: 32
Slot Number: 4
Enclosure Device ID: 32
Slot Number: 5
Enclosure Device ID: 32
Slot Number: 6
Enclosure Device ID: 32
Slot Number: 7
Enclosure Device ID: 32
Slot Number: 8
Enclosure Device ID: 32
Slot Number: 9
Enclosure Device ID: 32
Slot Number: 10
Enclosure Device ID: 32
Slot Number: 11

下面我们先对第三块盘,创建一个raid0.

# /opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r0 [32:2] -a0                                     

Adapter 0: Created VD 1
Adapter 0: Configured the Adapter!!
Exit Code: 0x00

下面我们先对第四块和第五块盘,创建一个raid1

# /opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r1 [32:3,32:4] -a0                                    

Adapter 0: Created VD 2
Adapter 0: Configured the Adapter!!
Exit Code: 0x00

下面我们再对第6,7,8块盘,创建一个raid5

# /opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r5 [32:5,32:6,32:7] -a0                                     

Adapter 0: Created VD 3
Adapter 0: Configured the Adapter!!
Exit Code: 0x00

下面我们再对第9,10,11,12块盘,创建一个raid10

# /opt/MegaRAID/MegaCli/MegaCli64 -CfgSpanAdd -r10 -Array0[32:8,32:9] -Array1[32:10,32:11] -a0                                    

Adapter 0: Created VD 4
Adapter 0: Configured the Adapter!!
Exit Code: 0x00

blob.png

#从上图可以看出,我们做的raid级别

#第一个是raid1

#第二个是raid0

#第三个是raid1

#第四个是raid5

#第五个是raid10

3.9 删除RAID卷组实操演示:

# /opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -aALL   #首先先查看一下我们的系统RAID状态。

Virtual Drive: 1 (Target Id: 1)   #带有Target标记的,Id:1,这个1就是我们所要删除的raid组的号。

# umount /data/  #这个raid是挂载到了/data目录,我们先解除挂载

# /opt/MegaRAID/MegaCli/MegaCli64 -cfgldde -L1 -a0  #上面不是查出id=1了嘛,就是指定a0适配器的,id为1的raid卷组删除.id=1上面是id=0.

 Virtual Disk is associate with Cache Cade. Please Use force option to delete   #这是说有缓存,要强制删除
Exit Code: 0x01

# /opt/MegaRAID/MegaCli/MegaCli64 -cfglddel  -L1 -force -a0  #加上-force参数,再次删除

Adapter 0: Deleted Virtual Drive-1(target id-1)  #提示删除成功。
Exit Code: 0x00

#另外:/opt/MegaRAID/MegaCli/MegaCli64 -cfgldde  -a0  是将a0适配器所有的raid信息都清除掉。

博文来自:www.51niux.com

3.10 各种注

注一:

做raid之前可以用#smartctl -i 磁盘盘符  来过滤出要做raid的磁盘的Serial number:号跟 MegaCli64获得的磁盘信息进行匹配,确保盘符号无误。

注二:

在在线做raid的时候可能遇到一个问题:

问题:

The specified physical disk does not have the appropriate attributes to complete 

the requested command.

Exit Code: 0x26

解决办法:

通过MegaCli64查看磁盘详细发现格式为:

Firmware state: JBOD   #这种格式不支持直接做raid。

#MegaCli64 -PDMakeGOOD -Physdrv [32:8]  -force -aALL  #将磁盘格式转换一下

Adapter: 0: EnclId-32 SlotId-8 state changed to Unconfigured-Good.
Exit Code: 0x00

#MegaCli64 -PDInfo -Physdrv [32:8] -a0 | grep -E "Enclosure Device|Slot Number|Firmware state" 

Enclosure Device ID: 32
Slot Number: 8
Firmware state: Unconfigured(good), Spun Up  #磁盘格式已经发生了变化,这种就可以做raid了

注三:

磁盘的空间和读写情况是我们比较关心的,有时候想测试数据对比一下的时候,如果想跳过一切缓存条件来进行裸盘测试的话,那硬盘也不应该做raid。但是现在R720xd,R730XD系列,不做raid的话,操作系统识别不到硬盘。

问题:

# MegaCli64 -PDMakeJBOD -PhysDrv[32:1] -a0    #我们将磁盘转换成JBOD模式,就可以直接被 可以直接被系统识别到。                              
Adapter: 0: Failed to change PD state at EnclId-32 SlotId-1.
Exit Code: 0x01

# MegaCli64 -AdpGetProp -enablejbod -aALL  #查看失败的原因是默认是禁止向JBOD转换的,当然还有一种情况就是raid卡不支持了。


# MegaCli64 -PDList -aALL -Nolog|grep '^Firm'  #查看一下,看到现在都是Spun Up模式

Firmware state: Online, Spun Up
Firmware state: Unconfigured(good), Spun Up
Firmware state: Unconfigured(good), Spun Up
Firmware state: Unconfigured(good), Spun Up
Firmware state: Unconfigured(good), Spun Up

# MegaCli64 -h|grep JBOD  #查看一下如何开启JBOD模式

MegaCli -AdpSetProp -EnableJBOD -val -aN|-a0,1,2|-aALL 
       val - 0=Disable JBOD mode. 
             1=Enable JBOD mode. 
    | CopyBackDsbl | LoadBalanceMode | UseFDEOnlyEncrypt | WBSupport | EnableJBOD 
MegaCli -PDMakeJBOD -PhysDrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL

# MegaCli64 -AdpSetProp -EnableJBOD -1  -a0 #开启支持JBOD模式,如果这里失败后面的也就没法转换了。

Adapter 0: Set JBOD to Enable success.

Exit Code: 0x0

# MegaCli64 -PDMakeJBOD -PhysDrv[32:2] -a0  #将某个磁盘转换为JBOD模式

注四:

磁盘做了raid0,如果涉及到硬盘的更换,如果只是这块硬盘热插拔,等你插上的时候会发现磁盘变为了,下面是idrac卡界面的显示:

图片.png

#这是因为这块硬盘上面本身就有raid配置信息,然后你又插上了,raid卡就不识别了认为是一个外来硬盘。Foreign State: Foreign。

#如果就是这块硬盘硬盘做了个热插拔,那么可以执行:MegaCli64 -cfgforeign -Import -a0   #执行导入命令。

#如果这块硬盘是从别的raid卡上面拔下来的还有raid信息插上了需要在线清一下配置信息再创建呢,就下面的操作。

#MegaCli64  -CfgLdAdd -r0 [32:5] -a0   #现在直接创建肯定是不行的,会有下面的报错

The specified physical disk does not have the appropriate attributes to complete 
the requested command.

Exit Code: 0x26

#MegaCli64 -pdinfo -physdrv [32:5] -a0   #可以单独查看一下这块盘的信息

Firmware state: Unconfigured(good), Spun Up   #现在都是Spun Up模式
Foreign State: Foreign   #硬盘被标记为“Foreign”外来配置,要清除一下
Foreign Secure: Drive is not secured by a foreign lock key

#MegaCli64 -cfgforeign -scan -a0   #扫描外来配置的个数

There are 1 foreign configuration(s) on controller 0.

Exit Code: 0x00

#MegaCli64 -cfgforeign -clear -a0  #清除一下foreign配置

Foreign configuration 0 is cleared on controller 0.

Exit Code: 0x00

#MegaCli64 -cfgforeign -scan -a0   #再次扫描外来配置的个数已经没有了

There is no foreign configuration on controller 0.

Exit Code: 0x00

 #MegaCli64 -pdinfo -physdrv [32:5] -a0  #再次查看下此块硬盘的信息

Firmware state: Unconfigured(good), Spun Up
Foreign State: None

#MegaCli64 -cfgldadd -r0 [32:5] -a0  #然后将这块硬盘做成raid0

Adapter 0: Created VD 5
Adapter 0: Configured the Adapter!!
Exit Code: 0x00

#MegaCli64  -ldinfo -L5 -a0   #已经可以看到这块盘的raid信息了。

Adapter 0 -- Virtual Drive Information:
Virtual Drive: 5 (Target Id: 5)
Name                :
RAID Level          : Primary-0, Secondary-0, RAID Level Qualifier-0
Size                : 278.875 GB
State               : Optimal
Strip Size          : 64 KB
Number Of Drives    : 1
Span Depth          : 1

  #MegaCli64 -pdinfo -physdrv [32:5] -a0   #可以再看下这块盘的磁盘信息

Firmware state: Online, Spun Up
Foreign State: None

idrac卡界面查看:

图片.png

#到此系统已经可以识别到这块硬盘了。       

作者:忙碌的柴少 分类:运维工具使用 浏览:18988 评论:0
留言列表
发表评论
来宾的头像