高级网络控制
bond
配置:(双网卡主机)
一、简介
链路聚合,最多只能使用2块网卡。
二、bond的方式
0 扩容,2个网卡一起工作,提高效率
1 主从备份,提高稳定性
2 广播容错
三、主从方式部署
1 nmtui或者nm-connection-editor #删除所有配置
2 nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.254.132/24 #增加一个bond网络,主从方式,主机ip为172.25.254.132
3 lsmod |grep bond #会在内核上自动打开一个参数
4 nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0
5 cat /proc/net/bonding/bond0 #将eth0加到bond中
6 nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0
7 cat /proc/net/bonding/bond0 #将eth1加到bond中
8 ifconfig eth0 down #宕掉eth0
9 cat /proc/net/bonding/bond0 #查看bond情况,eth1会替换eth0
主机一直保持172.25.254.132的ip对外发布服务,即使宕掉eth0,ip也没有中断
team
一、简介
相当于是bond的加强版,可以使用最多8块网卡做负载均衡,容错性比bond更高
二、部署步骤
1.首先可以使用nmtui命令删除原来网络配置:
2.
建立team0,ip设置为172.25.254.1:
nmcli connection add con-name team0 ifname team0 type team config '{"runner":{"name":"activebackup"}}' ip4 172.25.254.134/24
查看team0状态:
teamdctl team0 state
将eth0加到team0中:
nmcli connection add con-name eth0 ifname eth0 type team-slave master team0
将eth1加到team0中:
nmcli connection add con-name eth1 ifname eth1 type team-slave master team0
3.测试
1.down掉eth0网卡,看到runner那里变为eth1,eth1网卡接替工作
2.再次打开eth0
3.down掉eth1网卡,看到runner那里变为eth0,eth0网卡接替工作
#在上述整个过程中服务器172.25.254.1这个ip一直未中断过,一直保持可以被ping到的状态
4. 删除team
nmcli connection delete team0
nmcli connection delete eth0
nmcli connection delete eth1
br0一、简介
1.桥接
2.
查找brctl命令属于哪个包:
yum whatprovides brctl
安装找到的包:
yum install bridge-utils.x86_64 -y
二、部署
1.方法一:命令方式
添加br0网络:
brctl addbr br0
给br0一个ip:
ifconfig br0 172.25.254.134/24
将eth0网卡给br0:
brctl addif br0 eth0
查看br0状态:
[[email protected] ~]# brctl show
bridge name(网桥名称) bridge id STP enabled interfaces(网卡设备)
br0 8000.525400a5ffb3 no eth0
注:只有在给br0添加一块真实网卡之后其他主机才能ping通br0
删除br0:
ifconfig br0 down
brctl delbr br0
2.方法二:文件方式
使用nmtui删除所有配置
配置br0:
vim /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
ONBOOT=yes
BOOTPROTO=none
TYPE=Bridge #网卡类型为桥接
IPADDR=172.25.254.1
PREFIX=24
配置真实网卡:
vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
BRIDGE=br0 #将eth0网卡加到br0中
重启网络:
systemctl stop NetworkManager.service #关闭上层网管程序避免之前的网络残留影响
systemctl restart network
systemctl start NetworkManager.service