ipmitool 是一种可用在 linux 系统下的 ipmi 平台管理工具,它支持 ipmi 1.5 规范(最新的规范为 ipmi 2.0),通过它可以实现获取传感器的信息、显示系统日志内容、网络远程开关机等功能
1、软件安装启用
1.1 源码安装
wget https://downloads.sourceforge.net/project/ipmitool/ipmitool/1.8.18/ipmitool-1.8.18.tar.bz2
tar -jxf ipmitool-1.8.18.tar.bz2
cd ipmitool-1.8.18
./configure --prefix=/usr/local/ipmitool
make && make install
ln -s /usr/local/ipmitool/bin/ipmitool /usr/bin/ipmitool
1.2 在线安装
# Ubuntu
apt -y install ipmitool
# centos
yum -y install ipmitool
1.3 服务启用
启动服务
systemctl start ipmitool.service
开机自启动
systemctl enable ipmitool.service
1.4 加载相关驱动
modprobe ipmi_watchdog;modprobe ipmi_poweroff;modprobe ipmi_devintf;modprobe ipmi_si;modprobe ipmi_msghandler
2、ipmi常用选项
2.1 常用选项与子命令
2.1.1 常用选项
| 选项 | 含义 |
|---|---|
| -I【大写i】 | 指定接口 |
| -H | 主机 |
| -U | 用户名 |
| -P | 密码 |
2.1.2 接口类型
| 接口类型 | 含义 |
|---|---|
| open | openipmi接口 |
| imb | 英特尔IMB接口 |
| lan | v1.5 LAN接口 |
| lanplus | v2.0 RMCP+LAN接口 |
| serial-terminal | 串行接口,终端模式 |
| serial-basic | 串行接口,基本模式 |
| usb | usb接口,用于AMI设备的OEM接口 |
2.1.3 子命令及说明
raw # 发送一个原始的IPMI请求,并且打印回复信息
lan # 配置网络(lan)信道(channel)
chassis # 查看底盘的状态和配置电源
event # 向BMC发送一个已定义的事件(event),可用于测试配置的SNMP是否成功
mc # 查看MC(Management Contollor)状态和各种允许的项
sdr # 打印传感器仓库中的任何监控项和从传感器读取到的值。
sensor # 打印周详的传感器信息。
Fru # 打印内建的Field Replaceable Unit (FRU)信息
sel # 打印 System Event Log (SEL)
pef # 配置 Platform Event Filtering (PEF),事件过滤平台用于在监控系统发现有event时候,用PEF中的策略进行事件过滤,然后看是否需要报警。
sol/isol # 用于配置通过串口的Lan进行监控
user # 配置BMC中用户的信息 。
channel # 配置Management Controller信道。
2.2 详细选项与子命令
[root@localhost ~]# ipmitool -h
ipmitool version 1.8.18
usage: ipmitool [options...] <command>
-h This help
#这个帮助信息
-V Show version information
#显示版本信息
-v Verbose (can use multiple times)
#详细(可以多次使用)
-c Display output in comma separated format
#以逗号分隔格式显示输出
-d N Specify a /dev/ipmiN device to use (default=0)
#指定要使用的/dev/ipmiN设备(默认值=0)
-I intf Interface to use
#要使用的接口
-H hostname Remote host name for LAN interface
#LAN接口的远程主机名
-p port Remote RMCP port [default=623]
#远程RMCP端口[默认值=623]
-U username Remote session username
#远程会话用户名
-f file Read remote session password from file
#从文件中读取远程会话密码
-z size Change Size of Communication Channel (OEM)
#改变通信渠道的规模(OEM)
-S sdr Use local file for remote SDR cache
#将本地文件用于远程SDR缓存
-D tty:b[:s] Specify the serial device, baud rate to use, and, optionally, specify that interface is the system one
#指定要使用的串行设备、波特率,并可选择指定接口为系统接口
-4 Use only IPv4
#仅使用IPv4
-6 Use only IPv6
#仅使用IPv6
-a Prompt for remote password
#提示输入远程密码
-Y Prompt for the Kg key for IPMIv2 authentication
#提示输入用于IPMIv2身份验证的Kg密钥
-e char Set SOL escape character
#设置SOL转义符
-C ciphersuite Cipher suite to be used by lanplus interface
#lanplus接口使用的密码套件
-k key Use Kg key for IPMIv2 authentication
#使用Kg密钥进行IPMIv2身份验证
-y hex_key Use hexadecimal-encoded Kg key for IPMIv2 authentication
#使用十六进制编码的Kg密钥进行IPMIv2身份验证
-L level Remote session privilege level [default=ADMINISTRATOR], Append a '+' to use name/privilege lookup in RAKP1
#远程会话权限级别[默认值=ADMINISTRATOR],附加一个“+”以在RAKP1中使用名称/权限查找
-A authtype Force use of auth type NONE, PASSWORD, MD2, MD5 or OEM
#强制使用身份验证类型NONE、PASSWORD、MD2、MD5或OEM
-P password Remote session password
#远程会话密码
-E Read password from IPMI_PASSWORD environment variable
#从IPMI_password环境变量读取密码
-K Read kgkey from IPMI_KGKEY environment variable
#从IPMI_kgkey环境变量读取kgkey
-m address Set local IPMB address
#设置本地IPMB地址
-b channel Set destination channel for bridged request
#设置桥接请求的目标通道
-t address Bridge request to remote target address
#桥接请求到远程目标地址
-B channel Set transit channel for bridged request (dual bridge)
#设置桥接请求的传输通道(双桥)
-T address Set transit address for bridge request (dual bridge)
#设置网桥请求的传输地址(双桥)
-l lun Set destination lun for raw commands
#为原始命令设置目标lun
-o oemtype Setup for OEM (use 'list' to see available OEM types)
#OEM设置(使用“列表”查看可用的OEM类型)
-O seloem Use file for OEM SEL event descriptions
#使用文件进行OEM SEL事件描述
-N seconds Specify timeout for lan [default=2] / lanplus [default=1] interface
#指定lan[默认值=2]/lanplus[默认值=1]接口的超时
-R retry Set the number of retries for lan/lanplus interface [default=4]
#设置lan/lanplus接口的重试次数[默认值=4]
Interfaces:
open Linux OpenIPMI Interface [default]
#Linux OpenIPMI接口[默认值]
imb Intel IMB Interface
#英特尔IMB接口
lan IPMI v1.5 LAN Interface
#IPMI v1.5 LAN接口
lanplus IPMI v2.0 RMCP+ LAN Interface
#IPMI v2.0 RMCP+LAN接口
serial-terminal Serial Interface, Terminal Mode
#串行接口,终端模式
serial-basic Serial Interface, Basic Mode
#串行接口,基本模式
usb IPMI USB Interface(OEM Interface for AMI Devices)
#IPMI USB接口(用于AMI设备的OEM接口)
Commands:
raw Send a RAW IPMI request and print response
#发送RAW IPMI请求和打印响应
i2c Send an I2C Master Write-Read command and print response
#发送I2C主机写-读命令和打印响应
spd Print SPD info from remote I2C device
#从远程I2C设备打印SPD信息
lan Configure LAN Channels
#配置LAN通道
chassis Get chassis status and set power state
#获取机箱状态并设置电源状态
power Shortcut to chassis power commands
#机箱电源命令的快捷方式
event Send pre-defined events to MC
#向MC发送预定义事件
mc Management Controller status and global enables
#Management Controller状态和全局启用
sdr Print Sensor Data Repository entries and readings
#打印传感器数据存储库条目和读数
sensor Print detailed sensor information
#打印详细的传感器信息
fru Print built-in FRU and scan SDR for FRU locators
#打印内置FRU并扫描SDR以查找FRU定位器
gendev Read/Write Device associated with Generic Device locators sdr
#与通用设备定位器sdr关联的读/写设备
sel Print System Event Log (SEL)
#打印系统事件日志(SEL)
pef Configure Platform Event Filtering (PEF)
#配置平台事件筛选(PEF)
sol Configure and connect IPMIv2.0 Serial-over-LAN
#配置和连接LAN上的IPMIv2.0串行
tsol Configure and connect with Tyan IPMIv1.5 Serial-over-LAN
#通过局域网配置和连接Tyan IPMIv1.5串行
isol Configure IPMIv1.5 Serial-over-LAN
#配置LAN上的IPMIv1.5串行
user Configure Management Controller users
#配置Management Controller用户
channel Configure Management Controller channels
#配置Management Controller通道
session Print session information
#打印会话信息
dcmi Data Center Management Interface
#数据中心管理界面
nm Node Manager Interface
#节点管理器界面
sunoem OEM Commands for Sun servers
#用于Sun服务器的OEM命令
kontronoem OEM Commands for Kontron devices
#Kontron设备的OEM命令
picmg Run a PICMG/ATCA extended cmd
#运行PICMG/ATCA扩展命令
fwum Update IPMC using Kontron OEM Firmware Update Manager
#使用Kontron OEM固件更新管理器更新IPMC
firewall Configure Firmware Firewall
#配置固件防火墙
delloem OEM Commands for Dell systems
#用于Dell系统的OEM命令
shell Launch interactive IPMI shell
#启动交互式IPMI外壳
exec Run list of commands from file
#从文件运行命令列表
set Set runtime variable for shell and exec
#为shell和exec设置运行时变量
hpm Update HPM components using PICMG HPM.1 file
#使用PICMG HPM.1文件更新HPM组件
ekanalyzer run FRU-Ekeying analyzer using FRU files
#使用FRU文件运行FRU Ekeying分析器
ime Update Intel Manageability Engine Firmware
#更新英特尔可管理性引擎固件
vita Run a VITA 46.11 extended cmd
#运行VITA 46.11扩展命令
lan6 Configure IPv6 LAN Channels
#配置IPv6 LAN通道
3、常用命令
3.1 带外管理
3.1.1 设备管理
# 获取服务器电源状态
impitool -H <bmc-ip> -I lanplus -U <bmc-user> -P <bmc-password> powerstatus
# 远程开启服务器
impitool -H <bmc-ip> -I lanplus -U <bmc-user> -P <bmc-password> power on
# 远程关闭服务器(硬关机,如同切断电源)
ipmitool -H <bmc-ip> -I lanplus -U <bmc-user> -P <bmc-password> power off
# 远程关闭服务器(软关机,如同点击电源开关)
ipmitool -H <bmc-ip> -I lanplus -U <bmc-user> -P <bmc-password> power soft
# 远程重启服务器
impitool -H <bmc-ip> -I lanplus -U <bmc-user> -P <bmc-password> power reset
# 关闭电源后立即开启电源
或
impitoll -H <bmc-ip> -I lanplus -U <bmc-user> -P <bmc-password> cycle
# 关闭电源后等待1s后开启电源
# 远程重启BMC(热、冷重启)
impitool -H <bmc-ip> -I lanplus -U <bmc-user> -P <bmc-password> mc reset <warm|cold>
# 远程查看BMC信息
impitool -H <bmc-ip> -I lanplus -U <bmc-user> -P <bmc-password> mc info
3.1.2 SOL会话管理
# 查询SOL参数信息及设置:
ipmitool -H <bmc-ip> -I lanplus -U <bmc-user> -P <bmc-password> sol info
# 激活SOL对话:
ipmitool -H <bmc-ip> -I lanplus -U <bmc-user> -P <bmc-password> sol activate
3.1.3 用户管理
# 查询用户数据库概要信息
ipmitool -H <bmc-ip> -I lanplus -U <bmc-user> -P <bmc-password> user summary
# 列出所有用户信息
ipmitool -H <bmc-ip> -I lanplus -U <bmc-user> -P <bmc-password> user list
# 打印lan接口参数信息
impitool -H <bmc-ip> -I lanplus -U <bmc-user> -P <bmc-password> lan print 1
# 获取BMC相关信息
impitool -H <bmc-ip> -I lanplus -U <bmc-user> -P <bmc-password> mc info
# 获取FRU信息
impitool -H <bmc-ip> -I lanplus -U <bmc-user> -P <bmc-password> fru
# 获取SDR传感器信息
impitool -H <bmc-ip> -I lanplus -U <bmc-user> -P <bmc-password> sdr list
# 获取SEl相关信息
impitool -H <bmc-ip> -I lanplus -U <bmc-user> -P <bmc-password> sel sinfo
# 获取SEL日志信息
impitool -H <bmc-ip> -I lanplus -U <bmc-user> -P <bmc-password> sel list
# 获取SEL日志详情
impitool -H <bmc-ip> -I lanplus -U <bmc-user> -P <bmc-password> sel elist
# 设置服务器启动选项
impitool -H <bmc-ip> -I lanplus -U <bmc-user> -P <bmc-password> chassis bootdev <none|pxe|disk|safe|diag|cdrom|bios|floppy>
# pxe:预启动执行环境(Preboot Execution Environment)
# disk:硬盘
# safe:安全模式
# diag:诊断模式
# cdrom:光驱
# bios:基本输入输出系统
# floppy:软盘
3.2 带内管理
3.2.1 传感器管理
#获取传感器信息:
ipmitool sensor list/ipmitool sdr elist
# 获取CPU温度:
ipmitool sensor list | grep CPU0_DIE0_TEMP
# 注:一个CPU有多个die,对应传感器名称为
CPU0_DIE0_TEMP/CPU0_DIE1_TEMP/CPU0_DIE2_TEMP/CPU0_DIE3_TEMP
# 获取整机功耗:
ipmitool sensor list | grep Total_Power
# 获取风扇转速:
ipmitool sensor list | grep FAN
3.2.2 设置BMC网络
# 查看BMC网络信息(通常配置通道1):
ipmitool lan print 1
# 设置通道1使用静态IP地址:
ipmitool lan print 1
#设置BMC使用IP地址:
ipmitool lan set 1 ipaddr 172.16.21.98
#设置BMC使用子网掩码:
ipmitool lan set 1 netmask 255.255.255.0
#设置BMC使用网关:
ipmitool lan set 1 defgw ipaddr 172.16.21.205
3.2.3 设置BMC用户
#查看BMC用户信息:
ipmitool user list 1
#设置BMC用户密码:
ipmitool user set password {bmc-user-id} {bmc-password}
#注:{bmc-password}需要考虑密码复杂程度(字母、数字、特殊字符等,如admin@123),否则会设置密码失败,提示Set User Password command failed(user 2)
3.2.4 新建BMC用户
#新建BMC用户:
ipmitool user set name {bmc-user-id} {bmc-user-name}
#设置用户密码:
ipmitool user set password {bmc-user-id} {bmc-password}
#启用BMC用户:
ipmitool user enable {bmc-user-id}
#设置用户权限:
ipmitool channel setaccess {channel-number} {bmc-user-id} callin=on ipmi=on link=on privilege={privilege-level}
#{channel-number} 通常为1
#{privilege-level} 表示权限级别,可选参数为1~5,其中4表示为管理员权限
# 0x1 - Callback
# 0x2 - User
# 0x3 - 0perator
# 0x4 - Administrator
# 0x5 - 0EM Proprietary
# 0xF - not access
4、示例
4.1 新增用户并这设置为adminstor权限
ipmitool -I lanplus -H 172.16.20.45 -U admin -P Password@_ user set name 10 liang # 新增BMC用户liang,userid为10
ipmitool -I lanplus -H 172.16.20.45 -U admin -P Password@_ user set password 10 Password@_ # 设置BMC用户liang的密码
ipmitool -I lanplus -H 172.16.20.45 -U admin -P Password@_ user priv 10 4 #设置用户ID为10的BMC用户权限为administator
4.2 刷机器FRU信息
# 查看机器 FRU 信息
ipmitool -I lanplus -H 10.99.74.34 -U admin -P Password@_ fru list
# 刷新
ipmitool.exe -H 10.99.74.35 -I lanplus -U admin -P Password@_ fru edit 0 field p 0 "New H3C Technologies Co., Ltd."
ipmitool.exe -H 10.99.60.48 -I lanplus -U admin -P Password@_ fru edit 0 field p 1 "H3C UniServer R4950 G5"
4.3 IP地址设置
ipmitool lan set 0x01 ipsrc static
ipmitool lan set 0x01 ipaddr 172.16.2.111
ipmitool lan set 0x01 netmask 255.255.128.0
4.4 海光 3 号机器 设置 HDM 网口 Mac 地址
# 测试流程:
#1.查看装备模式
ipmitool raw 0x36 0x02 0x20 0x14 0x00 0x80 0xcb 0x01 0x00
#2.打开装备模式
ipmitool raw 0x36 0x02 0x20 0x14 0x00 0x80 0xcb 0x01 0x01 0x01
#3.关闭装备模式
ipmitool raw 0x36 0x02 0x20 0x14 0x00 0x80 0xcb 0x01 0x01 0x00
# 海光机器 3 号机器 进入 BMC 串口需拨动主板上的第二个拨码
# 海光机器 3 号机器 永久更新设置 BMC 口的 Mac 地址
ipmitool -I lanplus -H 172.16.101.101 -U admin -P Password@_ raw 0x36 0x09 0xa2 0x63 0x00 0x38 0x01
# 设置专用口的 Mac 地址,倒数第 8 个字段:0x02; 后 6 个为具体的 Mac 地址,Mac 地址第一段最低位不能为 1
ipmitool -I lanplus -H 172.16.101.101 -U admin -P Password@_ raw 0x36 0x02 0x20 0x14 0x00 0x80 0x57 0x02 0x00 0xc4 0x34 0x6b 0x3f 0x01 0x01
# 设置共享口的 Mac 地址,倒数第 8 个字段:0x01; 后 6 个为具体的 Mac 地址
ipmitool -I lanplus -H 172.16.101.101 -U admin -P Password@_ raw 0x36 0x02 0x20 0x14 0x00 0x80 0x57 0x01 0x00 0xc4 0x34 0x6b 0x3f 0x01 0x01
本文参考并总结其他博客信息,再次特别感谢。
参考博客信息如下:
[# 服务器增强管理利器---Ipmitool](https://www.cnblogs.com/shiwei1930/p/17853915.html)
浙公网安备 33010602011771号