使用ipmitool对服务器进行远程管理详细命令
IPMI工作原理:
IPMI的核心是一个专用芯片/控制器(叫做服务器处理器或基板管理控制器(BMC)),其并不依赖于服务器的处理器、BIOS或操作系统来工作,可谓非常地独立,是一个单独在系统内运行的无代理管理子系统,只要有BMC与IPMI固件其便可开始工作,而BMC通常是一个安装在服务器主板上的独立的板卡,现在也有服务器主板提供对IPMI支持的。IPMI良好的自治特性便克服了以往基于操作系统的管理方式所受的限制,例如操作系统不响应或未加载的情况下其仍然可以进行开关机、信息提取等操作。
在工作时,所有的IPMI功能都是向BMC发送命令来完成的,命令使用IPMI规范中规定的指令,BMC接收并在系统事件日志中记录事件消息,维护描述系统中传感器情况的传感器数据记录。在需要远程访问系统时,IPMI新的LAN上串行(SOL)特性很有用。SOL改变IPMI会话过程中本地串口传送方向,从而提供对紧急管理服务、Windows专用管理控制台或Linux串行控制台的远程访问。BMC通过在LAN上改变传送给 串行端口的信息的方向来做到这点,提供了一种与厂商无关的 远程查询启动、操作系统加载器或紧急管理控制台来诊断和维修故障的标准方式。
当需要对系统 文本控制台进行远程访问时,Serial Over LAN (SOL) 功能将非常有用。SOL 通过 IPMI 会话重定向本地串行接口,允许远程访问 Windows 的紧急事件管理控制台 (EMS) 特殊管理控制台 (SAC),或访问 LINUX 串行控制台。这个过程的步骤是 IPMI 固件截取数据,然后通过局域网重新发送定向到串行端口的信息。 这就提供了远程查看 BOOT、OS 加载器或紧急事件管理控制台以诊断并修复服务器相关问题的标准方法,而无需考虑供应商。它允许在引导阶段配置各种组件。
SOL with ipmitool
SOL via ipmitool on 1950 is definitely possible, as we have it working on a 1950 and a pile of fairly similar SGI xe210's (Intel 5000P chipset) here.
I only have access/experience with the SGI's though - let me know if the below doesn't help and I'll try to find out more about the 1950's setup.
a (not yet fully debugged) ipmi setup from scratch on the SGI looks something like:
load up the IPMI 'open' kernel modules
/etc/init.d/ipmi start
setup IP and access:
ipmitool channel info 1
ipmitool lan set 1 ipaddr <someIP>
ipmitool lan set 1 netmask 255.255.0.0
ipmitool lan set 1 auth ADMIN MD5,PASSWORD
ipmitool lan set 1 ipsrc static
ipmitool lan set 1 arp respond on
ipmitool lan set 1 arp generate on
ipmitool lan set 1 arp interval 5
ipmitool lan print 1
ipmitool lan set 1 access on
and then setup a user called 'admin'
ipmitool user set name 2 admin
ipmitool user set password 2 <some passwd>
#ipmitool user priv 2 4 1
ipmitool channel setaccess 1 2 callin=on ipmi=on link=on privilege=4
ipmitool user list 1
ipmitool user enable 2
and the sol setup continues over the lanplus interface:
ipmitool -I lanplus -H <someIP> -U admin -P <some passwd> -v -o intelplus sol info
ipmitool -I lanplus -H <someIP> -U admin -P <some passwd> -v -o intelplus sol set privilege-level admin
ipmitool -I lanplus -H <someIP> -U admin -P <some passwd> -v -o intelplus sol set non-volatile-bit-rate 115.2
ipmitool -I lanplus -H <someIP> -U admin -P <some passwd> -v -o intelplus sol set volatile-bit-rate serial
ipmitool -I lanplus -H <someIP> -U admin -P <some passwd> -v -o intelplus sol set force-encryption true
ipmitool -I lanplus -H <someIP> -U admin -P <some passwd> -v -o intelplus sol set enabled true
ipmitool -I lanplus -H <someIP> -U admin -P <some passwd> -v -o intelplus sol set retry-interval 2
ipmitool -I lanplus -H <someIP> -U admin -P <some passwd> -v -o intelplus sol payload enable 1 2
For the Dell you'd drop the '-o intelplus' but the rest should still apply. channel numbers might vary (the above is 1), and the SGI BIOS talks to ttyS1 instead of ttyS0.
BMC具有以下功能:
1.通过系统的串行端口进行访问
2. 故障日志记录和 SNMP 警报发送
3.访问系统事件日志 (System Event Log ,SEL) 和传感器状况
4.控制包括开机和关机
5.独立于系统电源或工作状态的支持
6.用于系统设置、基于文本公用程序和操作系统控制台的文本控制台重定向
使用 ipmi 的必要条件——必须在硬件、OS、管理工具等几个方面都满足:
1.服务器硬件本身提供对 ipmi 的支持 (硬件)
目前惠普、戴尔和 NEC 等大多数厂商的服务器都支持 IPMI 2.0,但并不是所有服务器都支持,所以应该先通过产品手册或在 BIOS 中确定服务器是否支持 ipmi,也就是说服务器在主板上要具有 BMC 等嵌入式的管理微控制器。
以DELL R710为例:
1) 启动服务器 使用ctrl+e 进去ipmi server mangement configuration
2)设置IPMI Over LAN 为On
3)进入IPMI Parameters 设置服务器ip/子网掩码 (也可以进去系统通过Ipmitool管理软件设置)
4)进入LAN User Confuguration 设置用户名 密码 (同样也可以进去系统通过Ipmitool管理软件设置)
2.操作系统提供相应的 ipmi 驱动 (OS)
通过操作系统监控服务器自身的 ipmi 信息时需要系统内核提供相应的支持,linux 系统通过内核对 OpenIPMI(ipmi 驱动)的支持来提供对 ipmi 的系统接口。在使用驱动之前,请先启动该驱动:service ipmi start
或者启动模块:ipmi_msghandler、ipmi_devintf、ipmi_si、ipmi_poweroff、ipmi_watchdog
3.ipmi 管理工具 (管理工具)
Linux 下的命令行方式的 ipmi 平台管理工具 ipmitool。ipmitool 命令需要通过相应的interface来访问BMC,在本地获取信息时候采用的是-I open,即为OpenIPMI接口,IPMItool命令包含的接口有open、lan、lanplus。其中open是指的是OpenIPMI与 BMC通信,Lan是通过Ethernet LAN网用IPV4的udp协议与BMC通信。UDP的数据段包含了IPMI request/resoponse消息,消息具有一个IPMI session 头和RMCP 头。
IPMI使用Remote Management Control Protocol (RMCP) 版本1支持操作系统关闭(pre-OS和OS-absent),RMCP把把数据发送到UDP的623端口。象lan接口一样,lanplus同样使用 Ethernet LAN 的UDP协议与BMC通信,但是lanplus使用RMCP+协议(在IPMIV20中描述)来同新,RMCP+允许使用改经的认证方式和数据完整性检查。Open端口用于本地监控系统使用的;Lan/lanplus通过网络进行远程监控。
利用ipmitool实现对Linux服务器的ipmi管理有2种方式:
1)通过OS监控本地服务,实现对本地服务器的管理。
架构:应用软件ipmitool <----------->OS提供支持ipmi系统接口<------------>硬件主板上有bmc芯片
通过ipmitool命令获取获取传感器中的各种监测值和该值的监测阈值,包括(CPU温度,电压,风扇转速,电源调制模块温度,电源电压等信息)
ipmitool本地监控使用命令:ipmitool -I open command,其中-I open表示使用OpenIPMI接口,command有以下项:
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信道。
# ipmitool -I open sensor list
2)通过网络监控远程服务器。
被监控服务器需要硬件和操作系统接口驱动的支持,可以无需安装应用软件。监控客户端需要应用软件如ipmitool工具,可以无需硬件和操作系统接口驱动的支持。
ipmi的远程监控是通过向与BMC相连的网络接口发送udp数据包实现的,udp数据包的定位是通过把ip地址写BMC芯片来实现,而这需要本地的Ipmi系统接口来完成连接。Ipmitool可以通过LAN远程监控系统,同时BMC中保存有一序列用户名和密码,通过LAN进行远端访问需要用户名和密码。
被监控服务器使用ipmitool更改ip,查看ip
# ipmitool lan set 1 ipaddr 172.16.6.2
监控客户端Ipmi ip地址也必须和被监控服务端在同一网段,可以手动加一个ip(确保能互通),能够Ping通被监控服务器地址 则可以远程管理该主机。
# ipmitool -I lanplus -H 172.16.6.2 -U root -P password sol activate
以下是ipmitool在生产环境下常用命令:
查看ipmi信息 #ipmitool mc info
人员 #ipmitool user list 1
查看绑定IP #ipmitool lan print 1
更改IP #ipmitool lan set 1 ipaddr x.x.x.x
更改密码 #ipmitool user list 1
#ipmitool user set password 2 "passme"
ipmitool的SQL远程控制服务器 #ipmitool -I lanplus -H x.x.x.x -U root -P password sol (de)activate
强制重启(关闭或开启)被监控服务器 #ipmitool -I lanplus -H x.x.x.x -U root -P password chassis power reset (off on)
列出日志 ipmitool sel list
快捷键 shift + ~ +. 是退出ipmi
可以通过加'shell'参数,就像登录到远程服务器(ssh)那样操作bmc。
通过IPMITOOL添加远程管理账户
ipmitool user set name 6 admin; //在ID6添加admin账户
ipmitool user set password 6 password; //设置ID6的密码为password
ipmitool user priv 6 4 1;//赋予管理员权限 6指ID号 4指管理员权限 1指频道号
ipmitool sol payload enable 1 6;//允许payload
ipmitool user enable 6;//激活ID6的账户
ipmitool user list 1 //列出用户
DELL服务器开启IPMI
相关参考文档:
使用 ipmitool 实现 Linux 系统下对服务器的 ipmi 管理(对IPMI有详细解读)
http://www.ibm.com/developerworks/cn/linux/l-ipmi/index.html
IPMItool manpage
http://ipmitool.sourceforge.net/manpage.html
一、DELL服务器开启IPMI:
(支持DELL型号:PE1850 ,PE2850 ,PE1950,PE2950,R410,R510,R710)
1.配置系统启用IPMI,启动服务器,在启动过程中,看提示,按Ctrl+E 进入进入远程访问公用程序
2.设置IPMI Over LAN为On,意思为启用通过LAN方式的IPMI,默认为Off。
二、通过web访问DRAC 开启IPMI:
(支持此方式的DELL服务器型号:PE1950,PE2950 ,R410, R510,R710)
远程访问--配置---网络---IPMI LAN 设置----启用 LAN 上的 IPMI
注:如果未开启IPMI,远程访问时报错提示:
Error: Unable to establish LAN session
三、设置iDRAC网络参数(也可以web方式配置网络设置参数):
DRAC5
选择LAN Parameters,配置iDRAC网卡参数, NIC Selection ,设置网卡共享模式,默认为“Dedicated” (专用).
iDRAC6
选择LAN Parameters, 可以配置iDRAC网络参数与NIC Selection, 默认为“Dedicated” (专用).
注:LAN 共享依赖于“NIC Selection”(NIC 选择)配置选项。可用选项有“Shared”(共享)和“Failover”(故障转移),如果存在 Remote Access Controller (RAC) 卡,则还有一个选项“Dedicated” (专用)。
显示配置选项。
* “Shared”(共享)
选择此选项与主机操作系统共享网络接口。 当主机操作系统配置为 NIC 组时,远程访问设备网络接口具有全部功能。远程访问设备通过 NIC 1 和 NIC 2 接收数据,不过只通过 NIC 1 发送数据。
如果 NIC 1 失败,远程访问设备将不可访问。
注:NIC 2 在 PowerEdge 1900 系统上不可用。
* “Failover”(故障转移)
选择此选项与主机操作系统共享网络接口。 当主机操作系统配置为 NIC 组时,远程访问设备网络接口具有全部功能。
远程访问设备通过 NIC 1 和 NIC 2 接收数据,不过只通过 NIC 1 发送数据。 如果 NIC 1 失败,远程访问设备会故障转移到 NIC 2 来进行所有数据发送。远程访问设备会接着使用 NIC 2 进行数据发送。 如果 NIC 2 失败,远程访问设备会故障转移回 NIC 1 来进行所有数据发送。
注: 此选项不能在 PowerEdge 1900 系统上选择。
* “Dedicated”(专用)
选择此选项让远程访问设备利用 Remote Access Controller (RAC) 上的专用网络接口。此接口不与主机操作系统共享并且会将系统管理通信路由到单独的物理网络,从而能够与应用程序通信分开。
四、IPMItool软件:
1.DELL官方 提供win版本的 ipmish 工具,请见附件word 文档里有此程序工具。 此工具只能支持部分常用命令,全命令行的操作的话需要购买我们的软件服务。
2.Linux 版本 (功能比较强大)
从http://sourceforge.net/projects/ipmitool/files/下载最新稳定版本,然后编译安装。
五、Linux版本 IPMItool工具使用(测试版本ipmitool version 1.8.9):
1.常用命令
电源管理:
# ipmitool -H drac ip -U root -P 密码 power off (硬关机,直接切断电源)
# ipmitool -H drac ip -U root -P 密码 power soft (软关机,即如同轻按一下开机扭)
# ipmitool -H drac ip -U root -P 密码 power on (硬开机)
# ipmitool -H drac ip -U root -P 密码 power reset (硬重启)
# ipmitool -H drac ip -U root -P 密码 power status (获取当前电源状态)
查看IPMI接口网络配置
# ipmitool -H ip -U root -P xxxx lan print 1 (1为网络(lan)信道(channel) ,默认是1, 运行命令时可以省略不输入。)
查看DRAC用户列表
#ipmitool -H ip -U root -P xxxx user list
修改root用户的密码
#ipmitool -H ip -U root -P xxxx user set password 2(user id,这里root的uid是2) <password>
打印传感器数据(设备温度、电压、风扇转速==):
#ipmitool -H ip -U root -P xxxx sdr
打印传感器详细数据:
#ipmitool -H ip -U root -P xxxx sensor
获取机箱周围温度信息:
#ipmitool -I lan -H ip -U root -P xxxx sensor get "Ambient Temp"
获取机箱具体温度
# ipmitool -I lan -U root -P xxxx -H ip sensor get "Ambient Temp"| /bin/grep -i "Sensor Reading"|/bin/cut -c 26-28
上次系统重启原因(测试中显示System restart cause: chassis power control command)
#ipmitool -H ip -U root -P xxxx chassis restart_cause
2.设置 串行链接IPMIv2.0 Serial-over-LAN 配置:
# ipmitool -I lanplus -U root -P xxxx -H ip sol
SOL Commands: info [<channel number>]
set <parameter> <value> [channel]
payload <enable|disable|status> [channel] [userid]
activate [<usesolkeepalive|nokeepalive>]
deactivate
looptest [<loop times>] [<loop interval(in ms)>]
参考例子:
ipmitool -I lanplus -H < IP> -U root -P <some passwd> sol info
ipmitool -I lanplus -H < IP> -U root -P <some passwd> sol set privilege-level admin
ipmitool -I lanplus -H < IP> -U root -P <some passwd> sol set non-volatile-bit-rate 115.2
ipmitool -I lanplus -H < IP> -U root -P <some passwd> sol set volatile-bit-rate serial
ipmitool -I lanplus -H < IP> -U root -P <some passwd> sol set force-encryption true
ipmitool -I lanplus -H < IP> -U root -P <some passwd> sol set enabled true
ipmitool -I lanplus -H < IP> -U root -P <some passwd> sol set retry-interval 2
ipmitool -I lanplus -H < IP> -U root -P <some passwd> sol payload enable 1 2
3.设置启动设备:
#ipmitool -H ip -U root -P xxxx chassis bootdev <device>
bootdev <device> [clear-cmos=yes|no]
bootdev <device> [options=help,...]
none : Do not change boot device order
pxe : Force PXE boot
disk : Force boot from default Hard-drive
safe : Force boot from default Hard-drive, request Safe Mode
diag : Force boot from Diagnostic Partition
cdrom : Force boot from CD/DVD
bios : Force boot into BIOS Setup
floppy: Force boot from Floppy/primary removable media
4.常用网络配置命(在操作系统本地命令方式,远程需要命令“ipmitool”后添加“-H ip -U root -P xxxx ”即可)
setup IP and access:
ipmitool channel info 1 打印现channel 1的信息
ipmitool lan set 1 ipaddr <IP>
ipmitool lan set 1 netmask 255.255.0.0
ipmitool lan set 1 auth ADMIN MD5,PASSWORD
ipmitool lan set 1 ipsrc static
ipmitool lan set 1 arp respond on
ipmitool lan set 1 arp generate on
ipmitool lan set 1 arp interval 5
ipmitool lan print 1
ipmitool lan set 1 access on 设置channel 1允许访问
5.设置用户参数:
ipmitool user set name 2 admin
ipmitool user set password 2 <some passwd> 修改密码
#ipmitool user priv 2 4 1 设置权限,语法: priv <user id> <privilege level> [<channel number>]
ipmitool user list 1 通道1用户列表 语法: list [<channel number>]
ipmitool user enable 2 启用uid 2的用户
六、利用ipmitool配置远程终端重定向
参考资料:http://docs.linuxtone.org/dell/ipmitool.pdf
七、IPMItool电源管理和引导设备命令测试(针对和讯现在使用的DELL机型):
1.支持电源命令电源管理的DELL机型如下:
PE1950
RAC 信息: DRAC 5,硬件版本:A00,固件版本 1.32 (07.12.22)
BMC 信息: IPMI 版本 2.0 , 固件版本 1.77
PE2950
RAC 信息: DRAC 5 ,硬件版本 A00, 固件版本 1.0 (06.05.12)
BMC 信息 IPMI 版本 2.0 , 固件版本 1.27
R410
iDRAC 信息:iDRAC6 硬件版本 0.01 固件版本 1.30 (Build 24)
IPMI 版本 2.0
R710
iDRAC 信息名称 :iDRAC6
固件版本1.20.01 硬件版本0.01 ,IPMI 版本 2.0
R510
名称 iDRAC6, 硬件版本 0.01,固件版本 1.27.10 ,IPMI 版本 2.0
2.设置PXE启动测试(因测试机有限,仅测试R710,此型号相关版本信息如上):
先检查电源状态:
#ipmitool -H <IP> -U root -P <password> power status
如果返回状态为“Power is off"
需要输入命令开启设备:
# ipmitool -H <IP> -U root -P <password> power on
然后再检查电源状态,确认为”Power is on”再运行下面的命令:
设置从pxe启动:
#ipmitool -H <IP> -U root -P <password> chassis bootdev pxe
然后重启服务器:
#pmitool -H <IP> -U root -P <password> power reset
设备启动后,就可以从pxe启动引导。
注:即便bios启动顺序未选择pxe启动(当然必须要开启相关网卡的pxe功能),此命令一样可以让设备从pxe启动。此pxe引导功能仅生效一次,设备再重启就按默认启动顺序启动。其他服务器型号待有测试机再补充。
暂无测试信息的机型:
R200
DRAC 4 信息 固件版本 1.75 (Build 06.03), 硬件版本A00,BMC 版本 1.83
XX00 系列以及6650系列服务器暂无测试信息
PE2650 DRAC III 暂无测试信息
PE1850 DRAC 4
PE2850 DRAC 4
发表评论