自动化运维-IPMI详细操作介绍

IPMI硬件管理

IPMI是一个开放的标准,是用于管理基于 Intel架构服务器的工业标准,由英特尔、HP、NEC、DELL等公司制定。用户可以利用IPMI监视服务器的物理健康特征,如温度、电压、风扇工作状态、电源状态等。 2004年Intel发表了IPMI 2.0的规格,能够向下相容IPMI 1.0、1.5,新增了Console Redirection,并可以通过以太网远程管理服务器。

IPMI主要的功能

IPMI 操作方法

今天主要来说一下IPMI具体的使用操作方法,从常规的ipmitool命令行操作到Python脚本控制,基本能涵盖到日常运维所涉及的所有操作。

ipmitool 是一种可用在 linux 系统下的命令行方式的 ipmi 平台管理工具,它支持 ipmi 2.0规范,通过它可以实现获取传感器的信息、显示系统日志内容、网络远程开关机等功能。

命令行操作实例

进入BMC sh(ipmitool交互界面)

$ ipmitool -I open shell
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
……

查看开关机状态

$ ipmitool power status
Chassis Power is on

开机/关机

$ ipmitool power on 
$ ipmitool power off

查看当前用户

$ ipmitool user list 2
ID Name Callin Link Auth IPMI Msg Channel Priv Limit
1 Administrator true false true ADMINISTRATOR
2 (Empty User) true false false NO ACCESS
……

增加用户

$ ipmitool user set name 2 test01 
$ ipmitool user set password 2 password123

查看BMC IP地址

$ ipmitool lan print 2
……
IP Address Source :  Static Address
IP Address :         192.168.1.222
Subnet Mask :        255.255.255.0
MAC Address :        38:ea:a7:a9:xx:xx
……

修改BMC IP地址

$ ipmitool lan set 2 ipsrc static 
$ ipmitool lan set 2 ipaddr 192.168.1.1
$ ipmitool lan set 2 netmask 255.255.255.0 
$ ipmitool lan set 2 defgw 192.168.1.254

查看日志

$ ipmitool sel list
 10c | 11/07/2022 | 06:47:24 | Temperature #0x03 | Upper Critical going high | Asserted
 10d | 11/07/2022 | 06:47:33 | Temperature #0x03 | Upper Critical going high | Asserted
 10e | 11/07/2022 | 06:48:57 | System ACPI Power State #0xd5 | S4/S5: soft-off | Asserted
 10f | 11/08/2022 | 00:46:40 | System ACPI Power State #0xd5 | S0/G0: working | Asserted
 110 | 11/08/2022 | 01:52:23 | Memory #0x40 | Uncorrectable ECC | Asserted
 111 | 11/08/2022 | 01:52:33 | Memory #0x40 | Uncorrectable ECC | Asserted
 112 | 11/14/2022 | 06:48:58 | Temperature #0x30 | Upper Critical going high | Asserted
 …… 
$ ipmitool sel help
SEL Commands: 
info clear delete list elist get add time save readraw writeraw interpret

查看FRU信息

$ ipmitool fru list
FRU Device Description : Builtin FRU Device (ID 0)
 Chassis Type : Rack Mount Chassis
 Chassis Serial : *****  
 Board Mfg Date : Wed Oct 21 20:00:00 2009
 Board Mfg : HP
 Board Product : ProLiant DL380p Gen8
 Board Serial : *****  
 Board Part Number : 653200-B21  
 Product Manufacturer : HP
 Product Name : ProLiant DL380p Gen8
 Product Part Number : 653200-B21  
 Product Serial : *****

FRU Device Description : BMC CONTROLLER (ID 238)
 Product Manufacturer : HPE
 Product Name : BMC CONTROLLER
 Product Part Number : iLO 4
……

设置为光盘启动

$ ipmitool chassis bootparam set bootflag force_cdrom
bootparam set bootflag  [options=...]
 Legal devices are:
 none : No override
 force_pxe : Force PXE boot
 force_disk : Force boot from default Hard-drive
 force_safe : Force boot from default Hard-drive, request Safe Mode
 force_diag : Force boot from Diagnostic Partition
 force_cdrom : Force boot from CD/DVD
 force_bios : Force boot into BIOS Setup

重启BMC

$ ipmitool mc reset cold

注:以上命令中均在本机执行,如果对网络中其它主机进行操作,需要指定BMC 的IP地址、用户名和密码:

-H hostname Remote host name for LAN interface

-U username Remote session username

-P password Remote session password

Python操作实例

安装所需的软件包(第三方),拿HP iLO示例

$ pip install python-hpilo

导入软件包,获取服务器物理状态

# -*- coding: utf-8 -*-

import pprint
import hpilo

ilo = hpilo.Ilo("192.168.1.1", "admin", "password")
health_summary = ilo.get_embedded_health()['health_at_a_glance']

pprint.pprint(health_summary)

获取IML日志:

# 查看IML(Integrated Management log)日志
logs = ilo.get_server_event_log()
for log in logs:
   print(log)

查看Event日志

# 查看 iLO Event log
events = ilo.get_ilo_event_log()
for event in events:
   print(event)

主要方法:

方法

功能

get_embedded_health()

获取服务器物理状态信息

press_pwr_btn()

按一下电源键

hold_pwr_btn()

长按电源键

reset_rib()

重置ilo

reset_server()

重启服务器

cold_boot_server()

冷重启

warm_boot_server()

热重启

get_ilo_event_log()

获取ilo event日志

get_server_event_log()

获取IML日志

展开阅读全文

页面更新:2024-05-27

标签:操作   软件包   物理   电源   状态   地址   服务器   硬件   用户   详细   日志

1 2 3 4 5

上滑加载更多 ↓
推荐阅读:
友情链接:
更多:

本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828  

© CopyRight 2020-2024 All Rights Reserved. Powered By 71396.com 闽ICP备11008920号-4
闽公网安备35020302034903号

Top