服务器-IPMI详解

IPMI、Intelligent Platform Management Interface(智能平台管理接口):一种开放标准的硬件管理接口规范,定义了如何与服务器上的BMC进行通信。

  • 核心作用:允许管理员独立于操作系统,通过网络远程管理服务器硬件,即使服务器关机或操作系统无响应,也能进行操作。(带外管理)
  • 与BMC的关系:BMC是“硬件”,IPMI是“语言”,IPMI控制BMC实现相关操作。
  • 常见功能如下:
远程电源管理 远程查看、控制服务器的开机、关机、重启
硬件健康监控 实时读取CPU温度、风扇转速、电压、电源状态等传感器数据
系统事件日志 查看和管理系统事件日志(SEL),用于故障排查
远程控制台

远程查看启动过程和操作系统控制台

1、KVM:远程桌面,带图形界面

2、Serial Over LAN:远程串口,纯命令行

3、JViewer:基于Java的远程桌面(KVM)

用户与安全

管理BMC的用户账号和权限

一、IPMI使用——安装和使用介绍

安装  
yum install ipmitool #Centos系列
apt install ipmitool #Ubuntu系列
ipmitool -h #查看帮助信息

 

Interfaces:接口类型,指定通过什么通道与BMC通信

Interfaces:
        open          Linux OpenIPMI Interface [default]
        imb           Intel IMB Interface
        lan           IPMI v1.5 LAN Interface
        lanplus       IPMI v2.0 RMCP+ LAN Interface
        serial-terminal  Serial Interface, Terminal Mode
        serial-basic  Serial Interface, Basic Mode
        usb           IPMI USB Interface(OEM Interface for AMI Devices)
接口类型含义使用场景
-I open 使用本地内核驱动(/dev/ipmi0) 在服务器本地操作系统内执行命令,无需网络
-I lan 通过IPMI v1.5协议进行网络连接 兼容旧设备,但安全性较低
-I lanplus

通过IPMI v2.0协议进行网络连接

(最常用

远程管理,支持加密和更强的认证,推荐使用
-I bmc

使用BMC的本地接口

(某些平台上支持)

较少使用
-I usb

通过USB连接BMC

(某些平台支持)

较少使用
使用   

命令格式:ipmitool [options...] <command>

options:选项,配置参数,控制“如何连接”BMC(比如远程BMC的IP,用户名及密码)

常用选项含义示例 
-H <ip> 目标BMC的IP地址  -H 172.19.66.22
-U <用户名> 登录BMC的用户名  -U admin
-P <密码> 登录BMC的密码  -P password123
-I <接口类型> 指定网络接口(见Interfaces介绍)  -I lanplus
-p <端口> 指定BMC的端口号(默认623)  -p 623
-C <加密套件> 指定IPMI v2.0的加密套件  -C 17
-L <权限级别>

指定会话的权限级别

(如USER、OPERATOR、ADMIN)

 -L ADMIN
       -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)
       -I intf        Interface to use
       -H hostname    Remote host name for LAN interface
       -p port        Remote RMCP port [default=623]
       -U username    Remote session username
-P password Remote session password -E Read password from IPMI_PASSWORD environment variable -K Read kgkey from IPMI_KGKEY environment variable

commands:命令,告诉BMC“要做什么”,后续进行详细行介绍

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

一、IPMI使用——实战命令

电源管理

本地命令

ipmitool power status #查看服务器当前电源状态
ipmitool power on #开机
ipmitool power reset #强制重启
ipmitool power cycle #冷重启(先断电再开机)

远程命令

ipmitool -H 172.19.66.22 -U admin -P password -I lanplus power status
ipmitool -H 172.19.66.22 -U admin -P password -I lanplus power on
ipmitool -H 172.19.66.22 -U admin -P password -I lanplus power reset 
ipmitool -H 172.19.66.22 -U admin -P password -I lanplus power cycle
网络配置  
ipmitool lan print 1 #打印通道1的网络信息,通常只有1个通道,id为1
ipmitool lan set 1 ipsrc dhcp #设置IP获取方式为DHCP,动态获取
ipmitool lan set 1 ipsrc static #设置IP获取方式为静态IP,需手动设置
ipmitool set 1 ipaddr <IP地址>
ipmitool set 1 netmask <子网掩码>
ipmitool set 1 defgw ipaddr <网关地址>
 

image

用户管理  
ipmitool user list 1 #列出通道1的所有用户,通常只有1个通道,id为1
ipmitool user set name <用户ID> <用户名> #添加用户,设置指定用户ID的用户名
ipmitool user set password <用户ID> <用户密码> #设置用户密码
#设置密码:如果开启了复杂密码验证使能,必须要有特殊字符、Test@123
#密码不符合复杂度要求,会出现报错
ipmitool user enable/disable <用户ID>  #启用或停用用户
ipmitool user priv 3 3 1 #设置用户权限(3是用户ID,3是OPERATOR级别,1是通道号)

ipmitool channel getaccess 1 <用户ID> #查看用户在该通道上的权限
#设置用户权限 ipmitool channel setaccess
1 USERID callin=on ipmi=on link=on privilege=4

image

查看传感器
ipmitool sensor list #列出所有传感器及其当前读数(温度、风扇等)
 
查看系统事件日志
ipmitool sel list    #查看系统事件日志,是排查硬件问题的利器
 
重启BMC
ipmitool mc reset warm/cold #有特殊需求时才用
 
SOL功能

ipmitool sol info 1 #查看SOL信息
ipmitool sol activate #激活SOL功能
#核心作用:通过串口远程查看BIOS/POST启动过程和操作系统内核早期信息
#常用于调试启动故障,现在基本很少使用

 
posted @ 2025-04-22 17:05  FengweiTech  阅读(409)  评论(0)    收藏  举报