本文目的
在管理daos 集群过程中,尤其是当集群规模达到千节点,为使用 并发工具,如pdsh 或clush 来批量化部署管理业务, 保证网络接口统一十分关键,一方面提高我们的工作效率,另一方面是大大降低集群的维护成本。
怎么做?
环境:centos stream9
1.修改网络接口配置文件
#1.ifconfig 查看接口名称,默认是eno* 、ens*
[root@hik2 home]# ifconfig
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.192.53.82 netmask 255.255.255.0 broadcast 10.192.53.255
inet6 fe80::3eec:efff:feb6:c632 prefixlen 64 scopeid 0x20<link>
ether 3c:ec:ef:b6:c6:32 txqueuelen 1000 (Ethernet)
RX packets 43459267 bytes 6112520394 (5.6 GiB)
RX errors 0 dropped 842 overruns 0 frame 0
TX packets 73098578 bytes 9751537499 (9.0 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device memory 0xbba20000-bba3ffff
eno2: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 3c:ec:ef:b6:c6:33 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
device memory 0xbba00000-bba1ffff
ens102f0np0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.254.254.109 netmask 255.255.255.0 broadcast 10.254.254.255
inet6 fe80::1270:fdff:fea3:2c88 prefixlen 64 scopeid 0x20<link>
ether 10:70:fd:a3:2c:88 txqueuelen 1000 (Ethernet)
RX packets 5259 bytes 369347 (360.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 488 bytes 30876 (30.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens102f1np1: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 10:70:fd:a3:2c:89 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
ens85f0np0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.254.254.9 netmask 255.255.255.0 broadcast 10.254.254.255
inet6 fe80::1270:fdff:fe31:eca4 prefixlen 64 scopeid 0x20<link>
ether 10:70:fd:31:ec:a4 txqueuelen 1000 (Ethernet)
RX packets 5257 bytes 369037 (360.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 458 bytes 28684 (28.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens85f1np1: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 10:70:fd:31:ec:a5 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
#2.修改网络配置文件中接口名称并将配置文件重命名
cd /etc/NetworkManager/system-connections # stream9 的网络配置文件位置
[root@hik2 system-connections]# ll
total 28
-rw-------. 1 root root 343 May 23 04:51 eno1.nmconnection #修改为eth0
-rw-------. 1 root root 256 Mar 6 2023 eno2.nmconnection #修改为eth1
-rw-------. 1 root root 297 Jun 12 00:03 ens102f0np0.nmconnection #修改为eth2
-rw-------. 1 root root 278 May 12 05:35 ens102f1np1.nmconnection # (外部业务网络暂忽略)
-rw-------. 1 root root 303 Jul 28 02:49 ens85f0np0.nmconnection #修改为eth3
-rw-------. 1 root root 276 Jul 28 02:48 ens85f1np1.nmconnection # (外部业务网络暂忽略)
-rw-------. 1 root root 285 Mar 6 2023 usb0.nmconnection
以修改eth为例:
vi eth0.nmconnection
配置文件内容:
[connection]
id=eth0 #修改为新的接口名称
uuid=0e130ae2-751c-3543-872c-c14c1220ae76
type=ethernet
autoconnect-priority=-999
interface-name=eth0 #修改为新的接口名称
permissions=
timestamp=1684831761
[ethernet]
mac-address-blacklist=
[ipv4]
address1=10.192.53.82/24,10.192.53.254
dns=10.1.7.88;
dns-search=
method=manual
[ipv6]
addr-gen-mode=eui64
dns-search=
method=auto
[proxy]
修改后:
[root@hik2 system-connections]# ll
total 28
-rw-------. 1 root root 278 May 12 05:35 ens102f1np1.nmconnection
-rw-------. 1 root root 276 Jul 28 02:48 ens85f1np1.nmconnection
-rw-------. 1 root root 341 Oct 13 03:16 eth0.nmconnection
-rw-------. 1 root root 256 Oct 13 03:18 eth1.nmconnection
-rw-------. 1 root root 283 Oct 13 03:19 eth2.nmconnection
-rw-------. 1 root root 291 Oct 13 03:19 eth3.nmconnection
-rw-------. 1 root root 285 Mar 6 2023 usb0.nmconnection
# 3.修改 /etc/default/grub
[root@hik2 system-connections]# cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M resume=/dev/mapper/cs-swap rd.lvm.lv=cs/root rd.lvm.lv=cs/swap rhgb quiet biosdevname=0 net.ifnames=0" #添加 biosdevname=0 net.ifnames=0
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true
GRUB_CMDLINE_LINUX_DEFAULT="intel_iommu=on"
# after saving the file, run the following to reconfigure
# the bootloader:
$ sudo grub2-mkconfig --output=/boot/grub2/grub.cfg
# if the command completed with no errors, reboot the system
# in order to make the changes take effect
$ sudo reboot
为什么这么做?
网卡命名的规则主要和 biosdevname 和 net.ifnames 两个参数的影响。两个参数值的不同组合决定的网卡接口的命名格式:
当我们编辑完成的时候不会立即生效,因为这个文件并不会被启动设置所读取到,而/boot/grub2/grub.cfg是被系统启动时真正读取到的,所以需要把刚才编辑好的文件转换为系统可以真正读取到的文件。