13.8.6. 使用命令行工具 nmcli 配置 IPoIB
首先确定是否需要重命名默认 IPoIB 设备,如果需要,请按照 第 13.5.2 节 “70-persistent-ipoib.rules 的使用” 部分中的说明使用 udev 重命名规则重命名设备。通过删除 the
ib_ipoib
内核模块,然后重新载入它,用户可以强制重命名 IPoIB 接口而不重新启动:
~]$ rmmod ib_ipoib ~]$ modprobe ib_ipoib
设备具有所需的名称后,使用 nmcli 工具创建 IPoIB 接口。以下示例显示了两种方式:
例 13.3. 在两个单独的命令中创建和修改 IPoIB。
~]$ nmcli con add type infiniband con-name mlx4_ib0 ifname mlx4_ib0 transport-mode connected mtu 65520 Connection 'mlx4_ib0' (8029a0d7-8b05-49ff-a826-2a6d722025cc) successfully added. ~]$ nmcli con edit mlx4_ib0 ===| nmcli interactive connection editor |=== Editing existing 'infiniband' connection: 'mlx4_ib0' Type 'help' or '?' for available commands. Type 'describe [>setting<.>prop<]' for detailed property description. You may edit the following settings: connection, infiniband, ipv4, ipv6 nmcli> set infiniband.mac-address 80:00:02:00:fe:80:00:00:00:00:00:00:f4:52:14:03:00:7b:cb:a3 nmcli> save Connection 'mlx4_ib3' (8029a0d7-8b05-49ff-a826-2a6d722025cc) successfully updated. nmcli> quit
或者您可以在一个命令中运行 nmcli c add 和 nmcli c modify,如下所示:
例 13.4. 通过一个命令创建和修改 IPoIB.
nmcli con add type infiniband con-name mlx4_ib0 ifname mlx4_ib0 transport-mode connected mtu 65520 infiniband.mac-address 80:00:02:00:fe:80:00:00:00:00:00:00:f4:52:14:03:00:7b:cb:a3
在这些点上,已创建了名为
mlx4_ib0
的 IPoIB 接口,并设置为使用连接模式、最大连接模式 MTU、DHCP
(IPv 4
和 IPv6
)。如果将 IPoIB 接口用于集群流量和用于集群外通信的以太网接口,则可能需要在 IPoIB 接口上禁用默认路由和任何默认名称服务器。这可按如下方式完成:
~]$ nmcli con edit mlx4_ib0
===| nmcli interactive connection editor |===
Editing existing 'infiniband' connection: 'mlx4_ib0'
Type 'help' or '?' for available commands.
Type 'describe [>setting<.>prop<]' for detailed property description.
You may edit the following settings: connection, infiniband, ipv4, ipv6
nmcli> set ipv4.ignore-auto-dns yes
nmcli> set ipv4.ignore-auto-routes yes
nmcli> set ipv4.never-default true
nmcli> set ipv6.ignore-auto-dns yes
nmcli> set ipv6.ignore-auto-routes yes
nmcli> set ipv6.never-default true
nmcli> save
Connection 'mlx4_ib0' (8029a0d7-8b05-49ff-a826-2a6d722025cc) successfully updated.
nmcli> quit
如果需要
P_Key
接口,请使用 nmcli 创建一个,如下所示:
~]$ nmcli con add type infiniband con-name mlx4_ib0.8002 ifname mlx4_ib0.8002 parent mlx4_ib0 p-key 0x8002 Connection 'mlx4_ib0.8002' (4a9f5509-7bd9-4e89-87e9-77751a1c54b4) successfully added. ~]$ nmcli con modify mlx4_ib0.8002 infiniband.mtu 65520 infiniband.transport-mode connected ipv4.ignore-auto-dns yes ipv4.ignore-auto-routes yes ipv4.never-default true ipv6.ignore-auto-dns yes ipv6.ignore-auto-routes yes ipv6.never-default true