戴尔Dell服务器Centos7设置磁盘阵列

轩辕暗神 7月前 ⋅ 502 阅读

检查 RAID 控制器工具: 戴尔服务器通常提供命令行工具(如 MegaCli 或 perccli)来管理硬件 RAID。您可以使用这些工具来检查 RAID 状态。例如: MegaCli -LDInfo -Lall -aALL 首先下载MegaCli8.07.10.tar.gz提取码:sm29 我这里放在了服务器的/opt/MegaRAID并解压的

[root@localhost opt]# mkdir MegaRAID
[root@localhost opt]# ls
MegaRAID  package  rh
[root@localhost opt]# cd MegaRAID/
[root@localhost MegaRAID]# ls
[root@localhost MegaRAID]# rz -E  #此处上传压缩包
rz waiting to receive.
[root@localhost MegaRAID]# ls
MegaCli8.07.10.tar.gz
[root@localhost MegaRAID]# tar -zvxf 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 MegaCli8.07.10]# cd /opt/MegaRAID/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 
准备中...                          ################################# [100%]
Installing....
正在升级/安装...
   1:Lib_Utils-1.00-09                ################################# [100%]
[root@localhost Linux]# rpm -ivh MegaCli-8.02.21-1.noarch.rpm
准备中...                          ################################# [100%]
正在升级/安装...
   1:MegaCli-8.02.21-1                ################################# [100%]

1、查看磁盘状态:

/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL

返回如下:

[root@localhost aa]# /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL
                                 
Adapter #0

Enclosure Device ID: 32
Slot Number: 0
Drive's postion: DiskGroup: 0, Span: 0, Arm: 0
Enclosure position: 0
Device Id: 0
WWN: 5000C5009FF49B4C
Sequence Number: 2
Media Error Count: 0
Other Error Count: 0
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0
PD Type: SAS
Raw Size: 558.911 GB [0x45dd2fb0 Sectors]
Non Coerced Size: 558.411 GB [0x45cd2fb0 Sectors]
Coerced Size: 558.375 GB [0x45cc0000 Sectors]
Firmware state: Online, Spun Up
Device Firmware Level: KT37
Shield Counter: 0
Successful diagnostics completion on :  N/A
SAS Address(0): 0x5000c5009ff49b4d
SAS Address(1): 0x0
Connected Port Number: 2(path0) 
Inquiry Data: SEAGATE ST600MP0036     KT37WAF06894            
FDE Enable: Disable
Secured: Unsecured
Locked: Unlocked
Needs EKM Attention: No
Foreign State: None 
Device Speed: 12.0Gb/s 
Link Speed: 12.0Gb/s 
Media Type: Hard Disk Device
Drive Temperature :35C (95.00 F)
PI Eligibility:  Yes 
Number of bytes of user data in LBA: 512 
Drive is formatted for PI information:  Yes 
PI: PI with type 2
Drive's write cache : Disabled
Port-0 :
Port status: Active
Port's Linkspeed: 12.0Gb/s 
Port-1 :
Port status: Active
Port's Linkspeed: 12.0Gb/s 
Drive has flagged a S.M.A.R.T alert : No



Enclosure Device ID: 32
Slot Number: 1
Drive's postion: DiskGroup: 1, Span: 0, Arm: 0
Enclosure position: 0
Device Id: 1
WWN: 5000C5009FF40010
Sequence Number: 2
Media Error Count: 0
Other Error Count: 0
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0
PD Type: SAS
Raw Size: 558.911 GB [0x45dd2fb0 Sectors]
Non Coerced Size: 558.411 GB [0x45cd2fb0 Sectors]
Coerced Size: 558.375 GB [0x45cc0000 Sectors]
Firmware state: Online, Spun Up
Device Firmware Level: KT37
Shield Counter: 0
Successful diagnostics completion on :  N/A
SAS Address(0): 0x5000c5009ff40011
SAS Address(1): 0x0
Connected Port Number: 0(path0) 
Inquiry Data: SEAGATE ST600MP0036     KT37WAF069XT            
FDE Enable: Disable
Secured: Unsecured
Locked: Unlocked
Needs EKM Attention: No
Foreign State: None 
Device Speed: 12.0Gb/s 
Link Speed: 12.0Gb/s 
Media Type: Hard Disk Device
Drive Temperature :36C (96.80 F)
PI Eligibility:  Yes 
Number of bytes of user data in LBA: 512 
Drive is formatted for PI information:  Yes 
PI: PI with type 2
Drive's write cache : Disabled
Port-0 :
Port status: Active
Port's Linkspeed: 12.0Gb/s 
Port-1 :
Port status: Active
Port's Linkspeed: 12.0Gb/s 
Drive has flagged a S.M.A.R.T alert : No



Enclosure Device ID: 32
Slot Number: 2
Drive's postion: DiskGroup: 1, Span: 0, Arm: 1
Enclosure position: 0
Device Id: 2
WWN: 5000C5009FF4B0E4
Sequence Number: 2
Media Error Count: 0
Other Error Count: 0
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0
PD Type: SAS
Raw Size: 558.911 GB [0x45dd2fb0 Sectors]
Non Coerced Size: 558.411 GB [0x45cd2fb0 Sectors]
Coerced Size: 558.375 GB [0x45cc0000 Sectors]
Firmware state: Online, Spun Up
Device Firmware Level: KT37
Shield Counter: 0
Successful diagnostics completion on :  N/A
SAS Address(0): 0x5000c5009ff4b0e5
SAS Address(1): 0x0
Connected Port Number: 4(path0) 
Inquiry Data: SEAGATE ST600MP0036     KT37WAF067R6            
FDE Enable: Disable
Secured: Unsecured
Locked: Unlocked
Needs EKM Attention: No
Foreign State: None 
Device Speed: 12.0Gb/s 
Link Speed: 12.0Gb/s 
Media Type: Hard Disk Device
Drive Temperature :33C (91.40 F)
PI Eligibility:  Yes 
Number of bytes of user data in LBA: 512 
Drive is formatted for PI information:  Yes 
PI: PI with type 2
Drive's write cache : Disabled
Port-0 :
Port status: Active
Port's Linkspeed: 12.0Gb/s 
Port-1 :
Port status: Active
Port's Linkspeed: 12.0Gb/s 
Drive has flagged a S.M.A.R.T alert : No



Enclosure Device ID: 32
Slot Number: 3
Drive's postion: DiskGroup: 1, Span: 0, Arm: 2
Enclosure position: 0
Device Id: 3
WWN: 5000C5009FF389A8
Sequence Number: 2
Media Error Count: 0
Other Error Count: 0
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0
PD Type: SAS
Raw Size: 558.911 GB [0x45dd2fb0 Sectors]
Non Coerced Size: 558.411 GB [0x45cd2fb0 Sectors]
Coerced Size: 558.375 GB [0x45cc0000 Sectors]
Firmware state: Online, Spun Up
Device Firmware Level: KT37
Shield Counter: 0
Successful diagnostics completion on :  N/A
SAS Address(0): 0x5000c5009ff389a9
SAS Address(1): 0x0
Connected Port Number: 1(path0) 
Inquiry Data: SEAGATE ST600MP0036     KT37WAF05MC4            
FDE Enable: Disable
Secured: Unsecured
Locked: Unlocked
Needs EKM Attention: No
Foreign State: None 
Device Speed: 12.0Gb/s 
Link Speed: 12.0Gb/s 
Media Type: Hard Disk Device
Drive Temperature :34C (93.20 F)
PI Eligibility:  Yes 
Number of bytes of user data in LBA: 512 
Drive is formatted for PI information:  Yes 
PI: PI with type 2
Drive's write cache : Disabled
Port-0 :
Port status: Active
Port's Linkspeed: 12.0Gb/s 
Port-1 :
Port status: Active
Port's Linkspeed: 12.0Gb/s 
Drive has flagged a S.M.A.R.T alert : No



Enclosure Device ID: 32
Slot Number: 4
Enclosure position: 0
Device Id: 4
WWN: 5000C5009FF4B48C
Sequence Number: 1
Media Error Count: 0
Other Error Count: 0
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0
PD Type: SAS
Raw Size: 558.911 GB [0x45dd2fb0 Sectors]
Non Coerced Size: 558.411 GB [0x45cd2fb0 Sectors]
Coerced Size: 558.375 GB [0x45cc0000 Sectors]
Firmware state: Unconfigured(good), Spun Up
Device Firmware Level: KT37
Shield Counter: 0
Successful diagnostics completion on :  N/A
SAS Address(0): 0x5000c5009ff4b48d
SAS Address(1): 0x0
Connected Port Number: 3(path0) 
Inquiry Data: SEAGATE ST600MP0036     KT37WAF0601K            
FDE Enable: Disable
Secured: Unsecured
Locked: Unlocked
Needs EKM Attention: No
Foreign State: Foreign 
Foreign Secure: Drive is not secured by a foreign lock key
Device Speed: 12.0Gb/s 
Link Speed: 12.0Gb/s 
Media Type: Hard Disk Device
Drive Temperature :32C (89.60 F)
PI Eligibility:  Yes 
Number of bytes of user data in LBA: 512 
Drive is formatted for PI information:  Yes 
PI: PI with type 2
Drive's write cache : Disabled
Port-0 :
Port status: Active
Port's Linkspeed: 12.0Gb/s 
Port-1 :
Port status: Active
Port's Linkspeed: 12.0Gb/s 
Drive has flagged a S.M.A.R.T alert : No




Exit Code: 0x00

我这里需要给 Slot Number: 1 Slot Number: 2 Slot Number: 3 Slot Number: 4 做成一个阵列采用RAID6

2、查看现有阵列

/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -aALL 这个命令将列出所有RAID逻辑卷的详细信息,包括RAID级别、状态、硬盘组成等。 查询结果如下:

[root@localhost aa]# /opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -aALL
                                 

Adapter 0 -- Virtual Drive Information:
Virtual Drive: 0 (Target Id: 0)
Name                :
RAID Level          : Primary-0, Secondary-0, RAID Level Qualifier-0
Size                : 558.375 GB
Parity Size         : 0
State               : Optimal
Strip Size          : 64 KB
Number Of Drives    : 1
Span Depth          : 1
Default Cache Policy: WriteThrough, ReadAheadNone, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteThrough, ReadAheadNone, Direct, No Write Cache if Bad BBU
Default Access Policy: Read/Write
Current Access Policy: Read/Write
Disk Cache Policy   : Disk's Default
Encryption Type     : None
Default Power Savings Policy: Controller Defined
Current Power Savings Policy: None
Can spin up in 1 minute: Yes
LD has drives that support T10 power conditions: Yes
LD's IO profile supports MAX power savings with cached writes: No
Bad Blocks Exist: No
PI type: No PI

Is VD Cached: No

可以看到这里有2个阵列,这里我们需要删除Virtual Drive: 1 (Target Id: 1)这个阵列,

以使用以下命令来删除 Virtual Drive: 1 (Target Id: 1):

/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdDel -L1 -a0

其中 -L1 表示删除 Target Id 为 1 的逻辑驱动(Virtual Drive),-a0 表示操作的是第一个控制器。

删除前请确保没有重要数据在该逻辑驱动上,因为此操作会清除该 RAID 逻辑卷的所有数据。

[root@localhost aa]# /opt/MegaRAID/MegaCli/MegaCli64 -CfgLdDel -L1 -a0

Adapter 0: Deleted Virtual Drive-1(target id-1)

Exit Code: 0x00

3、创建RAID的步骤:

可以通过MegaCli命令来配置RAID,假设你要创建RAID 5,命令如下:

/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r5 [32:1,32:2,32:3,32:4] -a0

-r5 表示RAID 5,若选择RAID 6则改为 -r6。 [32:1,32:2,32:3,32:4] 指定硬盘的Enclosure Device ID和Slot Number,替换为你实际的硬盘位置。 -a0 表示操作的适配器编号,这里是0,替换为实际的适配器编号。 创建完成后,可以用以下命令检查RAID状态:

/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -aALL

执行结果如下:

[root@localhost aa]# /opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r5 [32:1,32:2,32:3,32:4] -a0
                                 
Mix of configured and unconfigured drives are not possible.

Exit Code: 0x0b

如果这一步遇到问题有可能是硬盘还在其他阵列当中,解决办法清除状态:

清除外部磁盘(Foreign)状态 要清除磁盘的 Foreign 状态,可以使用以下命令:

/opt/MegaRAID/MegaCli/MegaCli64 -CfgForeign -Clear -a0

这将清除所有外部磁盘(Foreign)状态。如果你想清除单个磁盘的 Foreign 状态,可以指定具体的磁盘:

/opt/MegaRAID/MegaCli/MegaCli64 -PdClear -PhysDrv[32:4] -a0

然后再创建RAID一般就可以成功了

后期更换硬盘步骤:

RAID 5 阵列具备冗余能力,当其中一块硬盘发生故障时,您可以直接更换新的硬盘而不需要做其他复杂的操作。更换硬盘的过程相对简单,但需要按照正确的步骤进行,确保数据不会丢失。以下是更换损坏硬盘的操作步骤:

步骤 1:确认故障硬盘

首先,使用 MegaCli 或 storcli 等工具检查当前硬盘的状态,并确认是哪一块硬盘发生了故障。

/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL

检查输出中的硬盘状态,通常如果硬盘发生故障,状态会显示为 Failed、Offline 或者 Foreign。

步骤 2:标记故障硬盘为“离线”状态

在更换硬盘之前,可以将故障硬盘标记为“离线”,避免 RAID 控制器继续尝试与它通信。使用以下命令:

/opt/MegaRAID/MegaCli/MegaCli64 -PDOffline -PhysDrv[32:x] -a0

这里的 PhysDrv[32:x] 是故障硬盘的位置标识符(例如:32:3)。确认位置后执行该命令。

步骤 3:物理更换硬盘

拔掉故障硬盘,插入一块相同型号和容量的新硬盘。请确保新硬盘符合 RAID 阵列的规格(通常至少要与故障硬盘的容量相同,最好相同品牌和型号)。

步骤 4:初始化并重建 RAID 阵列

RAID 控制器通常会自动检测到新硬盘并开始重建过程。你可以使用以下命令查看重建的进度:

/opt/MegaRAID/MegaCli/MegaCli64 -PDRbld -showprog -PhysDrv[32:x] -a0

如果新的硬盘没有被自动重建,可以手动启动重建操作:

/opt/MegaRAID/MegaCli/MegaCli64 -PDRbld -Start -PhysDrv[32:x] -a0

在此过程中,RAID 阵列会利用剩余硬盘上的数据以及冗余信息重建故障硬盘上的数据。这个过程可能需要几个小时(具体取决于磁盘的大小和 RAID 阵列的负载)。

步骤 5:验证阵列恢复状态

重建完成后,可以通过以下命令查看 RAID 阵列的状态:

/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -Lall -aALL

确保虚拟磁盘的状态为 Optimal,且所有硬盘都已恢复正常。

步骤 6:重新启动系统(可选)

虽然更换硬盘后不一定需要重启系统,但如果你遇到任何问题,可以考虑重新启动系统,以确保一切配置生效并稳定运行。

reboot

注意事项

备份:尽管 RAID 5 提供了冗余保护,但还是建议定期备份重要数据,防止其他不可预测的故障导致数据丢失。 硬盘兼容性:更换硬盘时,确保新硬盘的容量与故障硬盘相同或更大,并且与 RAID 阵列兼容。不同品牌或型号的硬盘可能会影响性能和稳定性。 耐心等待重建完成:在硬盘重建过程中,尽量避免进行其他大负载的操作,以免影响重建速度或造成数据不一致。 通过这种方式,你应该能够轻松地将故障硬盘替换为新硬盘,而不需要进行复杂的配置操作。


全部评论: 0

    我有话说: