redhat 6.4 双网卡bond主备模式简单配置

来源:互联网 发布:matlab dsp编程 编辑:程序博客网 时间:2024/06/07 01:43

问题:在日常场景维护中为了应用环境的高可用性,其中网卡的高可用性是最基础的性质;此文就redhat 6.4版本做个简单的主备bond配置;在linux 7中将使用team的概念配置将变的更加简单,后期有机会再做测试学习;

实施步骤:

1、创建一个bond0的文件

2、配置bond0文件的网卡内容信息

3、将eth1和eth2 配置网卡信息添加入bond0网卡中

4、设置/etc/modprobe.d/dist.conf 保证网卡运行在主备模式下(如果使用负载均衡模式,请做相关的配置以及测试)


实验:

查看网卡信息:

[root@redis ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:E5:8C:03  
          inet addr:192.168.1.30  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fee5:8c03/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:175 errors:0 dropped:0 overruns:0 frame:0
          TX packets:109 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:21468 (20.9 KiB)  TX bytes:14431 (14.0 KiB)


eth1      Link encap:Ethernet  HWaddr 08:00:27:41:41:5C  
          inet addr:192.168.56.102  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe41:415c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:14 errors:0 dropped:0 overruns:0 frame:0
          TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:5644 (5.5 KiB)  TX bytes:2946 (2.8 KiB)


eth2      Link encap:Ethernet  HWaddr 08:00:27:F2:30:D5  
          inet addr:192.168.56.101  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fef2:30d5/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:16 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:6610 (6.4 KiB)  TX bytes:1152 (1.1 KiB)


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:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:240 (240.0 b)  TX bytes:240 (240.0 b)


创建并配置bond0网卡

[root@redis network-scripts]# touch /etc/sysconfig/network-scripts/ifcfg-bond0

[root@redis network-scripts]# cat ifcfg-bond0 
DEVICE=bond0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=no
IPADDR=192.168.1.100
PREFIX=24
GATEWAY=192.168.1.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
NAME="System bond0"

配置eth1,eth2配置文件,将两个网卡加入到bond0中来

[root@redis network-scripts]# cat ifcfg-eth1 
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
PEERDNS=no


[root@redis network-scripts]# cat ifcfg-eth2
DEVICE=eth2
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
PEERDNS=no

配置添加/etc/modprobe.d/dist.conf内容

最后一行添加
alias bond0 bonding
options bond0 miimon=100 mode=1 max_bonds=2


停止NMCI服务,重新启动网卡信息

service iptables stop
chkconfig iptables off
service NetworkManager stop
chkconfig NetworkManager off
[root@redis network-scripts]# service network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down interface eth1:  /etc/sysconfig/network-scripts/ifdown-eth: line 116: /sys/class/net/bond0/bonding/slaves: No such file or directory
                                                           [  OK  ]
Shutting down interface eth2:  /etc/sysconfig/network-scripts/ifdown-eth: line 116: /sys/class/net/bond0/bonding/slaves: No such file or directory
                                                           [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface bond0:                               [  OK  ]
Bringing up interface eth0:                                [  OK  ]

测试:网卡相互down测试网络连通性
首选查看bond0的运行信息
[root@redis network-scripts]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth1
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0


Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 08:00:27:41:41:5c
Slave queue ID: 0


Slave Interface: eth2
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 08:00:27:f2:30:d5
Slave queue ID: 0
[root@redis network-scripts]# 

down eth1
ifdown eth1 查看确认 ping
至此双网卡主备绑定完成;
总结:配置简单,在生产环境中配置还是相对来说比较多的;这里只是其中的一种方法,还有其他很多的配置方法,请看官自行测试;

阅读全文
'); })();
0 0
原创粉丝点击
热门IT博客
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 黄鹤楼写作背景 野望写作背景 手机写作软件 写作技巧有哪些 写作软件手机版 写作方法与技巧 基础写作教程 写作文的技巧 写文软件 创作软件 托福作文 作文技巧 从百草园到三味书屋写作背景 百草园到三味书屋写作背景 写信范文 写信图片 写信拼音 写信的作文 写信的拼音 写信格式图 想你就写信 写信英文 写信英语 怎么写信 写信的英文 英语写信 小学生写信 写信结尾 写信开头 写信模板 给爸爸写信 写信造句 二年级写信 男朋友写信 写信给爸爸 怎样写信 给孩子写信 如何写信 写信告诉我 秋娃娃写信 写信表白