1.5 多网卡绑定设置
安装 GBase 8a Mpp Cluster 产品的服务器建议支持外网和内网两种模式。
所谓外网,是可以供应用访问的网络,一般使用千兆网络;内网是用于 GBase 8a
Mpp Cluster 产品内部数据交换和信息发送使用的网络,一般使用万兆或者以
上的网络;外网和内网同时也可以组成一个网络。
为了提高网络容错或吞吐量,一般服务器都会采取多网卡绑定的策略。网
卡的绑定方式和操作系统有关,本手册以 Redhat6.2 和 Redhat7.3 操作系统为
例,说明一个双网卡绑定的案例,多网卡绑定与此相似。示例中假设主机中包
含四块网卡,其中两块绑定,用于外网;其余两块绑定,用于内网。
以下为 Redhat6.2 网卡绑定的方式:
识别网卡名称和对应的设备位置。
安装操作系统完毕后,操作系统会识别出主机的网卡名称,例如一台
主机包含两块网卡,接口名称分别为 eth1,eth2。
使用 ethtool -p eth1 命令查看相应设备名称对应的设备位置,执行
该命令后,与 eth1 相对应的网卡接口旁边的指示灯将会闪烁,这样就
能查看 eth1 网卡对应的位置;其余网卡位置的判定同此。
确定绑定方式:
eth1 和 eth2 网卡以主备模式绑定为网卡 bond0。
进行网卡 bond0 的配置:
切换目录到/etc/sysconfig/network-scripts 下,使用 root 用户进行如
下操作:
新建 ifcfg-bond0 文件,编写内容如下:
# cd /etc/sysconfig/network-scripts
# vi ifcfg-bond0
DEVICE=bond0
ONBOOT=yes
BONDING_OPTS="mode=1 miimon=100"
BOOTPROTO=static
TYPE=Ethernet
USERCTL=no
IPADDR=192.168.103.88
NETMASK=255.255.255.0
NM_CONTROLLED=no
修改 ifcfg-eth1 文件,修改内容如下:
# cd /etc/sysconfig/network-scripts
# vi ifcfg-eth1
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=none
TYPE=Ethernet
MASTER=bond0
SLAVE=yes
USERCTL=no
NM_CONTROLLED=no
修改 ifcfg-eth2 文件,修改内容如下:
# cd /etc/sysconfig/network-scripts
# vi ifcfg-eth2
DEVICE=eth2
ONBOOT=yes
BOOTPROTO=none
TYPE=Ethernet
MASTER=bond0
SLAVE=yes
USERCTL=no
NM_CONTROLLED=no
加载绑定模块
在/etc/modprobe.d/dist.conf 这个文件的末尾加入如下内容:
alias bond0 bonding
将绑定设置为开机自动加载方式
在/etc/rc.d/rc.local 这个文件的倒数第 2 行加入如下内容:
ifenslave bond0 eth1 eth2
ifup bond0
重启操作系统,验证配置正确性
重启操作系统后,在 root 用户下使用 ifconfig 命令验证配置是否正确,
验证如下情况:
A)bond0 虚拟网卡能被操作系统识别,并且配置的 IP 地址正确无误。
B)eth1,eth2 网卡不显示 IP 地址。
C)bond0 的 MAC 地址与 eth1,eth2 的其中一个相同(bond0 与哪个网卡的
MAC 地址相同,则那个网卡为现在启用的网卡)。
使用 ifconfig 命令验证上面三点:
# ifconfig
bond0 Link encap:Ethernet HWaddr 90:B1:1C:2F:FB:BF
inet addr:192.168.103.88 Bcast:192.168.255.255
Mask:255.255.255.0
inet6 addr: fe80::92b1:1cff:fe2f:fbbf/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:735202 errors:0 dropped:0 overruns:0 frame:0
TX packets:13 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:562057464 (536.0 MiB) TX bytes:1016 (1016.0 b)
eth1 Link encap:Ethernet HWaddr 90:B1:1C:2F:FB:BF
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:735202 errors:0 dropped:0 overruns:0 frame:0
TX packets:13 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:562057464 (536.0 MiB) TX bytes:1016 (1016.0 b)
Interrupt:34
在 Redhat7.3 中网卡绑定的方式和 Redhat6.2 中类似。
关闭和停止 NetworkManager 服务
//停止 NetworkManager 服务
# systemctl stop NetworkManager.service
//禁止开机启动 NetworkManager 服务
# systemctl disable NetworkManager.service
进行网卡 bond0 的配置:
切换目录到/etc/sysconfig/network-scripts 下,使用 root 用户新建编
辑 ifcfg-bond0 和修改 ifcfg-eth1、ifcfg-eth2 文件,操作同上文中 Redhat6.2
对应部分操作。
加载绑定模块
在/etc/modprobe.d/目录下创建 bonding.conf(网卡绑定模式)配置文件,
在文件末尾加入如下内容:
alias bond0 bonding
options bond0 mode=1 miimon=100
执行 modprobe bonding 命令更新加载 bonding 模块,使其系统支持网卡
bonding。
# modprobe bonding
#验证 bonding 模块是否加载成功,出现如下结果则证明加载成功
# lsmod | grep bonding
bonding 145728 0
重启网络服务,查看网络网卡信息
# systemctl restart network
# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: active-backup
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth0
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 28:6e:d4:88:ce:5d
Slave queue ID: 0
Slave Interface: eth1
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 28:6e:d4:88:ce:5e
Slave queue ID: 0
# ifconfig
将绑定设置为开机自动加载方式,重启操作系统验证网卡绑定配置正
确性,同 Redhat6.2 操作。
另外,在 Redhat7 上还提供了一项新的实现技术 Teaming。配置 Teaming
有两种方式,第一种是使用 nmcli 命令,第二种是直接修改配置文件。在本文
中不再赘述。




