banner
云野阁

云野阁

闲云野鹤,八方逍遥

Linux实现模拟IPMI

环境准备:#

(1)使用脚本安装 docker、docker-compose

bash <(curl -sSL https://linuxmirrors.cn/docker.sh)

(2)配置镜像加速

vi /etc/docker/daemon.json

{
  "data-root": "/data/dockerData",
  "registry-mirrors": ["https://registry.cn-hangzhou.aliyuncs.com",
    "https://huecker.io",
    "https://docker.rainbond.cc",
    "https://dockerhub.timeweb.cloud",
    "https://dockerhub.icu",
    "https://docker.registry.cyou",
    "https://docker-cf.registry.cyou",
    "https://dockercf.jsdelivr.fyi",
    "https://docker.jsdelivr.fyi",
    "https://dockertest.jsdelivr.fyi",
    "https://mirror.aliyuncs.com",
    "https://dockerproxy.com",
    "https://mirror.baidubce.com",
    "https://docker.m.daocloud.io",
    "https://docker.nju.edu.cn",
    "https://docker.mirrors.sjtug.sjtu.edu.cn",
    "https://docker.mirrors.ustc.edu.cn",
    "https://mirror.iscas.ac.cn",
    "https://docker.rainbond.cc",
    "https://docker.kubesre.xyz"],
    "log-driver":"json-file",
    "log-opts":{"max-size" :"50m","max-file":"3"}
}

(3)启动 docker 服务

systemctl start docker
systemctl enable docker
systemctl status docker

部署 IPMI Simulator 容器#

(1)在 IPMI Simulator 官方仓库中下载源码包

(2)下载完成并解压后,修改 Dockerfile 文件

FROM alpine
LABEL maintainer="[email protected]"

RUN apk --update --no-cache add openipmi-lanserv

# Create the directories that will be used to persist state information
# for the IPMI simulator instance.
RUN mkdir -p /tmp/chassis

COPY . /tmp/ipmisim

# 新加部分
RUN chmod +x /tmp/ipmisim/bin/chassis_control.sh
# 新加部分
EXPOSE 623

EXPOSE 623/udp

CMD ["ipmi_sim", "-n", "-c", "/tmp/ipmisim/lan.conf", "-f", "/tmp/ipmisim/sim.emu"]

(3)生成镜像文件,运行容器

docker build -f Dockerfile -t vaporio/ipmi-simulator .
docker run -d --name ipmi-simulator --restart always -p 623:623/udp -p 623:623/tcp vaporio/ipmi-simulator

(4) 配置防火墙策略

firewall-cmd --add-port=623/tcp --permanent
firewall-cmd --add-port=623/udp --permanent
sudo firewall-cmd --reload
sudo firewall-cmd --list-all

(5)在主机上查看模拟 IPMI 的底盘和电源状态

 ipmitool -I lan -H 主机ip -p 623 -U ADMIN -P ADMIN chassis status

System Power : on
Power Overload : false
Power Interlock : inactive
Main Power Fault : false
Power Control Fault : false
Power Restore Policy : always-off
Last Power Event :
Chassis Intrusion : inactive
Front-Panel Lockout : inactive
Drive Fault : false
Cooling/Fan Fault : false

扩展命令:

IPMI 设备的电源状态

#打开
ipmitool -I lan -H 主机ip -p 623 -U ADMIN -P ADMIN chassis power on
#关闭
ipmitool -I lan -H 主机ip -p 623 -U ADMIN -P ADMIN chassis power off
#重启
ipmitool -I lan -H 主机ip -p 623 -U ADMIN -P ADMIN chassis power reset
#标识机箱(使指示灯闪烁)
ipmitool -I lan -H 主机ip -p 623 -U ADMIN -P ADMIN chassis identify 5

读取系统状态

#显示系统传感器
ipmitool -I lan -H 主机ip -p 623 -U ADMIN -P ADMIN sensor list
#显示系统现有可替代器件列表
ipmitool -I lan -H 主机ip -p 623 -U ADMIN -P ADMIN fru list
#显示系统SDR Repository设备列表
ipmitool -I lan -H 主机ip -p 623 -U ADMIN -P ADMIN sdr list
#显示系统平台事件过滤的列表
ipmitool -I lan -H 主机ip -p 623 -U ADMIN -P ADMIN pef filter list
#显示系统平台策略列表
ipmitool -I lan -H 主机ip -p 623 -U ADMIN -P ADMIN pef policy list

系统日志

#显示所有系统事件日志
ipmitool -I lan -H 主机ip -p 623 -U ADMIN -P ADMIN sel elist
#显示当前BMC的时间
ipmitool -I lan -H 主机ip -p 623 -U ADMIN -P ADMIN sel time get
#修改当前BMC的时间
ipmitool -I lan -H 主机ip -p 623 -U ADMIN -P ADMIN sel time set "09/25/2024 18:29:20"


系统相关

#查看BMC信息
ipmitool -I lan -H 主机ip -p 623 -U ADMIN -P ADMIN bmc info
#BMC冷启动
ipmitool -I lan -H 主机ip -p 623 -U ADMIN -P ADMIN bmc reset cold
#BMC启动
ipmitool -I lan -H 主机ip -p 623 -U ADMIN -P ADMIN bmc reset warm
#显示系统默认通道
ipmitool -I lan -H 主机ip -p 623 -U ADMIN -P ADMIN channel info
#显示所有用户
ipmitool -I lan -H 主机ip -p 623 -U ADMIN -P ADMIN user list
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.