bond绑定之后服务器无法正常登录

bond绑定之后服务器无法正常登录,第1张

一般情况下,在绑定Bond之后,服务器不能正常登录的原因可能是:

1. 网络设置问题。构建Bond网络的时候,由于网络参数的错误设置,导致服务器无法在网络中获得有效的IP地址;

2. 操作系统设置问题。在构建Bond之后,操作系统可能会分配错误的网卡(NIC)优先级,从而导致服务器无法正常连接网络;

3. 路由器设置问题。路由器或者交换机进行映射设置失误或者网络参数设置不当,都可能导致终端无法连接服务器。

可以。

bond的英文释义为纽带、联系,那么在Linux中,bond是一种虚拟网卡的技术,可以把几块网卡联系起来,虚拟成一块网卡来对外提供服务。

目前网卡绑定mode共有七种(0~6)bond0、bond1、bond2、bond3、bond4、bond5、bond6

常用的有三种:

mode=0:平衡负载模式,有自动备援,但需要”Switch”支援及设定。

mode=1:自动备援模式,其中一条线若断线,其他线路将会自动备援。

mode=6:平衡负载模式,有自动备援,不必”Switch”支援及设定。

Linux网口绑定:

通过网口绑定(bond)技术,可以很容易实现网口冗余,负载均衡,从而达到高可用高可靠的目的。前提约定:

2个物理网口分别是:eth0,eth1

绑定后的虚拟口是:bond0

服务器IP是:10.10.10.1

第一步,配置设定文件:

[root@woo ~]# vi  /etc/sysconfig/network-scripts/ifcfg-bond0  

DEVICE=bond0  

BOOTPROTO=none  

ONBOOT=yes  

IPADDR=10.10.10.1  

NETMASK=255.255.255.0  

NETWORK=192.168.0.0 

[root@woo ~]# vi  /etc/sysconfig/network-scripts/ifcfg-eth0  

DEVICE=eth0  

BOOTPROTO=none  

MASTER=bond0  

SLAVE=yes 

[root@woo ~]# vi  /etc/sysconfig/network-scripts/ifcfg-eth1  

DEVICE=eth1  

BOOTPROTO=none  

MASTER=bond0  

SLAVE=yes  

第二步,修改modprobe相关设定文件,并加载bonding模块:

1.在这里,我们直接创建一个加载bonding的专属设定文件/etc/modprobe.d/bonding.conf  

[root@woo ~]# vi /etc/modprobe.d/bonding.conf  

alias bond0 bonding  

options bonding mode=0 miimon=200 

2.加载模块(重启系统后就不用手动再加载了)  

[root@woo ~]# modprobe bonding 

3.确认模块是否加载成功:  

[root@woo ~]# lsmod | grep bonding  

bonding 100065 0  

第三步,重启一下网络,然后确认一下状况:

[root@db01 ~]# service network restart  

Shutting down interface bond0:  [  OK  ]  

Shutting down loopback interface:  [  OK  ]  

Bringing up loopback interface:  [  OK  ]  

Bringing up interface bond0:  [  OK  ] 

[root@db01 ~]#  cat /proc/net/bonding/bond0  

Ethernet Channel Bonding Driver: v3.4.0-1 (October 7, 2008) 

Bonding Mode: fault-tolerance (active-backup)  

Primary Slave: None  

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: 40:f2:e9:db:c9:c2 

Slave Interface: eth1  

MII Status: up  

Speed: 1000 Mbps  

Duplex: full  

Link Failure Count: 0  

Permanent HW addr: 40:f2:e9:db:c9:c3  

[root@db01 ~]#  ifconfig | grep HWaddr  

bond0     Link encap:Ethernet  HWaddr 40:F2:E9:DB:C9:C2    

eth0      Link encap:Ethernet  HWaddr 40:F2:E9:DB:C9:C2    

eth1      Link encap:Ethernet  HWaddr 40:F2:E9:DB:C9:C2    

从上面的确认信息中,我们可以看到3个重要信息:

1.现在的bonding模式是active-backup

2.现在Active状态的网口是eth0

3.bond0,eth1的物理地址和处于active状态下的eth0的物理地址相同,这样是为了避免上位交换机发生混乱。

任意拔掉一根网线,然后再访问你的服务器,看网络是否还是通的。

第四步,系统启动自动绑定、增加默认网关:

[root@woo ~]# vi /etc/rc.d/rc.local  

#追加  

ifenslave bond0 eth0 eth1  

route add default gw 10.10.10.1 


欢迎分享,转载请注明来源:夏雨云

原文地址:https://www.xiayuyun.com/zonghe/466873.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-06-05
下一篇2023-06-05

发表评论

登录后才能评论

评论列表(0条)

    保存