运维管理利器系列 ipmitool

安装

yum -y install epel-release
yum -y install ipmitool
yum install OpenIPMI  ipmitool

加载模块

modprobe ipmi_watchdog
modprobe ipmi_poweroff
modprobe ipmi_devintf
modprobe ipmi_msghandler
modprobe ipmi_si

modprobe: ERROR: could not insert 'ipmi_si': No such device
原因:当前系统运行在虚拟机而非物理机上,只有运行在物理机上的CentOS系统才能用这个模块,没有不影响ipmi的使用。

可选操作:添加到/etc/modules
echo ipmi_devintf >> /etc/modules
echo ipmi_si >> /etc/modules

查看模块

lsmod | grep ipmi

image.png

image.png

启动服务

systemctl start ipmievd.service
systemctl status ipmievd.service

使用

1:通过系统查看物理机带外管理IP

[root@localhost tmp]# ipmitool lan print 1
Set in Progress         : Set Complete
Auth Type Support       : MD5
Auth Type Enable        : Callback : MD5
                        : User     : MD5
                        : Operator : MD5
                        : Admin    : MD5
                        : OEM      : MD5
IP Address Source       : Static Address
IP Address              : 192.168.206.57
Subnet Mask             : 255.255.255.0
MAC Address             : 6c:92:bf:9b:4c:49
SNMP Community String   : AMI
IP Header               : TTL=0x40 Flags=0x40 Precedence=0x00 TOS=0x10
BMC ARP Control         : ARP Responses Enabled, Gratuitous ARP Disabled
Gratituous ARP Intrvl   : 0.0 seconds
Default Gateway IP      : 192.168.206.1
Default Gateway MAC     : 58:60:5f:87:2e:c3
Backup Gateway IP       : 0.0.0.0
Backup Gateway MAC      : 00:00:00:00:00:00
802.1q VLAN ID          : Disabled
802.1q VLAN Priority    : 0
RMCP+ Cipher Suites     : 0,1,2,3,6,7,8,11,12,15,16,17
Cipher Suite Priv Max   : caaaaaaaaaaaXXX
                        :     X=Cipher Suite Unused
                        :     c=CALLBACK
                        :     u=USER
                        :     o=OPERATOR
                        :     a=ADMIN
                        :     O=OEM
Bad Password Threshold  : 0
Invalid password disable: no
Attempt Count Reset Int.: 0
User Lockout Interval   : 0

2:查询BMC中相关的SDR(传感器数据记录)信息

[root@k8s-node-gpu-dataswitch-p-222028 yum.repos.d]#  ipmitool sdr 或者 ipmitool sdr list
Inlet_Temp       | 24 degrees C      | ok
Outlet_Temp      | 37 degrees C      | ok
CPU0_Temp        | 63 degrees C      | ok
CPU1_Temp        | 52 degrees C      | ok
CPU0_DTS         | 4 degrees C       | ok
CPU1_DTS         | 7 degrees C       | ok
CPU0_DIMM_Temp   | 29 degrees C      | ok
CPU1_DIMM_Temp   | 29 degrees C      | ok
CPU0_VR_Temp     | 32 degrees C      | ok
CPU1_VR_Temp     | 33 degrees C      | ok
PCH_Temp         | 52 degrees C      | ok
OCP_Temp         | no reading        | ns
NVME_Temp        | 35 degrees C      | ok
PSU0_Temp        | 32 degrees C      | ok
PSU1_Temp        | 26 degrees C      | ok
RAID0_Temp       | no reading        | ns
RAID1_Temp       | no reading        | ns
RAID2_Temp       | no reading        | ns
RAID3_Temp       | no reading        | ns
GPU0_Temp        | no reading        | ns
GPU1_Temp        | 23 degrees C      | ok
GPU2_Temp        | no reading        | ns
GPU3_Temp        | no reading        | ns
GPU4_Temp        | 23 degrees C      | ok
GPU5_Temp        | no reading        | ns
GPU6_Temp        | no reading        | ns
GPU7_Temp        | no reading        | ns
PCIE_SSD0_Temp   | no reading        | ns
PCIE_SSD1_Temp   | no reading        | ns
PCIE_SSD2_Temp   | no reading        | ns
PCIE_SSD3_Temp   | no reading        | ns
PCIE_SSD4_Temp   | no reading        | ns
PCIE_SSD5_Temp   | no reading        | ns
PCIE_SSD6_Temp   | no reading        | ns
PCIE_SSD7_Temp   | no reading        | ns
M.2_Inlet_Temp   | 29 degrees C      | ok
Rear_HDDBP_Temp  | no reading        | ns
SWITCH0_Temp     | no reading        | ns
SWITCH1_Temp     | no reading        | ns
P3V3             | 3.28 Volts        | ok
P5V              | 5.08 Volts        | ok
P12V             | 12.06 Volts       | ok
CPU0_Vcore       | 1.76 Volts        | ok
CPU1_Vcore       | 1.76 Volts        | ok
CPU0_DDR_VDDQ1   | 1.22 Volts        | ok
CPU0_DDR_VDDQ2   | 1.22 Volts        | ok
CPU1_DDR_VDDQ1   | 1.22 Volts        | ok
CPU1_DDR_VDDQ2   | 1.22 Volts        | ok
CPU0_PVCCIO      | 1.01 Volts        | ok
CPU1_PVCCIO      | 1.00 Volts        | ok
PCH_P1V05        | 1.05 Volts        | ok
PCH_VNN          | 1 Volts           | ok
CPU0_Status      | 0x00              | ok
CPU1_Status      | 0x00              | ok
PSU0_Status      | 0x00              | ok
PSU1_Status      | 0x00              | ok
PSU_Redundant    | 0x00              | ok
PSU0_Fan_Status  | 0x00              | ok
PSU1_Fan_Status  | 0x00              | ok
FAN0_F_Speed     | 5760 RPM          | ok
FAN0_R_Speed     | 4896 RPM          | ok
FAN1_F_Speed     | 5760 RPM          | ok
FAN1_R_Speed     | 4896 RPM          | ok
FAN2_F_Speed     | 5760 RPM          | ok
FAN2_R_Speed     | 4896 RPM          | ok
FAN3_F_Speed     | 5760 RPM          | ok
FAN3_R_Speed     | 4896 RPM          | ok
FAN_M2_Speed     | 0 RPM             | ok
FAN0_Present     | 0x00              | ok
FAN1_Present     | 0x00              | ok
FAN2_Present     | 0x00              | ok
FAN3_Present     | 0x00              | ok
Total_Power      | 296 Watts         | ok
CPU_Power        | 158 Watts         | ok
MEM_Power        | 10 Watts          | ok
FAN_Power        | 25 Watts          | ok
HDD_Power        | 6 Watts           | ok
PSU0_POUT        | 136 Watts         | ok
PSU1_POUT        | 128 Watts         | ok
CPU0_C0D0        | 0x00              | ok
CPU0_C0D1        | 0x00              | ok
CPU0_C1D0        | 0x00              | ok
CPU0_C1D1        | 0x00              | ok
CPU0_C2D0        | 0x00              | ok
CPU0_C2D1        | 0x00              | ok
CPU0_C3D0        | 0x00              | ok
CPU0_C3D1        | 0x00              | ok
CPU0_C4D0        | 0x00              | ok
DISK0_Status     | 0x00              | ok
DISK1_Status     | 0x00              | ok
DISK2_Status     | 0x00              | ok
DISK3_Status     | 0x00              | ok
DISK4_Status     | 0x00              | ok
DISK5_Status     | 0x00              | ok
DISK6_Status     | 0x00              | ok
DISK7_Status     | 0x00              | ok
DISK8_Status     | 0x00              | ok
DISK9_Status     | 0x00              | ok
DISK10_Status    | 0x00              | ok
BMC_Boot_Up      | 0x00              | ok
ME_FW_Status     | 0x00              | ok
Event_Log        | 0x00              | ok
IPMI_Watchdog    | 0x00              | ok
CPU_ResourceRate | 0 unspecified     | ok
MEM_ResourceRate | 0 unspecified     | ok
HDD_ResourceRate | 0 unspecified     | ok
HDD_Max_Temp     | 35 degrees C      | ok

3:通过ipmitool修改带外管理IP

# 配置IP地址:
格式: ipmitool lan set 通道ID  ipaddr  IP地址
[root@localhost tmp]# ipmitool lan set 1 ipaddr 10.57.60.91
Setting LAN IP Address to 10.57.60.91

# 配置子网掩码:
格式: ipmitool lan set 通道ID  netmask  掩码地址
[root@localhost tmp]# ipmitool lan set 1 netmask 255.255.255.0
Setting LAN Subnet Mask to 255.255.255.0

# 配置网关地址:
格式: ipmitool  lan  set  通道ID  defgw  ipaddr  网关地址
[root@localhost tmp]# ipmitool lan set 1 defgw ipaddr 10.57.60.1
Setting LAN Default Gateway IP to 10.57.60.1

# 查看网络配置:
格式: ipmitool  lan  print 通道ID
[root@localhost tmp]# ipmitool lan print 1
Set in Progress         : Set Complete
Auth Type Support       : MD5 
Auth Type Enable        : Callback : MD5 
                        : User     : MD5 
                        : Operator : MD5 
                        : Admin    : MD5 
                        : OEM      : MD5 
IP Address Source       : Static Address
IP Address              : 10.57.60.91
Subnet Mask             : 255.255.255.0
MAC Address             : b4:05:5d:8b:8a:bd
SNMP Community String   : AMI
IP Header               : TTL=0x40 Flags=0x40 Precedence=0x00 TOS=0x10
BMC ARP Control         : ARP Responses Enabled, Gratuitous ARP Disabled
Gratituous ARP Intrvl   : 0.0 seconds
Default Gateway IP      : 10.57.60.1
Default Gateway MAC     : 00:00:00:00:00:00
Backup Gateway IP       : 0.0.0.0
Backup Gateway MAC      : 00:00:00:00:00:00
802.1q VLAN ID          : Disabled
802.1q VLAN Priority    : 0
RMCP+ Cipher Suites     : 0,1,2,3,6,7,8,11,12,15,16,17
Cipher Suite Priv Max   : caaaaaaaaaaaXXX
                        :     X=Cipher Suite Unused
                        :     c=CALLBACK
                        :     u=USER
                        :     o=OPERATOR
                        :     a=ADMIN
                        :     O=OEM
Bad Password Threshold  : 3
Invalid password disable: no
Attempt Count Reset Int.: 200
User Lockout Interval   : 300

4:启动相应驱动模块

[root@localhost tmp]# modprobe ipmi_msghandler
[root@localhost tmp]# modprobe ipmi_devintf
[root@localhost tmp]# modprobe ipmi_si
[root@localhost tmp]# modprobe ipmi_poweroff
[root@localhost tmp]# modprobe ipmi_watchdog
[root@localhost tmp]# 
[root@localhost tmp]# 
[root@localhost tmp]# lsmod |grep ^ipmi
ipmi_watchdog          32768  0
ipmi_poweroff          16384  0
ipmi_ssif              32768  0
ipmi_si                65536  2
ipmi_devintf           20480  0
ipmi_msghandler       110592  5 ipmi_devintf,ipmi_si,ipmi_watchdog,ipmi_ssif,ipmi_poweroff

5:ipmitool 电源管理

ipmitool -I lanplus -H 192.168.205.143 -U admin -P 密码 power off (硬关机,直接切断电源)
										  
ipmitool -I lanplus -H 192.168.205.143 -U admin -P 密码 power soft (软关机,即如同轻按一下开机按钮)
										  
ipmitool -I lanplus -H 192.168.205.143 -U admin -P 密码 power on (硬开机)
										  
ipmitool -I lanplus -H 192.168.205.143 -U admin -P 密码 power reset (硬重启)
										  
ipmitool -I lanplus -H 192.168.205.143 -U admin -P 密码 power status (获取当前电源状态)
										  
ipmitool -I lanplus -H 192.168.205.143 -U admin -P 密码 chassis power cycle

注意: power cycle 和power reset的区别在于前者从掉电到上电有1秒钟的间隔,而后者是很快上电

6:重置服务器BMC IP地址

ipmitool -I lanplus -H 192.168.205.143 -U admin -P admin mc reset cold

7:IPMItool命令备忘单

IPMItool命令描述
ipmitool help显示IPMItool的帮助信息
ipmitool mc info检查固件版本
ipmitool mc reset [warm/cold]重置管理控制器
ipmitool fru print显示字段可替换单元的详细信息
传感器输出命令描述
ipmitool sdr list列出系统上的所有传感器名称。每个传感器将映射到其相应的传感器编号
ipmitool sdr type list列出系统上的所有传感器类型。
ipmitool sdr type Fan列出系统上的所有风扇类型传感器。
ipmitool sdr type "Power Supply"列出系统上的所有电源类型传感器。
ipmitool sdr type Temperature列出系统上的所有温度类型传感器。
机箱IPMItoll命令描述
ipmitool chassis status ipmitool chassis identify []打开前面板识别灯
ipmitool [chassis] power soft通过acpi进行软关机
ipmitool [chassis] power cycle强制关闭电源,等待1秒然后再打开电源的组合
ipmitool [chassis] power off硬断电
ipmitool [chassis] power on硬启动
ipmitool [chassis] power reset硬重置
修改启动设备描述
ipmitool chassis bootdev pxe修改启动顺序以首先启动pxe
ipmitool chassis bootdev cdrom修改启动顺序以首先启动cdrom
ipmitool chassis bootdev bios修改引导顺序以首先引导BIOS
记录IPMItools命令描述
ipmitool sel info返回有关系统事件日志的常规信息
ipmitool sel list返回系统事件日志列表
ipmitool sel elist返回与传感器数据日志交叉引用的系统事件日志的列表
ipmitool sel get ID返回有关特定事件日志的详细信息(使用事件ID指定哪个日志)
ipmitool sel clear清除事件日志