解决CentOS7网卡端口出现紊乱的问题
时间:2015-12-08 17:10 来源:linux.it.net.cn 作者:IT
最近项目上,遇到一个问题,让我们很是没办法,就是Dell R920 安装上CentOS7的系统,做完Bonding后,发现端口重启系统后会紊乱,过程如下:
-
端口紊乱情况
服务器上一共配置了两张万兆两口的网卡和一张千兆四口的网卡,其中不同万兆卡上,两端口做Bonding,同时千兆卡上也挑了间隔的两口做Bonding,大概如下情况:、
eth0,eth1,eth2,eth3千兆端口,eth4,eth5,eth6,eth7是万兆端口,这时经常紊乱是eth3,eth4的端口,两端口变更,使得做了bonding的端口无法生效
-
CentOS7的端口命名规则
原来CentOS6之前的网卡端口命名都是eth的,CentOS7之后千兆网口已经变更成随机的em0...emN或是ens01(N=整数),万兆网口则变成p1p2等形式,要修改为eth的模式步骤如下:
a.编辑文件
vi /etc/sysconfig/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="rd.lvm.lv=centos/swap vconsole.font=latarcyrheb-sun16 net.ifnames=0 biosdevname=0 rd.lvm.lv=centos/root crashkernel=auto vconsole.keymap=us rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
“以上标红色的值是修改为eth的基础”
b.执行命令生效
grub2-mkconfig -o /boot/grub2/grub.cfg
c.增加规划文件
vi /etc/udev/rules.d/70-persistent-net.rules
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="78:2b:cb:xx:xx:01", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="78:2b:cb:xx:xx:02", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="78:2b:cb:xx:xx:03", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="78:2b:cb:xx:xx:04", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:xx:xx:a1", ATTR{type}=="1", KERNEL=="eth*", NAME="eth4"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:xx:xx:a0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth5"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:60:6e:xx:xx:f6", ATTR{type}=="1", KERNEL=="eth*", NAME="eth6"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:60:6e:xx:xx:f7", ATTR{type}=="1", KERNEL=="eth*", NAME="eth7"
“以上MAC地址与网卡端口对应”
总结:以上方法并不能解决网口紊乱问题,因为官方文档都要求bond的网卡都不需要写MAC地址,所以最后我们尝试使在每个/etc/sysconfig/network-scripts/ifcfg-eth*网卡配置文件上写上HWADDR,重启有7-8遍,做ethtool检查几次,发现在没有问题,所以建议遇到同样问题同学,可以尝试一下这种方法
(责任编辑:IT)
最近项目上,遇到一个问题,让我们很是没办法,就是Dell R920 安装上CentOS7的系统,做完Bonding后,发现端口重启系统后会紊乱,过程如下:
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="78:2b:cb:xx:xx:01", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="78:2b:cb:xx:xx:02", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="78:2b:cb:xx:xx:03", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="78:2b:cb:xx:xx:04", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:xx:xx:a1", ATTR{type}=="1", KERNEL=="eth*", NAME="eth4"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:xx:xx:a0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth5"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:60:6e:xx:xx:f6", ATTR{type}=="1", KERNEL=="eth*", NAME="eth6"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:60:6e:xx:xx:f7", ATTR{type}=="1", KERNEL=="eth*", NAME="eth7" “以上MAC地址与网卡端口对应”
总结:以上方法并不能解决网口紊乱问题,因为官方文档都要求bond的网卡都不需要写MAC地址,所以最后我们尝试使在每个/etc/sysconfig/network-scripts/ifcfg-eth*网卡配置文件上写上HWADDR,重启有7-8遍,做ethtool检查几次,发现在没有问题,所以建议遇到同样问题同学,可以尝试一下这种方法 |