Ironic Key Technologies--IPMI

IPMI简介

1、什么是IPMI

    IPMI是智能型平台管理接口(Intelligent Platform Management Interface)的缩写,管理基于 Intel结构的企业系统中所使用的外围设备采用的一种工业标准。
    IPMI信息通过基板管理控制器BMC进行交流。BMC,是底板管理控制器 (Baseboard Management Controller)的缩写,BMC是以嵌入式Linux操作系统为平台,基于IPMI规范协议,实现对服务器的运行状态监控,以及远程控制管理等功能。
    管理员通过IPMI管理界面,能够轻易实现对服务器的管理和监控。
    通俗的说,IPMI就是一个管理服务器的接口。用户无论在开机还是关机的状态下,只要接通电源就可以实现对服务器的监控。通过IPMI接口,管理员可以实现对服务器的带内管理、带外管理、远程管理、统一管理。
    IPMI通过使用低级硬件智能管理,而不使用操作系统进行管理,具有两个主要优点: 首先,此配置允许进行带外服务器管理;其次,操作系统不必负担传输系统状态数据的任务。

2、IPMI主要功能


    1) 可以在服务接通电源(没有启动操作系统)的情况下,对它进行远程管理:开机、关机、重启。
    2) 控制台重定向。可以远程登陆控制台查看修改bios设置、设置系统启动引导方式、远程安装系统、登入系统等,效果相当于直接在服务器上连接一台显示器键盘鼠标执行操作。
    3) 故障日志记录和SNMP 警报发送,访问系统事件日志和传感器状况。

3、IPMI 工作原理
   IPMI的核心是BMC,即基板管理控制器,其并不依赖于服务器的处理器、BIOS或操作系统来工作,是一个单独运行的无代理管理子系统,只要有BMC与IPMI固件(运行在ROM里的只读程序)其便可开始工作,BMC通常是一个安装在服务器主板上的独立板卡。
    在工作时,所有的IPMI功能都是向BMC发送命令来完成的,命令使用IPMI规范中规定的指令,BMC接收并在系统事件日志中记录事件消息,维护描述系统中传感器情况的传感器数据记录。





4、ipmitool工具

  实现IPMI协议的工具有多个,以ipmitool工具为例。
  ipmitool 命令需要通过相应的interface来访问BMC,IPMItool命令包含的接口有open、lan、lanplus。

1)本地管理

    本地管理,Inband (In-Band),一般是由服务器内安装的操作系统实现,使用应用层工具ipmitool,发送指令通过OS内核提供的接口(如上图①)和bmc进行通信。流程为:服务器本地ipmitool软件-->服务器本地OS内核接口-->服务器硬件bmc

    在本地获取信息时候采用的是-I open,即为OpenIPMI接口,其中open是指的是OpenIPMI与 BMC通信。

    通过本地管理的方式控制IPMI时,有绝对的权限。不需要知道原始IPMI密码,就可以任意修改任何一个用户的密码。

2)远程管理

    远程管理,Outband (Out-of-Band),是由局域网内可联通IPMI地址的操作系统实现,网络(如上图②)以udp报文形式与远端服务器bmc进行通信。流程为:远程OS的ipmitool软件--->网卡(udp)--->服务器硬件bmc

    远程获取信息时候采用的是-Ilan/lanplus,Lan和lanplus都是通过Ethernet LAN网用IPV4的udp协议与BMC通信,UDP的数据段包含了IPMI request/resoponse消息,消息具有一个IPMI session 头和RMCP 头。

    其中lan/lanplus分别是v1.5/v2.0的标准。

    Lan:通过网络UDP,使用RMCP协议; 

    Lanplus:与Lan相同,但使用RMCP+协议,应用于IPMI v2.0版本。目前,多用lanplus。
        

5、Ironic中IPMITool的使用

    Ironic创建实例的生命周期中,是通过Lanplus的远程管理方式,对服务器进行控制。用到IPMITool的命令有:开关机、重启、获取电源状态;设置引导顺序、获取引导顺序。

    1)ironic驱动支持ipmitool

    首先,需要修改ironic支持的驱动,在配置文件/etc/ironic/ironic.conf的ennabled_drivers字段添加支持。如果没有配置,默认情况下,ironic使用的是pxe_ipmitool驱动。

    2)创建node时,指定驱动

    # ironic node-create -d pxe_ipmitool -i ipmi_address=<address> -i ipmi_username=<username> -i ipmi_password=<password>

    其中,-d指定使用的驱动, -i指定驱动的信息。一般需要driver_info需要指定如下信息:
    ipmi_address、ipmi_username、ipmi_password、ipmi_port (远程IPMI RMCP端口,默认使用623端口)

    若还有其它指定项,例如ironic适配Moonshot之类微服务器,还需要额外指定-B、-b、-T、-t,来指定单个IPMI地址下,多个微卡的偏移地址。

    3)ironic程序调用的ipmitool命令

    原始结构:(信息基本都是从driver_info中获取)

#ipmitool -I lanplus -H driver_info['address'] -L driver_info['priv_level'] -p driver_info['dest_port']
-U driver_info['username'] -R str(CONF.ipmi.retry_timeout // CONF.ipmi.min_command_interval) -N str(CONF.ipmi.min_command_interval) 

    以及可能添加的-B、-b、-T、-t参数。

    ipmitool -I lanplus -H 192.168.1.100 -U Administrator -P password -B 0 -T 0x9E -b 7 -t 0x72 chassis bootdev pxe

    新创建微服务器某个微卡为裸金属节点:

    POST:/v1/nodes

    body:

    {

            "name":"test_Moonshot_node",

            "driver":"agent_ipmitool",

            "driver_info":{

                       "ipmi_username":"ADMIN"

                        "ipmi_password":"password"

                        "transit_address":0x86

                        "transit_channel":0

                        "target_channel":7

                        "target_address":0x72

                        "ipmi_bridging":'dual'

            }

    }

    ironic用到的ipmitool命令:

#ipmitool -I lanplus -H 192.168.0.100 -U admin -P 123456 -R 5 -N 12 chassis raw  0x00 0x08 0x03 0x08 
ipmitool -I lanplus -H 192.168.0.100 -U admin -P 123456 -R 5 -N 12 chassis power on
ipmitool -I lanplus -H 192.168.0.100 -U admin -P 123456 -R 5 -N 12 chassis power off
ipmitool -I lanplus -H 192.168.0.100 -U admin -P 123456 -R 5 -N 12 chassis power status
ipmitool -I lanplus -H 192.168.0.100 -U admin -P 123456 -R 5 -N 12 chassis bootdev disk
ipmitool -I lanplus -H 192.168.0.100 -U admin -P 123456 -R 5 -N 12 chassis bootdev pxe

6,IPMI channel

 ipmitool -I open lan print 1  打印当前channel 1的信息,显示BMC通道的信息


1)一共有16个channel,如果不知道BMC使用的是哪个通道,需要首先找到所使用的channel:
# for i in `seq 1 16`; do ipmitool lan print $i 2>/dev/null | grep -q ^Set && echo Channel $i; done
Channel 1
然后,使用下面的命令确认:
ipmitool -I open channel info 1


执行命令ipmitool -I open lan print 1 ,可以查看当前BMC的详细信息,包括IP地址及类型、mac、掩码、网关等信息。之后可以使用相关命令进行修改。

ipmitool -I open lan set 1 ipsrc static                设置本地BMC地址为静态,才能设置IP
ipmitool -I open lan set 1 ipaddr 192.168.1.100        设置本地BMC的IP地址
ipmitool -I open lan set 1 netmask 255.255.255.0       子网掩码
ipmitool -I open lan set 1 defgw ipaddr 192.168.1.1    网关
ipmitool user list 1                                   查看BMC用户列表
ipmitool user set name 2 wyp                           对BMC的1号用户设置用户名wyp
ipmitool user set password 2 Passw0rd                  对BMC的1号用户设置密码Passw0rd

2)多数服务器的BMC可以设置两个IP,一个专用接口,一个共享接口。

例如浪潮服务器管理芯片BMC IP设置,IPMI主板集成管理芯片BMC IP 设置,开机按DEL键进入BIOS设置,选择"Server Mgmt"---"BMC Network Configuration"---"lan channel 1/2"---"static ip address"

lan channel 1:指的是复用管理网口,网卡1接口

lan channel 2:指的是IPMI管理专用接口,一般需要设置这个接口

3)ironic_python_agent中channel的使用

在OpenStack最新的P版ironic_python_agent组件hardware.py代码中,get_bmc_address()方法中遍历的channel是1-7,对于部分服务器如果channel为8,则会执行硬件自检错误,需要修改(1,8)为(1,16)

代码链接:

https://github.com/openstack/ironic-python-agent/blob/master/ironic_python_agent/hardware.py

7,IPMI使用问题

1)IPMI安全风险

    很多人希望使用IPMI做带外管理。如果直接使用是有问题的。

    在OS层面上,是可以随意修改IPMI的设置。也就是说,对于linux来说,有专门的驱动工具ipmitool,可以修改底层IPMI的设置,包括修改IPMI的用户名和密码。

    这样在多层级权限场景下就不适合直接做带外管理,只能做带外辅助工具,因为使用者可以随意修改管理员用于管理的账号密码。

2)引导顺序可能导致的问题

    bootdev方法设置的引导顺序,只作用一次。效果相当于进入BIOS后通过设置(例如F12)配置One-Time Boot.

    If you do have access to IPMI for the box, you may be able to force it to do a one-time boot into the BIOS setup.as follows:

ipmitool -I lanplus -H 192.168.0.100 -U admin -P 123456 -R 5 -N 12 chassis bootdev disk
ipmitool -I lanplus -H 192.168.0.100 -U admin -P 123456 -R 5 -N 12 chassis bootdev pxe

    由于引导顺序只作用一次,若部署的裸金属实例有二次重启操作,那么第二次重启的引导顺序不再受ipmitool设置的影响,而是由系统本身的BIOS引导顺序决定。

    如果通过ironic调用IPMItool工具,设置系统部署完后从disk引导,此时一次性配置完成并失效,系统从disk启动。但是如果之后系统再次重启后,引导顺序就由BIOS本身设置的引导顺序决定(可以自定义顺序),如果disk引导顺序排序在网络引导之后,则重启之后系统就会一直pxe引导,导致无法正常从磁盘引导进入系统。
规避方法:可以在BIOS设置里,把disk引导优先级高于网络引导优先级。


8,理解ipmi raw命令

raw :发送一个原始的 IPMI 请求,并且打印回复信息。
http://www.dell.com/downloads/global/power/ps4q07-20070387-Babu.pdf

To help maximize the available BMC capabilities, administrators can instead access hardware functions using raw commands。

Using IPMItool raw commands
The IPMI specification defines many more management capabilities than the IPMItool command-line options can provide.
Administrators can take advantage of these capabilities by framing raw command requests and sending them to BMCs.
IPMItool raw commands have the following format:
ipmitool –I interface options raw netfn cmd data
In this format, interface can be open, lan, or lanplus. If open is used, options is not included;
otherwise, options is -H ipaddress -U username -P password.
The netfn element is the network function,which identifies the functional message class and clusters IPMI commands
into different sets.
The cmd element represents a unique one-byte command value within a given network function. Finally, the data element
provides additional parameters for a request or response, if any.
    Three examples can help demonstrate using raw commands: changing the power cycle interval, creating custom LCD messages, and generating
platform event messages.

9,IPMI在OpenStack的应用
1),Overview
IPMI drivers使用 IPMI 2.0或1.5协议来管理节点。使用  IPMItool开源命令行CLI工具来管理支持IPMI的设备。

下面是使用 IPMItool 来执行电源和管理的hardware types和 classic drivers:
  • hardware types:
    • ipmi
  • classic drivers:
    • agent_ipmitool
    • pxe_ipmitool
    • agent_ipmitool_socat
    • pxe_ipmitool_socat
2),Glossary术语
  • IPMI - Intelligent Platform Management Interface.
  • IPMB - Intelligent Platform Management Bus/Bridge.
  • BMC - Baseboard Management Controller.
  • RMCP - Remote Management Control Protocol.
3),启用IPMItool driver(s)
(3.1),在 ironic.conf 配置文件中,明确的使能 ipmi hardware type
[DEFAULT]
enabled_hardware_types  =  ipmi
(3.2), pxe_ipmitool classic driver默认开启,如果要开启其他  IPMI classic drivers,则需要在 ironic.conf 配置文件中的 enabled_drivers 中配置,如下,同时开启 pxe_ipmitool and agent_ipmitool
[DEFAULT]
enabled_drivers  =  pxe_ipmitool,agent_ipmitool
(3.3),重启  Ironic conductor服务

4),使用IPMItool driver注册裸金属节点
使用ipmitool注册裸金属节点

使用 IPMItool drivers的节点需要在driver字段设置硬件类型为ipmi,或者classic drivers支持IPMItool

下面的配置项需要添加到裸金属节点的 driver_info字段中:
ipmi_address:BMC的IP地址或主机名
ipmi_username: 访问BMC的用户名,默认为 NULL用户
ipmi_password访问BMC的密码,默认为 NULL
ipmi_port:远程 IPMI RMCP端口, ipmitool 默认使用623

ironic node-create命令可以基于 IPMItool driver,注册一个裸金属节点,例如
ironic  node - create  - d  ipmi  - i  ipmi_address =< address > \
     - i  ipmi_username =< username >  - i  ipmi_password =< password >
5),高级配置

5.1)  Single/Double bridging functionality

注意:若要使用bridging功能,IPMItool版本需要大于等于1.8.12

基于 IPMItool的drivers支持两种不同的bridging功能: single bridge 和 dual bridge

以下配置需要添加到节点的 driver_info中,bridging才能被使用:

  • ipmi_bridging: bridging类型; 默认值为no; 可修改为single 支持single bridge ,或修改为 dual 支持double bridge.
  • ipmi_local_address: 本地 IPMB地址,用于bridged请求.
    只有当 ipmi_bridging 设置为single或 dual才需要, 此配置可选配,如果没有配置则会被IPMItool自动发现.
  • ipmi_target_address: bridge请求的目标地址. 只有当 ipmi_bridging 设置为single或dual.时才需要配置。
  • ipmi_target_channelbridge请求的目标通道channel. 只有当 ipmi_bridging 设置为single或dual.时才需要配置。
Double bridge指定选项:
  • ipmi_transit_addressbridge请求的发送地址. 只有当 ipmi_bridging 设置为single或dual.时才需要配置。
  • ipmi_transit_channelbridge请求的发送通道channel. 只有当 ipmi_bridging 设置为single或dual.时才需要配置。

 ironic node-update命令可以用于已经使用 IPMItool  driver注册成功的裸金属节点 bridging 信息的设置,例如:
  • Single Bridging:

    ironic node-update add <UUID or name> driver_info/ipmi_local_address=<address> \
        driver_info/ipmi_bridging=single driver_info/ipmi_target_channel=<channel> \
        driver_info/ipmi_target_address=<target address>
  • Double Bridging:

    ironic  node - update  add  < UUID  or  name >  driver_info / ipmi_local_address =< address > \
         driver_info / ipmi_bridging = dual  driver_info / ipmi_transit_channel =< transit  channel > \
         driver_info / ipmi_transit_address =< transit  address >  driver_info / ipmi_target_channel =< target  channel > \
         driver_info / ipmi_target_address =< target  address >
5.2) 更改IPMI协议版本

基于 IPMItool的drivers使用IPMI 协议1.5或2.0版本。默认是2.0版本。
如果要修改裸金属节点的IPMI协议版本,可以配置以下选项,设置节点的 driver_info 字段。
ipmi_protocol_version:指定IPMI协议版本
ironic  node - update  add  < UUID  or  name >  driver_info / ipmi_protocol_version =< version >
1.5版本不支持加密。


参考:

https://docs.openstack.org/ironic/pike/admin/drivers/ipmitool.html

http://www.taodocs.com/p-78411748.html

猜你喜欢

转载自blog.csdn.net/wuyongpeng0912/article/details/79056251
key