1. RAID概述
RAID(Redundant Array of Independent Disks)独立磁盘冗余阵列,通过将多个磁盘组合起来提供更高的性能、可靠性和容量。更多学习教程www.fgedu.net.cn
# lspci | grep -i raid
03:00.0 RAID bus controller: Broadcom / LSI MegaRAID Tri-Mode SAS3508
# 查看RAID卡信息
# storcli /c0 show
Generating detailed summary of the adapter, it may take a while.
Controller = 0
Status = Success
Description = None
Product Name = PERC H750 Adapter
Serial Number = ABCD1234
SAS Address = 5003048012345678
PCI Address = 00:03:00:00
System Time = 04/03/2026 10:00:00
Controller Status = Optimal
Firmware Version = 5.280.01-6264
Rebuild Rate = 30%
BGI Rate = 30%
CC Rate = 30%
Reconstruct Rate = 30%
PR Rate = 30%
Current Size = 0 MB
Maximum Size = 0 MB
Number of Virtual Drives = 2
Number of Physical Drives = 8
Number of Enclosures = 1
2. RAID级别详解
不同RAID级别提供不同的性能、可靠性和容量特性。学习交流加群风哥微信: itpux-com
RAID级别 | 最少磁盘 | 冗余 | 容量利用率 | 读性能 | 写性能 | 适用场景
———|———-|——|————|——–|——–|———-
RAID 0 | 2 | 无 | 100% | 高 | 高 | 临时数据、缓存
RAID 1 | 2 | 有 | 50% | 中 | 中 | 操作系统、关键数据
RAID 5 | 3 | 有 | (n-1)/n | 高 | 中 | 文件服务器、应用数据
RAID 6 | 4 | 有 | (n-2)/n | 高 | 低 | 重要数据、归档
RAID 10 | 4 | 有 | 50% | 高 | 高 | 数据库、高IO应用
RAID 50 | 6 | 有 | (n-2)/n | 很高 | 中 | 大容量高IO需求
RAID 60 | 8 | 有 | (n-4)/n | 很高 | 低 | 大容量高可靠需求
# 查看支持的RAID级别
# storcli /c0 show all | grep -i “supported raid”
Supported RAID Levels: RAID0, RAID1, RAID5, RAID6, RAID10, RAID50, RAID60
# 查看当前虚拟磁盘
# storcli /c0 /vall show
Controller = 0
Status = Success
Description = None
Virtual Drives:
==============
DG/VD TYPE State Access Consist Cache Cac sCC Size Name
0/0 RAID10 Optl RW Yes RWBD – ON 1.818 TB OS_VD
1/1 RAID5 Optl RW Yes RWBD – ON 7.272 TB DATA_VD
3. RAID卡信息查看
查看RAID卡详细信息帮助了解硬件配置。学习交流加群风哥QQ113257174
# storcli /c0 show all
Controller = 0
Status = Success
Description = None
Product Name = PERC H750 Adapter
Serial Number = ABCD1234
SAS Address = 5003048012345678
PCI Address = 00:03:00:00
System Time = 04/03/2026 10:00:00
Controller Status = Optimal
Firmware Version = 5.280.01-6264
Rebuild Rate = 30%
BGI Rate = 30%
CC Rate = 30%
Reconstruct Rate = 30%
PR Rate = 30%
Current Size = 0 MB
Maximum Size = 0 MB
Number of Virtual Drives = 2
Number of Physical Drives = 8
Number of Enclosures = 1
Support PD Online Expansion = Yes
Support VD Online Expansion = Yes
Support Security = Yes
Support Boot Volume = Yes
Support PI = Yes
Support LD = Yes
Support JBOD = Yes
Support PFK = Yes
Support LKBS = Yes
Support Zero Memory = Yes
Support Diagnostic LD = Yes
Support T10-PI = Yes
Support SED = Yes
Support Max SATA drives = 32
Support Max SAS drives = 255
Support Max Virtual Drives = 64
Support Max Cachevaults = 1
Support Max Physical Drives per VD = 32
# 查看物理磁盘
# storcli /c0 /eall /sall show
Controller = 0
Status = Success
Description = None
Drive /c0/e252/s0 :
===================================
EID:Slt DID State DG Size Intf Med SED PI SeSz Model Sp Type
252:0 12 Onln 0 931.0 GB SATA SSD N N 512B Samsung SSD 970 U –
252:1 13 Onln 0 931.0 GB SATA SSD N N 512B Samsung SSD 970 U –
252:2 14 Onln 0 931.0 GB SATA SSD N N 512B Samsung SSD 970 U –
252:3 15 Onln 0 931.0 GB SATA SSD N N 512B Samsung SSD 970 U –
252:4 16 Onln 1 1.862 TB SAS HDD N N 512B Seagate ST2000 U –
252:5 17 Onln 1 1.862 TB SAS HDD N N 512B Seagate ST2000 U –
252:6 18 Onln 1 1.862 TB SAS HDD N N 512B Seagate ST2000 U –
252:7 19 Onln 1 1.862 TB SAS HDD N N 512B Seagate ST2000 U –
# 查看磁盘详细信息
# storcli /c0 /e252 /s0 show all
Drive /c0/e252/s0 :
================
EID:Slt = 252:0
DID = 12
State = Onln
DG = 0
Size = 931.0 GB
Intf = SATA
Med = SSD
SED = N
PI = N
SeSz = 512B
Model = Samsung SSD 970 EVO Plus
Sp = U
Type = –
Manufacturer Id = Samsung
Model Number = Samsung SSD 970 EVO Plus 1TB
NAND Vendor = Samsung
Serial Number = ABCD1234EFGH5678
Firmware Revision = 2B2QEXM7
Raw size = 931.512 GB [0xe8e0dbb0 Sectors]
Coerced size = 931.0 GB [0xe8d00000 Sectors]
Non Coerced size = 931.0 GB [0xe8d00000 Sectors]
Device Speed = 6.0Gb/s
Link Speed = 6.0Gb/s
NCQ = Yes
4. 创建RAID阵列
创建RAID阵列是配置存储的第一步。更多学习教程公众号风哥教程itpux_com
# storcli /c0 /eall /sall show | grep -E “UGood|JBOD”
252:8 20 UGood – 1.862 TB SAS HDD N N 512B Seagate ST2000 U –
252:9 21 UGood – 1.862 TB SAS HDD N N 512B Seagate ST2000 U –
# 创建RAID 1(镜像)
# storcli /c0 add vd raid1 size=all drives=252:8-9 pdperarray=2
Controller = 0
Status = Success
Description = Add VD Succeeded.
VD created successfully. VD ID = 2
# 创建RAID 5
# storcli /c0 add vd raid5 size=all drives=252:8-12
Controller = 0
Status = Success
Description = Add VD Succeeded.
VD created successfully. VD ID = 3
# 创建RAID 10
# storcli /c0 add vd raid10 size=all drives=252:8-15 pdperarray=2
Controller = 0
Status = Success
Description = Add VD Succeeded.
VD created successfully. VD ID = 4
# 创建RAID时指定参数
# storcli /c0 add vd raid5 size=all drives=252:8-12 \
wt|wb|awb \
nora|ra \
direct|cached \
cachevd \
strip=128 \
name=DATA_VOLUME
参数说明:
wt : Write Through(写透)
wb : Write Back(写回)
awb : Always Write Back(始终写回)
nora: No Read Ahead(不预读)
ra : Read Ahead(预读)
direct: Direct I/O
cached: Cached I/O
strip: 条带大小(64/128/256/512/1024KB)
# 查看创建的虚拟磁盘
# storcli /c0 /vall show
Controller = 0
Status = Success
Description = None
Virtual Drives:
==============
DG/VD TYPE State Access Consist Cache Cac sCC Size Name
0/0 RAID10 Optl RW Yes RWBD – ON 1.818 TB OS_VD
1/1 RAID5 Optl RW Yes RWBD – ON 7.272 TB DATA_VD
2/2 RAID1 Optl RW Yes RWBD – ON 1.862 TB MIRROR_VD
5. RAID阵列管理
RAID阵列管理包括配置、优化和维护。author:www.itpux.com
# storcli /c0 /v0 show all
Virtual Drive = 0
================
Type = RAID10
State = Optimal
Access = RW
Consistency = Yes
Cache = RWBD
Cac = –
sCC = ON
Size = 1.818 TB
Name = OS_VD
Strip Size = 256 KB
Number of Blocks = 3906764800
VD has Emulated PD = Yes
Span Depth = 2
Number of Drives Per Span = 2
Number of Spans = 2
Number of Drives = 4
Write Policy = Write Back
Read Policy = Read Ahead
Cache Policy = Direct I/O
PR = Disabled
BGI = Enabled
SSD Patrol Read = Disabled
# 修改虚拟磁盘属性
# storcli /c0 /v0 set wrcache=wt
Controller = 0
Status = Success
Description = Set VD Property Succeeded.
# storcli /c0 /v0 set rdcache=ra
Controller = 0
Status = Success
Description = Set VD Property Succeeded.
# 初始化虚拟磁盘
# storcli /c0 /v0 start init
Controller = 0
Status = Success
Description = Start VD Initialization Succeeded.
# 查看初始化进度
# storcli /c0 /v0 show init
Controller = 0
Status = Success
Description = None
VD Operation Status:
===================
VD Operation = Initialization
VD Operation Status = In Progress
VD Operation Progress = 45%
VD Operation Elapsed Time = 00:10:00
# 快速初始化
# storcli /c0 /v0 start init force
Controller = 0
Status = Success
Description = Start VD Initialization Succeeded.
# 一致性检查
# storcli /c0 /v0 start cc
Controller = 0
Status = Success
Description = Start Consistency Check Succeeded.
# 查看一致性检查进度
# storcli /c0 /v0 show cc
Controller = 0
Status = Success
Description = None
VD Operation Status:
===================
VD Operation = Consistency Check
VD Operation Status = In Progress
VD Operation Progress = 30%
VD Operation Elapsed Time = 00:05:00
6. 磁盘管理
磁盘管理包括热备盘配置、磁盘状态管理等。
# storcli /c0 /e252 /s10 add hotsparedrive
Controller = 0
Status = Success
Description = Add Hot Spare Succeeded.
# 配置专用热备盘
# storcli /c0 /e252 /s11 add hotsparedrive dgs=0
Controller = 0
Status = Success
Description = Add Dedicated Hot Spare Succeeded.
# 查看热备盘
# storcli /c0 /eall /sall show | grep -i “hotspare”
252:10 22 GHS – 1.862 TB SAS HDD N N 512B Seagate ST2000 U –
252:11 23 DHS – 1.862 TB SAS HDD N N 512B Seagate ST2000 U –
# 移除热备盘
# storcli /c0 /e252 /s10 delete hotsparedrive
Controller = 0
Status = Success
Description = Delete Hot Spare Succeeded.
# 设置磁盘为JBOD模式
# storcli /c0 /e252 /s12 makejbod
Controller = 0
Status = Success
Description = Make JBOD Succeeded.
# 设置磁盘为Good状态
# storcli /c0 /e252 /s12 makegood
Controller = 0
Status = Success
Description = Make Good Succeeded.
# 定位磁盘(闪烁指示灯)
# storcli /c0 /e252 /s0 start locate
Controller = 0
Status = Success
Description = Start Drive Locate Succeeded.
# 停止定位
# storcli /c0 /e252 /s0 stop locate
Controller = 0
Status = Success
Description = Stop Drive Locate Succeeded.
# 查看磁盘错误计数
# storcli /c0 /e252 /s0 show all | grep -i “error”
Media Error Count = 0
Other Error Count = 0
Predictive Failure Count = 0
7. RAID重建
RAID重建在磁盘故障后恢复数据冗余。
# storcli /c0 /e252 /s0 set offline
Controller = 0
Status = Success
Description = Set Drive Offline Succeeded.
# 查看虚拟磁盘状态
# storcli /c0 /vall show
Controller = 0
Status = Success
Description = None
Virtual Drives:
==============
DG/VD TYPE State Access Consist Cache Cac sCC Size Name
0/0 RAID10 Dgrd RW Yes RWBD – ON 1.818 TB OS_VD
# 查看物理磁盘状态
# storcli /c0 /eall /sall show | grep -E “Offln|Onln|GHS|DHS”
252:0 12 Offln 0 931.0 GB SATA SSD N N 512B Samsung SSD 970 U –
252:1 13 Onln 0 931.0 GB SATA SSD N N 512B Samsung SSD 970 U –
252:10 22 GHS – 1.862 TB SAS HDD N N 512B Seagate ST2000 U –
# 热备盘自动开始重建
# storcli /c0 /eall /sall show | grep -E “Rebuild|Rbld”
252:10 22 Rbld 0 1.862 TB SAS HDD N N 512B Seagate ST2000 U –
# 查看重建进度
# storcli /c0 /e252 /s10 show rebuild
Controller = 0
Status = Success
Description = None
Drive Reconstruction Status:
===========================
Drive = 252:10
Reconstruction Status = In Progress
Reconstruction Progress = 35%
Reconstruction Elapsed Time = 00:15:00
# 手动开始重建
# storcli /c0 /e252 /s10 start rebuild
Controller = 0
Status = Success
Description = Start Drive Rebuild Succeeded.
# 设置重建速率
# storcli /c0 set rebuildrate=70
Controller = 0
Status = Success
Description = Set Controller Property Succeeded.
# 查看重建速率
# storcli /c0 show | grep “Rebuild Rate”
Rebuild Rate = 70%
# 取消重建
# storcli /c0 /e252 /s10 stop rebuild
Controller = 0
Status = Success
Description = Stop Drive Rebuild Succeeded.
8. RAID迁移
RAID迁移允许在不丢失数据的情况下改变RAID级别。
# storcli /c0 /v0 show migration
Controller = 0
Status = Success
Description = None
VD Migration Support:
====================
VD = 0
Current RAID Level = RAID5
Supported Migration Levels = RAID0, RAID6
# 执行RAID级别迁移
# storcli /c0 /v0 start migrate type=raid6
Controller = 0
Status = Success
Description = Start VD Migration Succeeded.
# 查看迁移进度
# storcli /c0 /v0 show migration
Controller = 0
Status = Success
Description = None
VD Migration Status:
===================
VD = 0
Migration Status = In Progress
Migration Progress = 25%
Migration Elapsed Time = 00:30:00
Source RAID Level = RAID5
Target RAID Level = RAID6
# 扩展虚拟磁盘容量
# storcli /c0 /v0 expand size=all
Controller = 0
Status = Success
Description = Expand VD Succeeded.
# 在线容量扩展
# storcli /c0 /v0 start expand size=all
Controller = 0
Status = Success
Description = Start VD Expansion Succeeded.
# 查看扩展进度
# storcli /c0 /v0 show expand
Controller = 0
Status = Success
Description = None
VD Expansion Status:
===================
VD = 0
Expansion Status = In Progress
Expansion Progress = 40%
Expansion Elapsed Time = 00:20:00
9. RAID监控
RAID监控确保及时发现和处理问题。
# cat > /opt/scripts/raid_monitor.sh << 'EOF' #!/bin/bash LOG_FILE="/var/log/raid_monitor.log" ALERT_EMAIL="admin@fgedu.net.cn" check_controller_status() { STATUS=$(storcli /c0 show | grep "Controller Status" | awk '{print $4}') if [ "$STATUS" != "Optimal" ]; then echo "$(date): 控制器状态异常: $STATUS" >> $LOG_FILE
echo “RAID控制器状态异常: $STATUS” | mail -s “RAID告警” $ALERT_EMAIL
fi
}
check_virtual_drives() {
storcli /c0 /vall show | grep -v “Optl” | grep “RAID” | while read line; do
VD=$(echo $line | awk ‘{print $1}’)
STATE=$(echo $line | awk ‘{print $3}’)
if [ “$STATE” != “Optl” ]; then
echo “$(date): 虚拟磁盘 $VD 状态异常: $STATE” >> $LOG_FILE
echo “虚拟磁盘 $VD 状态异常: $STATE” | mail -s “RAID告警” $ALERT_EMAIL
fi
done
}
check_physical_drives() {
storcli /c0 /eall /sall show | grep -v “Onln” | grep -v “GHS” | grep -v “DHS” | grep -v “UGood” | grep “:” | while read line; do
DRIVE=$(echo $line | awk ‘{print $1}’)
STATE=$(echo $line | awk ‘{print $3}’)
if [ “$STATE” != “Onln” ] && [ “$STATE” != “GHS” ] && [ “$STATE” != “DHS” ] && [ “$STATE” != “UGood” ]; then
echo “$(date): 物理磁盘 $DRIVE 状态异常: $STATE” >> $LOG_FILE
echo “物理磁盘 $DRIVE 状态异常: $STATE” | mail -s “RAID告警” $ALERT_EMAIL
fi
done
}
check_rebuild_status() {
REBUILD=$(storcli /c0 /eall /sall show | grep “Rbld”)
if [ -n “$REBUILD” ]; then
echo “$(date): 检测到重建进行中: $REBUILD” >> $LOG_FILE
fi
}
check_controller_status
check_virtual_drives
check_physical_drives
check_rebuild_status
EOF
# chmod +x /opt/scripts/raid_monitor.sh
# 配置定时监控
# crontab -e
*/5 * * * * /opt/scripts/raid_monitor.sh
# 查看RAID事件日志
# storcli /c0 show events
Controller = 0
Status = Success
Description = None
Event Log:
=========
Time: 04/03/2026 10:00:00
Event: PD 252:0 State change from Onln to Offln
Severity: Critical
Time: 04/03/2026 10:01:00
Event: VD 0 State change from Optl to Dgrd
Severity: Critical
Time: 04/03/2026 10:02:00
Event: PD 252:10 Rebuild started
Severity: Information
# 查看BBU/CacheVault状态
# storcli /c0 /cv show
Controller = 0
Status = Success
Description = None
CacheVault Info:
===============
Model = CVPM05
State = Optimal
Temperature = 28 C
Temperature Status = Normal
Remaining Capacity = 100%
Design Capacity = 54.9 Wh
Full Charge Capacity = 54.9 Wh
Design Voltage = 48.0 V
Current Voltage = 48.0 V
Charge Cycles = 10
Max Charge Cycles = 500
Manufacture Date = 01/15/2026
Serial Number = ABCD1234
10. 故障处理
故障处理帮助快速恢复RAID阵列。
# 1. 识别故障磁盘
# storcli /c0 /eall /sall show | grep -v “Onln” | grep -v “GHS” | grep -v “DHS”
252:0 12 Offln 0 931.0 GB SATA SSD N N 512B Samsung SSD 970 U –
# 2. 定位故障磁盘
# storcli /c0 /e252 /s0 start locate
# 3. 物理更换磁盘
# 4. 设置新磁盘为Good状态
# storcli /c0 /e252 /s0 makegood
# 5. 开始重建
# storcli /c0 /e252 /s0 start rebuild
# 虚拟磁盘降级处理
# 查看降级原因
# storcli /c0 /v0 show all | grep -E “State|Status”
# 导入外部配置
# storcli /c0 /fall show
Controller = 0
Status = Success
Description = None
Foreign Drive:
=============
F_NUM EID:Slt DID State DG Size Intf Med
1 252:0 12 Frn – 931.0 GB SATA SSD
# 导入配置
# storcli /c0 /fall import
Controller = 0
Status = Success
Description = Import Foreign Configuration Succeeded.
# 清除配置
# storcli /c0 /fall delete
Controller = 0
Status = Success
Description = Clear Foreign Configuration Succeeded.
# 恢复删除的虚拟磁盘
# storcli /c0 /v0 start restore
Controller = 0
Status = Success
Description = Start VD Restore Succeeded.
# 紧急恢复步骤
# cat > /opt/scripts/raid_recovery.sh << 'EOF'
#!/bin/bash
echo "RAID紧急恢复流程"
echo "=========================================="
echo "1. 检查控制器状态"
storcli /c0 show | grep "Controller Status"
echo ""
echo "2. 检查虚拟磁盘状态"
storcli /c0 /vall show
echo ""
echo "3. 检查物理磁盘状态"
storcli /c0 /eall /sall show
echo ""
echo "4. 检查热备盘"
storcli /c0 /eall /sall show | grep -E "GHS|DHS"
echo ""
echo "5. 检查重建状态"
storcli /c0 /eall /sall show | grep "Rbld"
echo ""
echo "6. 检查BBU/CacheVault状态"
storcli /c0 /cv show
echo ""
echo "7. 检查事件日志"
storcli /c0 show events | tail -20
echo ""
echo "=========================================="
echo "恢复检查完成"
EOF
# chmod +x /opt/scripts/raid_recovery.sh
本文由风哥教程整理发布,仅用于学习测试使用,转载注明出处:http://www.fgedu.net.cn/10327.html
