首页 > 代码库 > CentOS下bond的配置方法

CentOS下bond的配置方法

博文目录

简介

    这里介绍一下Centos6网卡的bond配置方法,由于CentOS6、和CentOS7配置bond的方法不太一样,所以这里单独的介绍一下Centos6bond配置的方法,当然这种方法也适用于CentOS7只不过CentOS7配置的方法要更高效,以后会再对CentOS7bond的配置方法。

一、概念

    bond,就是网卡绑定啦,对于大型的机房来讲,是要有冗余机制的,bond便是一种网卡冗余机制,用来增加可靠性,防止单个网卡损坏出现的网络不通的情况,当然也可以提高可用性,让两张网卡同事进行数据传输。

二、配置方法

当然要做这个技术是需要两块以上的网卡的 

bonding(网卡绑定)

/etc/sysconfig/network-scripts下

建立ifcfg-bond0文件添加一下内容

DEVICE=bond0   设备名   

ONBOOT=yes  开机自启

BOOTPROTO=static  设置ip获取协议dhcp|static

IPADDR=6.6.6.6  这是IP

PREFIX=8 这是子网掩码

GATEWAY=6.6.6.1  设置网关

BONDING_OPTS="miimon=100 mode=0 primary=eth0"

mode 绑定模式:

                       0负载均衡模式

                     1准备模式

                     3镜像模式

miimon 多长时间测试物理网卡是否联通

primary 指定主网卡

    删除bond

ifconfig bond0 down

删除bond0文件

修改eth0、1文件

rmmod bonding

前导工作

[root@centos6 Desktop]# mkdir ~/if.bak     建立备份文件夹
[root@centos6 Desktop]# cp /etc/sysconfig/network-scripts/ifcfg-eth* ~/if.bak/
    备份网卡文件
[root@centos6 Desktop]# service NetworkManager stop
    关闭NetworkManager服务
Stopping NetworkManager daemon:               [  OK  ]
[root@centos6 Desktop]# chkconfig NetworkManager off
    关闭NetworkManager自启动服务
[root@centos6 Desktop]# iptables -F             清空防火墙

bond0 的操作

[root@centos6 Desktop]# cd /etc/sysconfig/network-scripts/ 进入网卡配置文件存放目录
[root@centos6 network-scripts]# touch ifcfg-bond0         创建bond0文件
[root@centos6 network-scripts]# vim ifcfg-bond0           编辑bond0文件
[root@centos6 network-scripts]# cat ifcfg-bond0 
DEVICE=bond0
ONBOOT=yes
BOOTPROTO=none
IPADDR=172.18.17.203
PREFIX=24
BONDING_OPTS="mode=1 miimon=100 primary=eth0"

eth0的操作

[root@centos6 network-scripts]# vim ifcfg-eth0
DEVICE=eth0
SLAVE=yes
MASTER=bond0

eth1的操作

[root@centos6 network-scripts]# vim ifcfg-eth1
DEVICE=eth1
SLAVE=yes
MASTER=bond0

后续操作

[root@centos6 network-scripts]#service network restart
[root@centos6 network-scripts]# cat /proc/net/bonding/bond0    查看bond0状态

Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: eth0 (primary_reselect always)
Currently Active Slave: eth0
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:08:bd:6d
Slave queue ID: 0

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



本文出自 “12612752” 博客,请务必保留此出处http://12622752.blog.51cto.com/12612752/1909027

CentOS下bond的配置方法