新浦京81707con > 功能介绍 > RHEL6配置双网卡bonding及桥接,端口绑定

原标题:RHEL6配置双网卡bonding及桥接,端口绑定

浏览次数:83 时间:2019-11-07

试验景况:VMware Workstation8

对象:Linux下多网卡设想一个网卡,使其一网卡坏掉不影响互联网采纳。

透过网口绑定(bond)技艺,能够十分轻易完毕网口冗余,负载均衡,进而完结高可用负载均衡的目标。

RHEL6.2

步骤:

[[email protected] ~]# cat /etc/issue
CentOS release 6.5 (Final)
Kernel r on an m

双网卡(虚机做bonding实验只扶植mode=1热备方式卡塔尔

1、修正eth0、eth1配置文件
ifcfg-eth0

[[email protected] ~]# echo "alias netdev-bond0 bonding" >/etc/modprobe.d/bonding.conf

# cd /etc/sysconfig/network-scripts/
 
# cat ifcfg-eth0
DEVICE="eth0"
HWADD大切诺基="00:0C:29:E4:DC:43"   (提出不钦赐MAC地址卡塔 尔(阿拉伯语:قطر‎
#NM_CONTROLLED="yes"
ONBOOT="yes"
BOOTPROTO=none
MASTER=bond1
SLAVE=yes
USERCTL=no
 
# cat ifcfg-eth1
DEVICE="eth1"
HWADD奥迪Q3="00:0C:29:E4:DC:4D"    (建议不钦命MAC地址卡塔 尔(英语:State of Qatar)
#NM_CONTROLLED="yes"
ONBOOT="yes"
BOOTPROTO=none
MASTER=bond1
SLAVE=yes
USERCTL=no
 
# cat ifcfg-bond1
DEVICE=bond1
#TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
#IPADDR=192.168.10.88
#NETMASK=255.255.255.0
#GATEWAY=192.168.10.2
USERCTL=no
BRIDGE=br0
BONDING_OPTS="miimon=100 mode=1" 
#出于中华VHEL6与早先不均等,所以钦命方式参数放在这里bonding文件中
 
# cat ifcfg-br0
DEVICE="br0"
#HWADDR="00:0C:29:E4:DC:43"
#NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE=Bridge
BOOTPROTO=static
#MASTER=bond1
#SLAVE=yes
#USERCTL=no
IPADDR=192.168.10.88
NETMASK=255.255.255.0
GATEWAY=192.168.10.2
 
# cat /etc/modprobe.d/modprobe.conf
alias netdev-bond1 bonding
 
重启系统查阅
# ifconfig
bond1     Link encap:Ethernet  HWaddr 00:0C:29:E4:DC:43
          inet6 addr: fe80::20c:29ff:fee4:dc43/64 Scope:Link
          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
          RX packets:1947 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2774 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:185500 (181.1 KiB)  TX bytes:279330 (272.7 KiB)
 
br0       Link encap:Ethernet  HWaddr 00:0C:29:E4:DC:43
          inet addr:192.168.10.88  Bcast:192.168.10.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fee4:dc43/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:925 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2708 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:78625 (76.7 KiB)  TX bytes:274754 (268.3 KiB)
 
eth0      Link encap:Ethernet  HWaddr 00:0C:29:E4:DC:43
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:1039 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2775 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:100299 (97.9 KiB)  TX bytes:280072 (273.5 KiB)
 
eth1      Link encap:Ethernet  HWaddr 00:0C:29:E4:DC:43
          UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
          RX packets:909 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:85267 (83.2 KiB)  TX bytes:0 (0.0 b)
 
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
MASTER=bond0
SLAVE=yes

网卡绑定前须求施行这些命令,以此来加多服务器运维时加载的模块。

图片 1

ifcfg-eth1

修正新建网卡绑定bond0配置文件

DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
MASTER=bond0
SLAVE=yes

[[email protected] ~]# vim /etc/sysconfig/network-scripts/ifcfg-bond0

2、配置虚构网卡
vi /etc/sysconfig/network-scripts/ifcfg-bond0

DEVICE=bond0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=static
USERCTL=no
PEERDNS=yes
IPV6INIT=no
IPADDR=112.25.xx.xx
NETMASK=255.255.255.192
BROADCAST=112.25.xx.xx
GATEWAY=112.25.xx.xx
BONDING_OPTS="miimon=80 mode=6"

DEVICE=bond0
BOOTPROTO=none
BROADCAST=192.168.1.255
IPADDR=192.168.1.97
NETMASK=255.255.255.0
NETWORK=192.168.1.0
ONBOOT=yes
TYPE=Ethernet
GATEWAY=192.168.1.1
USERCTL=no

miimon 是链路监测的时光距离单位是皮秒,miimon=80的意思正是每80ms监测三次链路连接景况,假诺有一条线路短路就转入另一条路径。

3、编辑modules.conf
vi /etc/modules.conf
alias bond0 bonding
options bond0 miimon=100 mode=1 primary=eth0

mode=0 表示负载均衡情势,两块网卡都干活,须要调换机作支撑

4、添加rc.local
modprobe bonding miimon=100 mode=1

mode=1 表示冗余方式,网卡唯有三个行事,一个出标题启用此外的

ifconfig
bond0 Link encap:Ethernet HWaddr 00:0C:29:20:C9:4A
inet addr:192.168.1.97 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe20:c94a/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:1065 errors:0 dropped:0 overruns:0 frame:0
TX packets:694 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:102157 (99.7 KiB) TX bytes:104152 (101.7 KiB)
eth0 Link encap:Ethernet HWaddr 00:0C:29:20:C9:4A
inet6 addr: fe80::20c:29ff:fe20:c94a/64 Scope:Link
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:981 errors:0 dropped:0 overruns:0 frame:0
TX packets:697 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:90816 (88.6 KiB) TX bytes:105086 (102.6 KiB)
Interrupt:185 Base address:0x1400
eth1 Link encap:Ethernet HWaddr 00:0C:29:20:C9:4A
inet6 addr: fe80::20c:29ff:fe20:c94a/64 Scope:Link
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:89 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:11641 (11.3 KiB) TX bytes:468 (468.0 b)
Interrupt:169 Base address:0x1480

mode=6 表示负载均衡情势,两块网卡都干活,无需交换机作支撑

本文由新浦京81707con发布于功能介绍,转载请注明出处:RHEL6配置双网卡bonding及桥接,端口绑定

关键词: 新浦京81707con

上一篇:如何搭建Percona

下一篇:没有了