1. Raid相关:
# 删除已有的Raid配置
MegaCli64 -CfgLdDel -LALL -aALL
# 获取设备ID和槽号
MegaCli64 -PDList -aALL|egrep ‘Enclosure Device ID|Slot Number‘|awk ‘NR%2==0{print $3};NR%2!=0{print $4;}‘
# 创建Raid5,$sdaslots为构造的符合参数要求的用来创建Raid的磁盘ID和槽号,大小为500G
MegaCli64 -CfgLdAdd -r5 "$sdaslots" WB RA Direct CachedBadBBU -sz500GB -a0
2. 远程管理卡操作,使用sshpass则不需要手动输入密码, $user和$ip分别为iDRAC设备用户名和密码:
# 打开系统电源
sshpass -p $password ssh -o ConnectTimeout=90 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet [email protected]$ip racadm serveraction powerup
# 打开系统电源从PXE启动,主要是为了通过网络安装系统
sshpass -p $password ssh -o ConnectTimeout=90 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet [email protected]$ip racadm config -g cfgServerInfo -o cfgServerBootOnce
sshpass -p $password ssh -o ConnectTimeout=90 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet [email protected]$ip racadm config -g cfgServerInfo -o cfgServerFirstBootDevice PXE
sshpass -p $password ssh -o ConnectTimeout=90 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet [email protected]$ip racadm serveraction powercycle
# 获取系统电源状态
sshpass -p $password ssh -o ConnectTimeout=90 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet [email protected]$ip racadm serveraction powerstatus 2>/dev/null|awk ‘{print $4}‘
# 关闭系统电源
sshpass -p $password ssh -o ConnectTimeout=90 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet [email protected]$ip racadm serveraction powerdown