备注:一般我们在做raid的时候都是通过显示器或者远程控制口连接服务器,然后重启根据raid卡的步骤一步步完成下去的,这样效率比较低,所以一般如果不涉及到系统盘的情况下,我们可以通过命令行来搞定,从而提升效率。
前提:安装好MegaCli这个服务
查看raid: /opt/MegaRAID/MegaCli/MegaCli64 -PDList -a0 |grep -iE "slot|error|state|pre"
1)查出Device ID:
/opt/MegaRAID/MegaCli/MegaCli64 -PDlist -aALL | grep "Device ID"
Enclosure Device ID: 0
Enclosure Device ID: 0
Enclosure Device ID: 0
Enclosure Device ID: 0
Enclosure Device ID: 0
Enclosure Device ID: 0
Enclosure Device ID: 0
Enclosure Device ID: 0
Enclosure Device ID: 0
Enclosure Device ID: 0
Enclosure Device ID: 0
Enclosure Device ID: 0
Enclosure Device ID: 0
Enclosure Device ID: 0
2)查出sort ID:
/opt/MegaRAID/MegaCli/MegaCli64 -PDList -a0 |grep -iE "slot|error|state|pre" | grep "Slot Number"
Slot Number: 0
Slot Number: 1
Slot Number: 2
Slot Number: 3
Slot Number: 4
Slot Number: 5
Slot Number: 6
Slot Number: 7
Slot Number: 8
Slot Number: 9
Slot Number: 10
Slot Number: 11
Slot Number: 14
Slot Number: 15
3)建立raid0
/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r0 [0:3] WT Direct -a0
例子:
sort3和sort4建立raid1
/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r1 [0:3,0:4] WT Direct -a0
单独sort3做raid0
/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r0 [0:3] WT Direct -a0
清除所有raid配置
/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdDel -L0 -force -a0
清除当前raid中某个虚拟设备信息
/opt/MegaRAID/MegaCli/MegaCli64 -cfglddel -L1 -a0
说明:可能当前某个raid(ex:raid1)划分了两个磁盘,那么第一个就是L0,第二个就是L1等等。然后上面的命令是删除第二个虚拟设备。