运维利器——ipmitool
- ipmitool 简介
- 基于 CentOS 安装、使用 ipmitool
- ipmitool lan(网络管理)
- ipmitool user(用户管理)
- 附:ansible 批量配置带外管理
ipmitool 简介
ipmitool —— 是在 Linux 命令行模式下,实现 ipmi 远程管理的一个工具。
适用情况:
- 无法重启服务器情况下,忘记 IPMI 登录信息;
- 针对 IPMI 进行批量管理,如批量添加 monitor 账号;
- 在业务后期需批量配置、修改 IPMI 信息
基于 CentOS 安装、使用 ipmitool
安装 ipmitool
yum -y install ipmitool
加载模块
modprobe ipmi_watchdog
modprobe ipmi_poweroff
modprobe ipmi_devintf
modprobe ipmi_si
modprobe ipmi_msghandler
查看相关模块是否加载
lsmod | grep ^ipmi
查看 ipmitool 版本
ipmitool -V
ipmitool lan(网络管理)
1)为通道配置静态类型
格式: ipmitool lan set 通道ID ipsrc ip获取类型root@master:~# ipmitool lan set 1 ipsrc static
lan set <channel> ipsrc <source>none = unspecifiedstatic = static address (manually configured)dhcp = address obtained by BMC running DHCPbios = address loaded by BIOS or system software
2)配置 IP
格式: ipmitool lan set 通道ID ipaddr IP地址root@master:~# ipmitool lan set 1 ipaddr 192.168.10.10
Setting LAN IP Address to 192.168.10.10
3)配置掩码
格式: ipmitool lan set 通道ID netmask 掩码地址root@master:~# ipmitool lan set 1 netmask 255.255.255.0
Setting LAN Subnet Mask to 255.255.255.0
4)配置默认网关
格式: ipmitool lan set 通道ID defgw ipaddr 网关地址root@master:~# ipmitool lan set 1 defgw ipaddr 192.168.10.11
Setting LAN Default Gateway IP to 192.168.10.11
5)查看网络配置
格式: ipmitool lan print 通道IDroot@master:~# ipmitool lan print 1
6)Other
# 恢复默认值,适用于浪潮服务器BMC
ipmitool raw 0x32 0x66# BMC执行热(冷)复位,在一些服务器(如HPE)配置完IP后需重启BMC生效
ipmitool -I open mc reset <warm|cold>
ipmitool user(用户管理)
(1)查看用户清单
root@master:~# ipmitool user list 1
ID Name Callin Link Auth IPMI Msg Channel Priv Limit
1 ADMIN false false true ADMINISTRATOR
(2)创建用户:
格式: ipmitool user set name 用户ID 用户名
root@master:~# ipmitool user set name 3 aaa
root@master:~# ipmitool user list 1
ID Name Callin Link Auth IPMI Msg Channel Priv Limit
3 aaa true false false Unknown (0x00)
(3)设置密码:
格式: ipmitool user set password 用户ID号 密码
root@master:~# ipmitool user set password 3 123.com
Set User Password command successful (user 3)
(4)给用户权限
格式:ipmitool channel setaccess 1 用户ID callin=on ipmi=on link=on privilege=值【on为开启、off为关闭,是该用户对于通道的权限】privilege的值:
1 callback
2 user
3 operator
4 administrator
5 OEMeg:
root@master:~# ipmitool channel setaccess 1 3 callin=on ipmi=on link=on privilege=4
Set User Access (channel 1 id 3) successful.
查看 用户id 为3的用户的情况:
root@master:~# ipmitool user list 1
ID Name Callin Link Auth IPMI Msg Channel Priv Limit
1 true false false Unknown (0x00)
2 ADMIN false false true ADMINISTRATOR
3 aaa true true true ADMINISTRATOR
(5)查看授权:
格式:ipmitool channel getaccess 1 用户ID
root@master:~# ipmitool channel getaccess 1 3
Maximum User IDs : 10
Enabled User IDs : 2User ID : 3
User Name : aaa
Fixed Name : No
Access Available : callback
Link Authentication : disabled
IPMI Messaging : disabled
Privilege Level : ADMINISTRATOR
附:ansible 批量配置带外管理
主机清单
cat hosts[client]
10.132.6.22 ipmiaddr='10.4.7.22' // ipmiaddr为主机带外管理地址
10.132.6.23 ipmiaddr='10.4.7.23'
10.132.6.24 ipmiaddr='10.4.7.24'
playbook
cat ipmi.yml---
- hosts: clientgather_facts: false // 跳过主机信息收集become: yes // 以 root 身份 sudo 执行命令become_user: root become_method: sudotasks:- name: install ipmitool // 安装 ipmitoolyum:name: ipmitoolstate: installed- name: loading module // 加载模块shell:cmd: "{
{ item.cmd }}"with_items:- {
cmd: modprobe ipmi_watchdog}- {
cmd: modprobe ipmi_poweroff}- {
cmd: modprobe ipmi_devintf}- {
cmd: modprobe ipmi_si}- {
cmd: modprobe ipmi_msghandler}- name: configure ipmi address static // 设置IP类型为静态地址shell:cmd: ipmitool lan set 1 ipsrc static- name: configure ipmi address // 配置IP地址,"{
{ ipmiaddr }}"为主机清单中变量shell:cmd: ipmitool lan set 1 ipaddr "{
{ ipmiaddr }}"- name: configure ipmi netmask and gateway // 配置子网掩码及默认网关shell:cmd: "{
{ item.cmd }}"with_items:- {
cmd: ipmitool lan set 1 netmask 255.255.255.0}- {
cmd: ipmitool lan set 1 defgw ipaddr 10.4.7.1}- name: reset BMC // 重启BMCshell:cmd: ipmitool -I open mc reset warm- name: new administrator user // 添加并授权用户shell:cmd: "{
{ item.cmd }}" with_items:- {
cmd: ipmitool user set name 3 admin}- {
cmd: ipmitool user set password 3 1234.com}- {
cmd: ipmitool channel setaccess 1 3 callin=on ipmi=on link=on privilege=4}
执行命令
ansible-playbook ipmi.yml
引用
IPMI 介绍 及 基于 Ubuntu16.04安装、使用 ipmitool、BMC
FusionServer Tools 2.0 Toolkit 用户指南 34