版權聲明:本文爲博主原創文章,未經博主容許不得轉載,轉載附上原文連接便可。 https://blog.csdn.net/GX_1_11_real/article/details/83213959html
https://www.cnblogs.com/qyy349609115/p/9066912.html緩存
https://www.cnblogs.com/luxiaodai/p/9871612.html工具
前言.net
下面總結的是使用Megacli工具,在線構建raid的操做。命令行
重點htm
用MegaCli作陣列,須要注意的參數blog
Adapter #0 陣列卡號,適配器編號
Enclosure Device ID: 32 raid卡的ID號
Slot Number: 0 物理磁盤的slot號,磁盤位置
1
2
3
咱們在作raid時,必需要使用上方的參數get
指定硬盤的位置時,[Enclosure Device ID: Slot Number]
例如:指定0號盤,[32:0]it
指定raid使用的適配器的編號,-aN
例如:指定0號適配器,-a0io
基本操做
【1】查看信息
因爲咱們作raid時,必須使用一些參數,所以在作raid以前,要把它們給查出來。
<1>查看全部物理硬盤狀態
/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL
或
/opt/MegaRAID/MegaCli/MegaCli64 -PDList -a0
1
2
3
<2>查看指定的盤的詳細信息(本文示例,查看0號盤)
/opt/MegaRAID/MegaCli/MegaCli64 -pdInfo -PhysDrv[32:0] -aALL
1
<3>查看邏輯盤詳細信息
/opt/MegaRAID/MegaCli/MegaCli64 -LdPdInfo -aALL
1
<4>顯示適配器個數
/opt/MegaRAID/MegaCli/MegaCli64 -adpCount
1
<5>顯示全部適配器信息
/opt/MegaRAID/MegaCli/MegaCli64 -AdpAllInfo -aAll
1
一般注意Adapter便可。
<6> 查看全部物理硬盤的Enclosure Device ID及Slot Number
/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL | egrep 'Enclosure Device ID|Slot Number'
1
<7> 查看全部物理硬盤的狀態
/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL | egrep 'Firmware state'
1
<8> 查看全部物理硬盤的Foreign信息
/opt/MegaRAID/MegaCli/MegaCli64 -PDlist -aALL | grep "Foreign State"
1
【2】清除外來配置
當咱們插入一塊或幾塊新的硬盤時,有的時候因爲這些硬盤之前被使用過等其餘緣由,咱們在查看它的硬盤狀態時,會發現硬盤被標記爲「Foreign」外來配置,若是使用是會報錯的。因此,在用它們作raid前要清除外來配置。
(因爲忘了截圖,因此下面就只有命令行了)
<1>掃描外來配置的個數
/opt/MegaRAID/MegaCli/MegaCli64 -cfgforeign -scan -a0
There are 2 foreign configuration(s) on controller 0.
Exit Code: 0x00
1
2
3
4
5
<2>清除外來配置
/opt/MegaRAID/MegaCli/MegaCli64 -cfgforeign -clear -a0
1
<3>再次掃描外來配置的個數
/opt/MegaRAID/MegaCli/MegaCli64 -cfgforeign -scan -a0
There is no foreign configuration on controller 0.
Exit Code: 0x00
1
2
3
4
5
【3】建立raid
-r :指定raid類型(例如:raid10,-r10)
WB :緩存策略
Direct:緩存策略
[32:1]:指定要操做的硬盤。如要對多個硬盤操做,用逗號「,"隔開,[32:0,32,1]
<1>建立raid0操做
/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r0[32:1] WB Direct -a0
1
<2>建立raid1操做
/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r1[32:0,32:1] WB Direct -a0
1
<3>建立raid5操做
/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r5 [32:0,32:1,32:2] WB Direct -a0
1
<4>建立raid10操做
/opt/MegaRAID/MegaCli/MegaCli64 -CfgSpanAdd -r10 -Array0[32:0,32:1] -Array1[32:2,32:3] WB Direct -a0
1
因爲raid10爲兩個raid1組成一個raid0。上面的示例的含義爲:將32:0,32:1作raid1組成Array0;32:2,32:3作raid1組成Array1,最後由Array0和Array1組成raid0。
【4】熱備盤設置
當咱們作完raid後,若是還有多餘的硬盤,能夠拿來去作熱備,這樣會在raid中的某塊盤壞了的時候,會自動將熱備盤添加入raid,保證了raid的完整性。
<1> 添加局部熱備盤(array0表示第0個raid)
/opt/MegaRAID/MegaCli/MegaCli64 -PDHSP -Set -Dedicated -Array0 -physdrv[32:4] -a0
1
<2> 添加全局熱備盤
/opt/MegaRAID/MegaCli/MegaCli64 -pdhsp -set -physdrv[32:4] -a0
1
<3>移除熱備盤(全局和局部均可)
/opt/MegaRAID/MegaCli/MegaCli64 -pdhsp -rmv -physdrv[32:4] -a0
1
【5】刪除陣列
<1>清除當前全部的raid組的配置(慎用)
/opt/MegaRAID/MegaCli/MegaCli64 -cfgclr -a0
1
<2>刪除指定的raid組(即邏輯盤信息)
必定要先查看 邏輯盤詳細信息
/opt/MegaRAID/MegaCli/MegaCli64 -LdPdInfo -aALL 1注意Target Id,其表明邏輯盤的id,L +Target Id爲指定邏輯盤L0 表明第一個邏輯盤L1 表明第二個邏輯盤依次類推