Ipmitool工具安装以及常见使用方法

Ipmitool工具安装以及常见使用方法( Intelligent Platform Management Interface)
参考手册:http://ipmitool.sourceforge.net/manpage.html

最近一直在公司实习,目前用到过一个陌生的云物理机管理工具,也是OpenStack的插件IronicServer组件派生的管理工具。功能非常强大。操作起来也很方便,下面来逐一介绍ipmitool工具的安装以及常见使用:

一、 IPMITOOL安装方式

1 、 方式一:
IPMI( Intelligent Platform Management Interface)的第一种安装方式是编译安装。
这个是源地址:https://sourceforge.net/projects/ipmitool/

在这里插入图片描述

下载完成后,进行安装操作。
1、 tar -xvf ipmitool-1.8.18.tar.bz2
2、 cd ipmitool-1.8.18
3./configure
4、 make
5、make install
6、编译安装之后,要开启三个相关模块,
modprobe ipmi_si(如果是虚拟机的话,该模块可能无法启动)
modprobe ipmi_devintf
modprobe ipmi_msghandler
可以起一下该服务,并查看下模块有没有启动:

[root@openstack ~]# lsmod | grep ipmi
ipmi_si                57587  0 
ipmi_devintf           17603  0 
ipmi_msghandler        46607  2 ipmi_devintf,ipmi_si
[root@openstack ~]# 

如果缺少模块,那么ipmitool命令就会出现异常。
2、方法二:
方法二的安装就相对比较容易:
直接使用yum来进行安装操作。

在这里插入图片描述

[root@openstack ~]# yum install -y ipmitool.x86_64
Loaded plugins: fastestmirror
……
……
……
Installed:
  ipmitool.x86_64 0:1.8.18-7.el7                                                                                                                                                            

Dependency Installed:
  OpenIPMI.x86_64 0:2.0.27-1.el7           OpenIPMI-libs.x86_64 0:2.0.27-1.el7           OpenIPMI-modalias.x86_64 0:2.0.27-1.el7           net-snmp-libs.x86_64 1:5.7.2-43.el7_7.3          

Complete!


可以启动下IPMI服务

[root@openstack ~]# systemctl status ipmi
● ipmi.service - IPMI Driver
   Loaded: loaded (/usr/lib/systemd/system/ipmi.service; enabled; vendor preset: enabled)
   Active: active (exited) since Fri 2020-02-28 14:30:40 CST; 7s ago
  Process: 7748 ExecStart=/usr/libexec/openipmi-helper start (code=exited, status=0/SUCCESS)
 Main PID: 7748 (code=exited, status=0/SUCCESS)

Feb 28 14:30:40 openstack systemd[1]: Starting IPMI Driver...
Feb 28 14:30:40 openstack systemd[1]: Started IPMI Driver.

[root@openstack ~]# lsmod | grep ipmi
ipmi_si                57587  0 
ipmi_devintf           17603  0 
ipmi_msghandler        46608  1 ipmi_devintf,ipmi_si
[root@openstack ~]# 

这里再说明一下,如果环境是虚机的话,ipmi_si模块会无法启动,手动加载的话,会提示如下报错。
[root@openstacktest ~]# modprobe ipmi_si
modprobe: ERROR: could not insert 'ipmi_si': No such device
[root@openstacktest ~]# 

二、ipmitool使用方法

1、首先看下丰富的帮助提示
[root@openstack ~]# ipmitool help
Commands:
	raw           Send a RAW IPMI request and print response
	i2c           Send an I2C Master Write-Read command and print response
	spd           Print SPD info from remote I2C device
	lan           Configure LAN Channels
	chassis       Get chassis status and set power state
	power         Shortcut to chassis power commands
	event         Send pre-defined events to MC
	mc            Management Controller status and global enables
	sdr           Print Sensor Data Repository entries and readings
	sensor        Print detailed sensor information
	fru           Print built-in FRU and scan SDR for FRU locators
	gendev        Read/Write Device associated with Generic Device locators sdr
	sel           Print System Event Log (SEL)
	pef           Configure Platform Event Filtering (PEF)
	sol           Configure and connect IPMIv2.0 Serial-over-LAN
	tsol          Configure and connect with Tyan IPMIv1.5 Serial-over-LAN
	isol          Configure IPMIv1.5 Serial-over-LAN
	user          Configure Management Controller users
	channel       Configure Management Controller channels
	session       Print session information
	dcmi          Data Center Management Interface
	nm            Node Manager Interface
	sunoem        OEM Commands for Sun servers
	kontronoem    OEM Commands for Kontron devices
	picmg         Run a PICMG/ATCA extended cmd
	fwum          Update IPMC using Kontron OEM Firmware Update Manager
	firewall      Configure Firmware Firewall
	delloem       OEM Commands for Dell systems
	shell         Launch interactive IPMI shell
	exec          Run list of commands from file
	set           Set runtime variable for shell and exec
	hpm           Update HPM components using PICMG HPM.1 file
	ekanalyzer    run FRU-Ekeying analyzer using FRU files
	ime           Update Intel Manageability Engine Firmware
	vita          Run a VITA 46.11 extended cmd
	lan6          Configure IPv6 LAN Channels

a) raw:发送一个原始的IPMI请求,并且打印回复信息。
b) Lan:配置网络(lan)信道(channel)
c) chassis :查看底盘的状态和设置电源
d) event:向BMC发送一个已经定义的事件(event),可用于测试配置的SNMP是否成功
e) mc: 查看MC(Management Contollor)状态和各种允许的项
f) sdr:打印传感器仓库中的所有监控项和从传感器读取到的值。
g) Sensor:打印详细的传感器信息。
h) Fru:打印内建的Field Replaceable Unit (FRU)信息
i) Sel: 打印 System Event Log (SEL)
j) Pef: 设置 Platform Event Filtering (PEF),事件过滤平台用于在监控系统发现有event时候,用PEF中的策略进行事件过滤,然后看是否需要报警。
k) Sol/isol:用于配置通过串口的Lan进行监控
l) User:设置BMC中用户的信息 。
m) Channel:设置Management Controller信道。
[root@openstack ~]# 

2、常见的操作命令
  1. 远程电源控制类 远程电源控制类
[root@openstack ~]#   Ipmitool -I lanplus –H 10.32.228.111 –U username –P Password  chassis power off
[root@openstack ~]# Ipmitool -I lanplus –H 10.32.228.111 –U username –P Password  chassis power on
[root@openstack ~]# Ipmitool -I lanplus –H 10.32.228.111 –U username –P Password  chassis power reset
[root@openstack ~]# Ipmitool -I lanplus –H 10.32.228.111 –U username –P Password   chassis power cycle
  1. 读取系统状态类
[root@openstack ~]# Ipmitool sensor list  显示系统所有传感器列表
[root@openstack ~]# Ipmitool fru list   显示系统所有现场可替代器件的列表
[root@openstack ~]# Ipmitool sdr list   显示系统所有SDRRepository设备列表 
[root@openstack ~]# Ipmitool pef list   显示系统平台时间过滤的列表
  1. 系统日志类
[root@openstack ~]# Ipmitool sel elist   显示所有系统事件日志
[root@openstack ~]# Ipmitool sel clear   删除所有系统时间日志
[root@openstack ~]# Ipmitool sel delete ID 删除第ID条SEL
[root@openstack ~]# Ipmitool sel time get  显示当前BMC的时间
[root@openstack ~]# Ipmitool sel time set XXX 设置当前BMC的时间
  1. 启动设置类
[root@openstack ~]# Ipmitool chassis bootdev bios 重启后停在BIOS 菜单
[root@openstack ~]# Ipmitool chassis bootdev pxe 重启后从PXE启动
  1. 系统相关的命令
[root@openstack ~]# Ipmitool mc info 显示BMC版本信息
[root@openstack ~]# Ipmitool bmc reset cold BMC 热启动
[root@openstack ~]# Ipmitool bmc reset warmBMC冷启动
  1. 网络接口相关命令
[root@openstack ~]# Ipmitool lan print 1 显示channel1的网络配置信息
[root@openstack ~]# Ipmitool lan set 1ipaddr 10.32.2.2 设置channel1的IP地址
[root@openstack ~]# Ipmitool lan set 1 netmask 255.255.0.0 设置channel1的netmask
[root@openstack ~]# Ipmitool lan set 4 defgw ipaddr255.255.0.254 设置channel4的网关
[root@openstack ~]# Ipmitool lan set 2 defgw macaddr  设置channel2的网关mac address
[root@openstack ~]# Ipmitool lan set 2 ipsrc dhcp 设置channel2的ip 源在DHCP
[root@openstack ~]# Ipmitool lan set 3 ipsrc static 设置channel2的ip是静态获得的
  1. 通道相关命令
[root@openstack ~]# Ipmitool channel info 显示系统默认channel
[root@openstack ~]# Ipmitool channel authcap channel-number privilege  修改通道的优先级别
[root@openstack ~]# Ipmitool channel getaccess channel-number user-id 读取用户在通道上的权限
[root@openstack ~]# Ipmitool channel setacccess channel-number user-id callin=on ipmi=on link=onprivilege=5 // 设置用户在通道上的权限
  1. 用户管理相关命令
[root@openstack ~]# Ipmitool user list chan-id 显示某通道上的所有用户
[root@openstack ~]# Ipmitool set password [] 修改某用户的密码
[root@openstack ~]# Ipmitool disable   禁止掉某用户
[root@openstack ~]# ipmitool enable   使能某用户
[root@openstack ~]# ipmitool priv [] 修改某用户在某通道上的权限
[root@openstack ~]# ipmitool test <16|20>[<password]> 测试用户
  1. 系统管理常用的
1. 查看设备信息
/usr/bin/ipmitool -I lanplus -H 10.88.1.181 -U sysadmin -P admin chassis status

2. 查看用户
/usr/bin/ipmitool -I lanplus -H 10.88.1.181 -U sysadmin -P admin user list

3. 增加用户
/usr/bin/ipmitool -I lanplus -H 10.88.1.181 -U sysadmin -P admin user set name 3 test1
/usr/bin/ipmitool -I lanplus -H 10.88.1.181 -U sysadmin -P admin user list
/usr/bin/ipmitool -I lanplus -H 10.88.1.181 -U sysadmin -P admin user set password 3 test1
/usr/bin/ipmitool -I lanplus -H 10.88.1.181 -U sysadmin -P admin user priv 3 20
/usr/bin/ipmitool -I lanplus -H 10.88.1.181 -U sysadmin -P admin user list
/usr/bin/ipmitool -I lanplus -H 10.88.1.181 -U test1 -P test1 user list

4. disable/enable用户
/usr/bin/ipmitool -I lanplus -H 10.88.1.181 -U sysadmin -P admin user disable 3
/usr/bin/ipmitool -I lanplus -H 10.88.1.181 -U test1 -P test1 user list
/usr/bin/ipmitool -I lanplus -H 10.88.1.181 -U sysadmin -P admin user enable 3
/usr/bin/ipmitool -I lanplus -H 10.88.1.181 -U test1 -P test1 user list

5. 查看服务器当前开电状态
/usr/bin/ipmitool -I lanplus -H 10.88.1.181 -U sysadmin -P admin power status

6. 服务器的开机,关机,reset和power cycle
/usr/bin/ipmitool -I lanplus -H 10.88.1.181 -U sysadmin -P admin power on
/usr/bin/ipmitool -I lanplus -H 10.88.1.181 -U sysadmin -P admin power off
/usr/bin/ipmitool -I lanplus -H 10.88.1.181 -U sysadmin -P admin power cycle
/usr/bin/ipmitool -I lanplus -H 10.88.1.181 -U sysadmin -P admin power reset

7. 查看服务器的80 Port当前状态
/usr/bin/ipmitool -I lanplus -H 10.88.1.181 -U sysadmin -P admin raw 0x30 0xB2

8. 查看服务器的传感器状态
所有传感器状态详细信息:
/usr/bin/ipmitool -I lanplus -H 10.88.1.181 -U sysadmin -P admin sensor
传感器SDR summary信息:
/usr/bin/ipmitool -I lanplus -H 10.88.1.181 -U sysadmin -P admin sdr info
传感器SDR 列表信息:
/usr/bin/ipmitool -I lanplus -H 10.88.1.181 -U sysadmin -P admin sdr list
FRU传感器SDR 列表信息:
/usr/bin/ipmitool -I lanplus -H 10.88.1.181 -U sysadmin -P admin sdr list fru
下载RAW SDR信息到文件:
/usr/bin/ipmitool -I lanplus -H 10.88.1.181 -U sysadmin -P admin sdr dump sdr.raw

9. 查看服务器的FRU信息
/usr/bin/ipmitool -I lanplus -H 10.88.1.181 -U sysadmin -P admin fru
/usr/bin/ipmitool -I lanplus -H 10.88.1.181 -U sysadmin -P admin fru print

三、 举例说明(关于用户的操作)

  - H为需要操作的BMC ip,-I lanplus为使用rmcp+协议发送命令,-U 为操作命令的用户名,-P为用户密码。
1、查询所有用户
[root@openstack ~]# ipmitool -H 10.10.10.10 -I lanplus -U root -P admin user list
2、新增用户用户名和用户id不能和已有用户名用户id重复,如用户名test3,用户id为3
[root@openstack ~]# ipmitool -H 10.10.10.10 -I lanplus -U root -P admin user set name 3 test3
3、密码需要满足复杂度要求,如设置用户id为3的密码
[root@openstack ~]# ipmitool -H 10.10.10.10 -I lanplus -U root -P admin user set password 3 test3
4、权限取值范围2:USER,3:OPERATOR,4:ADMINISTRATOR,用户创建后的默认权限为NO ACCESS,没有访问权限。如设置用户id为3的权限,设置完成即可使用用户名密码访问BMC
[root@openstack ~]# ipmitool -H 10.10.10.10 -I lanplus -U root -P admin user priv 3 4

5 、 使能id为3的用户
[root@openstack ~]# ipmitool -H 10.10.10.10 -I lanplus -U root -P admin user enabled 3
四、举例说明(重启BMC系统和密码及参数重置)
1、BMC 服务器管理口死机远程http无法登陆

ipmitool -H (BMC的管理IP地址) -I lan -U (BMC登录用户名) -P (BMC 登录用户名的密码) mc reset warm
#lan参数 为接口连接的模式之一,远程通过网络执行的一般用lan 或lanplus,如果在本地ssh登录操作 可用open 参数

2、BMC 防火墙策略配置全部拒绝导致无法访问
登录该服务器系统后执行:

[root@openstack ~]# ipmitool raw 0x32 0x66  #恢复默认值

[root@openstack ~]# ipmitool lan set 1 ipsrc static  (设置ipmi ip非DHCP)

[root@openstack ~]# ipmitool lan set 1 ipaddr 192.168.0.1(设置IPMI  地址) 

[root@openstack ~]# ipmitool lan set 1 netmask 255.255.255.0 (设置ipmi 子网掩码)

[root@openstack ~]# ipmitool lan set 1 defgw ipaddr 192.168.0.1 (设置ipmi 网关)

[root@openstack ~]# ipmitool user set password 1 abcdefg      (修改ipmi 用户名1的密码)#root 修改后默认密码abcdefg

[root@openstack ~]# ipmitool user set password 2 abcdefg      (修改ipmi 用户名2的密码)#admin 修改后默认密码abcdefg

发布了159 篇原创文章 · 获赞 293 · 访问量 12万+

猜你喜欢

转载自blog.csdn.net/qq_28513801/article/details/104555654