Linux之ipmitool管理BMC详解

 更新时间:2024年11月29日 14:50:57   作者:零时搞学习  
这篇文章介绍了ipmitool的基本用法和一些常用的命令,包括获取传感器信息、显示系统信息、电源控制、显示事件日志和启用/禁用BMC用户等,还介绍了如何通过IPMI-over-LAN远程控制BMC,并提供了连接到远程BMC的基本步骤

BMC管理 – ipmitool

老规矩,先 help看看参数

[root@test ~]# 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)
       -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
       -f file        Read remote session password from file
       -z size        Change Size of Communication Channel (OEM)
       -S sdr         Use local file for remote SDR cache
       -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
       -6             Use only IPv6
       -a             Prompt for remote password
       -Y             Prompt for the Kg key for IPMIv2 authentication
       -e char        Set SOL escape character
       -C ciphersuite Cipher suite to be used by lanplus interface
       -k key         Use Kg key for IPMIv2 authentication
       -y hex_key     Use hexadecimal-encoded Kg key for IPMIv2 authentication
       -L level       Remote session privilege level [default=ADMINISTRATOR]
                      Append a '+' to use name/privilege lookup in RAKP1
       -A authtype    Force use of auth type NONE, PASSWORD, MD2, MD5 or OEM
       -P password    Remote session password
       -E             Read password from IPMI_PASSWORD environment variable
       -K             Read kgkey from IPMI_KGKEY environment variable
       -m address     Set local IPMB address
       -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
       -o oemtype     Setup for OEM (use 'list' to see available OEM types)
       -O seloem      Use file for OEM SEL event descriptions
       -N seconds     Specify timeout for lan [default=2] / lanplus [default=1] interface
       -R retry       Set the number of retries for lan/lanplus interface [default=4]

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)

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

ipmitool命令的基本格式是:

ipmitool [选项] <命令> [参数]

其中:

  • 选项是一些可选的开关,用于设置ipmitool的一些参数。
  • 命令是要执行的操作,如获取传感器信息等。
  • 参数是可选的,它们是指定要执行的特定操作所需的选项和值。

常用的ipmitool命令

1.获取传感器信息

ipmitool sensor get <Sensor ID>

其中,

<Sensor ID>是要获取的传感器的ID。

此命令将显示指定传感器的当前状态。

2.显示系统信息

ipmitool fru print

此命令将打印系统中所有可用的FRU(固件可重编程单元)信息。

3.电源控制

ipmitool power on   开启电源
ipmitool power off	关闭电源
ipmitool power reset	重置电源,按我的理解是没有完全断电的动作,类似系统的reboot
ipmitool power cycle	先关闭电源,再开启

这些命令用于控制服务器的电源状态。

4.显示事件日志

ipmitool sel list

此命令将显示系统的事件日志。

5.启用/禁用BMC用户

ipmitool user enable <用户ID>
ipmitool user disable <用户ID>

这些命令用于启用或禁用BMC用户。

以上是一些常用的ipmitool命令和它们的基本用法。

更多的ipmitool命令和选项可以通过ipmitool -h命令查看完整的帮助文档。

关于OS下设定BMC或远程控制服务器的BMC命令等

ipmitool可以通过IPMI-over-LAN(基于LAN的IPMI协议)来远程控制BMC。

要使用IPMI-over-LAN,您需要确保BMC已经配置并连接到网络。

通过IPMI-over-LAN连接到BMC并进行远程控制的步骤

1.确定BMC的IP地址

使用ipmitool lan print命令可以获取BMC的IP地址、MAC地址和子网掩码等信息。

如果BMC未配置IP地址,则需要在本地物理访问服务器以配置BMC。

2.连接到BMC

使用ipmitool lan set <参数>命令设置BMC的用户名、密码和IP地址等信息。

例如,下面的命令设置BMC的IP地址为192.168.1.100,并将用户名设置为admin,密码设置为password:

ipmitool lan set 1 ipsrc static
ipmitool lan set 1 ipaddr 192.168.1.100
ipmitool lan set 1 netmask 255.255.255.0
ipmitool lan set 1 defgw ipaddr 192.168.1.1
ipmitool user set name 2 admin
ipmitool user set password 2 password

注意:

这里假设BMC使用的是默认的LAN通道1。

如果使用的是其他通道,则需要将1替换为相应通道的数字。

3.启用IPMI-over-LAN功能

使用ipmitool channel info <通道号>命令检查BMC所在通道的IPMI-over-LAN功能是否已经启用。

如果未启用,可以使用以下命令启用:

ipmitool channel setaccess <通道号> 2 ipmi=on auth=off link=on privilege=4

这将启用指定通道的IPMI-over-LAN功能,并使得通过此通道的IPMI会话的权限级别为4(ADMINISTRATOR级别)。

4.连接到远程BMC

使用以下命令连接到远程BMC:

ipmitool -H <BMC IP地址> -U <用户名> -P <密码> -I lanplus <命令>

注意,这里使用了-I lanplus选项,以使用基于LAN的IPMI协议。

<命令>是您要执行的ipmitool命令。

例如:

要获取传感器信息,可以使用以下命令:

ipmitool -H 192.168.1.100 -U admin -P password -I lanplus sensor list

这将显示远程BMC的传感器列表信息。

总结

以上是通过ipmitool进行远程BMC控制的基本步骤。

请注意,远程BMC的访问权限应该是受限的,只有授权用户才能访问。此外,您还应该确保网络安全措施已经得到了应用,以确保远程访问的安全性。

这些仅为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

相关文章

  • 教你一步一步在linux中正确的安装Xcache加速php

    教你一步一步在linux中正确的安装Xcache加速php

    这篇文章主要介绍了教你一步一步在linux中正确的安装Xcache加速php,需要的朋友可以参考下
    2017-04-04
  • Linux中拷贝 cp命令中拷贝所有的写法详解

    Linux中拷贝 cp命令中拷贝所有的写法详解

    本篇文章主要介绍了Linux中拷贝 cp命令中拷贝所有的写法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下。
    2016-12-12
  • 浅谈在linux kernel中打印函数调用的堆栈的方法

    浅谈在linux kernel中打印函数调用的堆栈的方法

    下面小编就为大家带来一篇浅谈在linux kernel中打印函数调用的堆栈的方法。小编觉得挺不错的。现在就分享给大家。也给大家做个参考。一起跟随小编过来看看吧
    2016-12-12
  • ubuntu无法ssh远程,提示'Permission denied (publickey)'的解决方法

    ubuntu无法ssh远程,提示'Permission denied (publickey

    SSH(Secure Shell)是一种加密的网络协议,用于在网络上安全地传输数据,它被广泛用于远程登录和执行命令,有时候使用SSH登录时,可能会遇到错误消息Permission denied (publickey)导致登录失败,这种情况可能由多种原因引起,将探讨导致SSH登录失败的可能性,并提供解决方案
    2025-04-04
  • apache的文件工具类FileUtils详解

    apache的文件工具类FileUtils详解

    org.apache.commons.io.FileUtils是apache提供用来操作文件的工具类,可以简化文件操作,这篇文章主要介绍了apache的文件工具类FileUtils,需要的朋友可以参考下
    2023-11-11
  • Linux切换root用户的几种实现方式

    Linux切换root用户的几种实现方式

    在Linux系统中,root用户为超级用户,拥有最高权限,切换到root用户的常用方法包括使用su、sudo、sudo-i和sudosu命令,每种方法适用于不同场景,需根据实际需求选择,使用root权限需谨慎,以免对系统造成损坏
    2024-11-11
  • Linux join命令快速实现从大文件中匹配内容

    Linux join命令快速实现从大文件中匹配内容

    本文介绍了如何使用Linux命令和join命令进行大数据文件的高效匹配,通过对文件进行排序和使用join命令,可以显著提升匹配效率,同时,还讨论了数据准备、文件排序、join命令的应用以及数据整理的方法
    2025-11-11
  • Linux系统云服务器被入侵排查和解决方法

    Linux系统云服务器被入侵排查和解决方法

    当 Linux 系统的云服务器被入侵时,及时排查和解决问题是防止更大损失的关键,所以本文给大家详细介绍了Linux系统云服务器被入侵排查和解决方法,需要的朋友可以参考下
    2025-11-11
  • Centos7安装JDK11全过程

    Centos7安装JDK11全过程

    文章详细介绍了如何在Linux系统上下载、卸载和安装JDK 11,包括查看当前JDK版本、卸载旧版本、解压安装包、配置环境变量等步骤
    2026-03-03
  • linux下用cron定时执行任务的方法

    linux下用cron定时执行任务的方法

    呵呵,比较有用,网上摘抄的。留着备用吧。
    2008-06-06

最新评论