一、IB网卡驱动安装步骤
1、打开驱动下载页面,选择对应操作系统和版本,cpu架构,下载iso、tar包或者源码包都可以。
下载地址:https://network.nvidia.com/products/infiniband-drivers/linux/mlnx_ofed/
(1) 管理员权限账户登入系统,将OFED 驱动包复制到系统下;
(2) 解压OFED 驱动包:tar -zxvf file.tgz
;
(注:常见压缩包的解压命令
tar -xvf file.tar
tar -zxvf file.tar.gz
tar -jxvf file.bz2
unrar e file.rar
unzip file.zip)
(3) 进入解压后目录,执行chmod -R 777 *
赋予文件可执行权限;
(4) 执行./mlnxofedinstall --without-fw-update --force
进行驱动安装更新;驱动安装时可能会有下图所示提示:
这可能是由于系统内核版本升级导致,请增加--add-kernel-support
参数,使驱动程序基于当前内核版本编译安装。
(5) 安装过程中,安装程序会自动检查当前操作系统环境所需工具是否齐备。如检查到缺失的软件包,将在会命令行提示,请按照提示操作。
(6) 驱动更新完成后重启系统,执行ethtool -i ethx
命令再次查看网卡驱动版本,确保系统重启后新驱动依然生效。
2、查看已安装的驱动版本、网卡状态
root@westhpc:~# ofed_info -s
MLNX_OFED_LINUX-24.01-0.3.3.1:
更改网卡IB模式为以太模式
当我们想要配置Mellanox网卡时,如果出现了下面情况:
$ sudo mst start
mst: command not found
这说明我们的系统中缺少MFT。
MFT是一套管理Mellanox网卡的工具,也是MLEX_OFED中的一部分。如果你不小心搞丢了MFT,可以用下面的方法安装:
- 去官网下载MFT
https://network.nvidia.com/products/adapter-software/firmware-tools/
我下载的版本是mft-4.25.0-62-x86_64-deb.tgz
wget https://www.mellanox.com/downloads/MFT/mft-4.25.0-62-x86_64-deb.tgz
tar xvf mft-4.25.0-62-x86_64-deb.tgz
cd mft-4.25.0-62-x86_64-deb
sudo bash install.sh
sudo mst start
如果安装中出现报错,请update升级并安装所需要的软件包。
如果不报错就说明MFT装好了。
默认地,你的网卡应该是IB模式,如果你的网络是以太网的话,你就需要将网卡转换为以太网模式:
- 查看你的设备名称
$ ls /dev/mst
mt4119_pciconf0 mt4119_pciconf0.1
- 查看设备的状态
$ sudo mlxconfig -d /dev/mst/mt4119_pciconf0 query
Device #1:
----------
Device type: ConnectX5
Name: MCX556A-ECA_Ax
Description: ConnectX-5 VPI adapter card; EDR IB (100Gb/s) and 100GbE; dual-port QSFP28; PCIe3.0 x16; tall bracket; ROHS R6
Device: /dev/mst/mt4119_pciconf0
Configurations: Next Boot
...
LINK_TYPE_P1 IB(1)
LINK_TYPE_P2 IB(1)
...
可以看到LINK_TYPE_P1和LINK_TYPE_P2的配置都是IB。
- 将设备切换到以太网模式
$ sudo mlxconfig -d /dev/mst/mt4119_pciconf0 set LINK_TYPE_P1=2 LINK_TYPE_P2=2
Device #1:
----------
Device type: ConnectX5
Name: MCX556A-ECA_Ax
Description: ConnectX-5 VPI adapter card; EDR IB (100Gb/s) and 100GbE; dual-port QSFP28; PCIe3.0 x16; tall bracket; ROHS R6
Device: /dev/mst/mt4119_pciconf0
Configurations: Next Boot New
LINK_TYPE_P1 IB(1) ETH(2)
LINK_TYPE_P2 IB(1) ETH(2)
Apply new Configuration? (y/n) [n] : y
Applying... Done!
-I- Please reboot machine to load new configurations.
- 重启服务器
sudo reboot
Notice:这里需要特别注意,更改完网卡模式部分服务器重启后IB网卡并不能工作在以太模式(目前发现H100和H800都不行),需要服务器强行断开电源半分钟后再加电启动才能正常切换到以太模式。
现在网卡已经变成以太网模式的了,可以通过下面几种命令查看
$ ibdev2netdev
mlx5_0 port 1 ==> ens10f0 (Down)
mlx5_1 port 1 ==> ens10f1 (Up)
$ ifconfig
ens10f0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 10:70:fd:2f:e4:40 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens10f1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::9a81:307c:1222:53bc prefixlen 64 scopeid 0x20<link>
ether 10:70:fd:2f:e4:41 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 45 bytes 7117 (7.1 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
$ ibstat
CA 'mlx5_0'
...
Port 1:
...
Link layer: Ethernet
CA 'mlx5_1'
.
Port 1:
...
Link layer: Ethernet
Ubuntu22.04网卡yaml配置文件参考:
network:
bonds:
bond0:
addresses:
- 100.64.24.27/22
interfaces:
- enp41s0f0np0
- enp170s0f0np0
nameservers:
addresses:
- 223.5.5.5
- 221.199.12.157
- 221.199.12.158
parameters:
lacp-rate: fast
mode: 802.3ad
transmit-hash-policy: layer3+4
routes:
- to: 0.0.0.0/0
via: 100.64.27.254
bond1:
addresses:
- 100.64.32.27/22
interfaces:
- enp170s0f1np1
- enp41s0f1np1
parameters:
lacp-rate: fast
mode: 802.3ad
transmit-hash-policy: layer3+4
routes:
- to: 100.64.32.0/22
via: 100.64.35.254
ethernets:
enp25s0np0:
dhcp4: no
addresses: [10.21.128.27/24]
mtu: 9000
routes:
- to: 10.21.128.0/19
via: 10.21.128.254
enp59s0np0:
dhcp4: no
addresses: [10.21.129.27/24]
mtu: 9000
routes:
- to: 10.21.128.0/19
via: 10.21.129.254
enp155s0np0:
dhcp4: no
addresses: [10.21.130.27/24]
mtu: 9000
routes:
- to: 10.21.128.0/19
via: 10.21.130.254
enp187s0np0:
dhcp4: no
addresses: [10.21.131.27/24]
mtu: 9000
routes:
- to: 10.21.128.0/19
via: 10.21.131.254
enp170s0f0np0:
dhcp4: true
enp170s0f1np1:
dhcp4: true
enp41s0f0np0:
dhcp4: true
enp41s0f1np1:
dhcp4: true
version: 2