机器的双网卡绑定 bonding
时间:2019-12-07 13:50 来源:linux.it.net.cn 作者:IT
1.双网卡绑定
2. 双网卡绑定的配置文件
/etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE="bond0"
BOOTPROTO="static"
ONBOOT="yes"
TYPE="ethernet"
IPADDR=x.x.x.x
NETMASK=255.255.255.0
BONDING_OPTS="miimon=100 mode=1 updelay=600000 primary=eth0" #100ms 健康检测 #mode=1 是主备模式 #primary=eth0 #默认active 是eth0
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts/ifcfg-eth1
2. 千兆网卡,突然变成10Mbps 或者100Mbps
(1) proc/net/bonding/bond0 信息查看
这个信息是linux启动后加载的硬件网卡信息
cat /proc/net/bonding/bond0 #查看双网卡信息
Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: eth0 (primary_reselect always) #默认active 是eth0
Currently Active Slave: eth1 #现在生效的主网卡是;eth1 可以切换到eth0
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 600000
Down Delay (ms): 0
Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps #有时会突然变成10M/s
Duplex: full
Link Failure Count: 0
Permanent HW addr: xxxx
Slave queue ID: 0
Slave Interface: eth1
MII Status: up
Speed: 10 Mbps # 为什么突然变成10M/s
Duplex: full
Link Failure Count: 2
Permanent HW addr: xxxxx
Slave queue ID: 0
(2). ethtool 工具来看
sudo ethtool eth0
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full #支持10M 半全双工
100baseT/Half 100baseT/Full #支持100M 半 全双工
1000baseT/Full #支持1000M 全双工
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised auto-negotiation: Yes
Speed: 100Mb/s #现在是100Mbps 实际网卡支持1000Mbps 所以网卡其实浪费了,有时网卡打满会出问题啊
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: pumbg
Wake-on: g
Current message level: 0x00000007 (7)
Link detected: yes
(3) . ethtool 修改speed
sudo ethtool -s eth0 speed 1000 #eth0 的speed 修改成1000
sudo ethtool eth0 #查看修改是否成功,此时/proc/net/bonding/bond0 还是没有修改的
sudo /etc/init.d/network restart #重启网卡
vim /proc/net/bonding/bond0 #此时 /proc/net/bonding/bond0 就修改成1000 啦
(4). ifenslave -c bond0 eth* 切换主网卡
cat /proc/net/bonding/bond0
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: eth0 (primary_reselect always)
Currently Active Slave: eth0 #现在网卡的master:eth0
#把网卡的master修改为:eth1
sudo ifenslave -c bond0 eth1
cat /proc/net/bonding/bond0
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: eth0 (primary_reselect always)
Currently Active Slave: eth1 #现在主网卡就是:eth1
(责任编辑:IT)
1.双网卡绑定 2. 双网卡绑定的配置文件 /etc/sysconfig/network-scripts/ifcfg-bond0 DEVICE="bond0" BOOTPROTO="static" ONBOOT="yes" TYPE="ethernet" IPADDR=x.x.x.x NETMASK=255.255.255.0 BONDING_OPTS="miimon=100 mode=1 updelay=600000 primary=eth0" #100ms 健康检测 #mode=1 是主备模式 #primary=eth0 #默认active 是eth0 /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth1 2. 千兆网卡,突然变成10Mbps 或者100Mbps (1) proc/net/bonding/bond0 信息查看 这个信息是linux启动后加载的硬件网卡信息 cat /proc/net/bonding/bond0 #查看双网卡信息 Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009) Bonding Mode: fault-tolerance (active-backup) Primary Slave: eth0 (primary_reselect always) #默认active 是eth0 Currently Active Slave: eth1 #现在生效的主网卡是;eth1 可以切换到eth0 MII Status: up MII Polling Interval (ms): 100 Up Delay (ms): 600000 Down Delay (ms): 0 Slave Interface: eth0 MII Status: up Speed: 1000 Mbps #有时会突然变成10M/s Duplex: full Link Failure Count: 0 Permanent HW addr: xxxx Slave queue ID: 0 Slave Interface: eth1 MII Status: up Speed: 10 Mbps # 为什么突然变成10M/s Duplex: full Link Failure Count: 2 Permanent HW addr: xxxxx Slave queue ID: 0 (2). ethtool 工具来看 sudo ethtool eth0 Settings for eth0: Supported ports: [ TP ] Supported link modes: 10baseT/Half 10baseT/Full #支持10M 半全双工 100baseT/Half 100baseT/Full #支持100M 半 全双工 1000baseT/Full #支持1000M 全双工 Supports auto-negotiation: Yes Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Advertised auto-negotiation: Yes Speed: 100Mb/s #现在是100Mbps 实际网卡支持1000Mbps 所以网卡其实浪费了,有时网卡打满会出问题啊 Duplex: Full Port: Twisted Pair PHYAD: 1 Transceiver: internal Auto-negotiation: on Supports Wake-on: pumbg Wake-on: g Current message level: 0x00000007 (7) Link detected: yes (3) . ethtool 修改speed sudo ethtool -s eth0 speed 1000 #eth0 的speed 修改成1000 sudo ethtool eth0 #查看修改是否成功,此时/proc/net/bonding/bond0 还是没有修改的 sudo /etc/init.d/network restart #重启网卡 vim /proc/net/bonding/bond0 #此时 /proc/net/bonding/bond0 就修改成1000 啦 (4). ifenslave -c bond0 eth* 切换主网卡 cat /proc/net/bonding/bond0 Bonding Mode: fault-tolerance (active-backup) Primary Slave: eth0 (primary_reselect always) Currently Active Slave: eth0 #现在网卡的master:eth0 #把网卡的master修改为:eth1 sudo ifenslave -c bond0 eth1 cat /proc/net/bonding/bond0 Bonding Mode: fault-tolerance (active-backup) Primary Slave: eth0 (primary_reselect always) Currently Active Slave: eth1 #现在主网卡就是:eth1 (责任编辑:IT) |