安装
Centos
wget https://docs.broadcom.com/docs-and-downloads/raid-controllers/raid-controllers-common-files/8-07-14_MegaCLI.zip
uzip 8-07-14_MegaCLI.zip
rpm -ivh MegaCli-8.07.14-1.noarch.rpm
Ubuntu
在线
修改 /etc/apt/sources.list 在末尾添加
deb http://hwraid.le-vert.net/ubuntu precise main
wget -O - http://hwraid.le-vert.net/debian/hwraid.le-vert.net.gpg.key | sudo apt-key add -
apt-get install megacli megactl megaraid-status
离线
wget http://hwraid.le-vert.net/debian/pool-stretch/megacli/megacli_8.07.14-2%2BDebian.stretch.9.9_amd64.deb
dpkg -i megacli_8.07.14-2+Debian.stretch.9.9_amd64.deb
apt-get install libncurses5 libtinfo5
apt --fix-broken install
查看
1.查看阵列卡信息
/opt/MegaRAID/MegaCli/MegaCli64 -AdpAllInfo -aALL
2.查看物理磁盘信息
/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL|egrep \
"Slot Number|PD Type|Raw Size|Firmware state|Media Type"|sed 's/Slot/\nSlot/g'
Adapter#0 -----raid卡控制器编号
Enclosure Device ID: 64 -----外壳设备ID,也就是raid卡的ID号
Slot Number: 6 ------磁盘槽位号
PD Type: SAS ------磁盘类型
Raw Size: 3.638 TB [0x1d1c0beb0 Sectors] ------大小
Firmware state: Online, Spun Up ------磁盘状态
3.查看RAID组信息:
/opt/MegaRAID/MegaCli/MegaCli64 -LdPdInfo -aALL|egrep \
"RAID Level|^Size|Slot Number|Virtual Drive"|sed 's/Virtual/\nVirtual/g'
4.查看物理磁盘个数
/opt/MegaRAID/MegaCli/MegaCli64 -PDGetNum -aALL
5.查看磁盘温度
/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL | egrep \
"Drive Temperature" | awk -F ":" '{print $2}'
6.扫描外来配置的个数:
/opt/MegaRAID/MegaCli/MegaCli64 -cfgforeign -scan -a0
/opt/MegaRAID/MegaCli/MegaCli64 -cfgforeign -preview -a0 查看当前的磁盘在normal时的位置
/opt/MegaRAID/MegaCli/MegaCli64 -cfgforeign -import -a0 来导入配置,恢复虚拟磁盘组
/opt/MegaRAID/MegaCli/MegaCli64 -cfgforeign -dsply -a0
7.删除外来配置
/opt/MegaRAID/MegaCli/MegaCli64 -cfgforeign -clear -a0
** 此命令慎用 **
MegaCli64 -cfgforeign -clear -a0 //这里的a0表示第一个raid卡控制器上的外来配置
8.查看磁盘错误
/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL|grep Error
Medai Error Count 表示磁盘可能错误,可能是磁盘有坏道,
这个值不为0值得注意,数值越大,危险系数越高
Other Error Count 表示磁盘可能存在松动,可能需要重新再插入
9.将某块物理盘下线/上线
/opt/MegaRAID/MegaCli/MegaCli64 -PDOffline -PhysDrv [32:4] -a0
/opt/MegaRAID/MegaCli/MegaCli64 -PDOnline -PhysDrv [32:4] -a0
10.查看raid陈列中掉线的硬盘:
/opt/MegaRAID/MegaCli/MegaCli64 -pdgetmissing -a0
11.查看,开启或关闭jbod模式(硬盘直通功能)
查看:MegaCli -AdpGetProp -enablejbod -aALL
打开:MegaCli -AdpSetProp -EnableJBOD -1 -aALL
关闭:MegaCli -AdpSetProp -EnableJBOD -0 -aALL
创建
1.用slot2号的盘创建raid0
/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r0[32:2] WB Direct -a0
2.用slot3,4号盘创建raid1
/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r1 [32:3,32:4] -a0
3.用slot5,6,7号盘创建raid5
/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r5 [32:5,32:6,32:7] -a0
4.用slot9,10,11,12号,创建一个raid10
/opt/MegaRAID/MegaCli/MegaCli64 -CfgSpanAdd -r10 -Array0[32:8,32:9] -Array1[32:10,32:11] -a0
5.如果创建报错
Exit Code: 0x26
/opt/MegaRAID/MegaCli/MegaCli64 -PDMakeGOOD -Physdrv [32:8] -force -aALL #将磁盘格式转换一下
删除
1.删除raid组0的raid组
/opt/MegaRAID/MegaCli/MegaCli64 -cfglddel -L0 -a0
案例
/opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL|egrep \
"Slot Number|PD Type|Raw Size|Firmware state|Media Type"|sed 's/Slot/\nSlot/g'
/opt/MegaRAID/MegaCli/MegaCli64 -LdPdInfo -aALL|egrep \
"Enclosure Device|RAID Level|^Size|Slot Number|Virtual Drive"|sed 's/Virtual/\nVirtual/g'
1.查看磁盘raid后的虚拟磁盘,和系统的盘符对应关系,根据对应关系,删除raid并重组raid
/opt/MegaRAID/perccli/perccli64 /c0/vall show
udevadm info -q path -n /dev/sdb
ll /dev/disk/by-path
第一条命令结果中VD号,和第二条命令结果中block前的字符串中的第三位,
一一对应,确认系统盘符和raid盘的对应关系
2.确认并删除raid
确认要删除raid前,对应的物理盘槽位号
/opt/MegaRAID/MegaCli/MegaCli64 -LdPdInfo -aALL|egrep \
"RAID Level|^Size|Slot Number|Virtual Drive"|sed 's/Virtual/\nVirtual/g'
删除vd1,(L1)
/opt/MegaRAID/MegaCli/MegaCli64 -cfglddel -L1 -a0
3.重组raid
/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r0[32:2] WB Direct -a0
4.格式化
mkfs.xfs
5.挂载
mount
blkid