运维利器——ipmitool

ipmitool 简介

ipmitool —— 是在 Linux 命令行模式下,实现 ipmi 远程管理的一个工具。

适用情况:

  1. 无法重启服务器情况下,忘记 IPMI 登录信息;
  2. 针对 IPMI 进行批量管理,如批量添加 monitor 账号;
  3. 在业务后期需批量配置、修改 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   = unspecified
  static = static address (manually configured)
  dhcp   = address obtained by BMC running DHCP
  bios   = 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 通道ID

root@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 OEM

eg:
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     : 2

User 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: client
  gather_facts: false		// 跳过主机信息收集
  become: yes 			// 以 root 身份 sudo 执行命令
  become_user: root 
  become_method: sudo
  tasks:
  - name: install ipmitool		// 安装 ipmitool
    yum:
        name: ipmitool
        state: 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		// 重启BMC
    shell:
        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

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值