前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >H3C 交换机链路聚合与服务器 bond0 负载均衡设置

H3C 交换机链路聚合与服务器 bond0 负载均衡设置

作者头像
以谁为师
发布2019-05-28 20:24:48
3.7K0
发布2019-05-28 20:24:48
举报

H3Cs5560交换机

代码语言:javascript
复制
interface Bridge-Aggregation 1
    port access vlan 10
#创建聚合口,划入vlan
int g 1/0/1
    port link-aggregation group 1
#聚合的两个物理口都加入集合组
int g 2/0/1
    port link-aggregation g 1

服务器

bond0配置cat ifcfg-bond0

代码语言:javascript
复制
DEVICE=bond0
BOOTPROTO=static
IPADDR=10.0.0.126
NETMASK=255.0.0.0
GATEWAY=10.0.0.1
ONBOOT=yes
USERCTL=no
TYPE=Ethernet

eth1,2...配置cat ifcfg-eth0

代码语言:javascript
复制
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
MASTER=bond0
SLAVE=yes

配置文件开机启用bond0

vim /etc/modprobe.d/openfwwf.conf

代码语言:javascript
复制
alias bond0 bonding
options bond0 miimon=1000 mode=0

命令方式启用bond0模块

代码语言:javascript
复制
insmod /lib/modules/`uname -r`/kernel/drivers/net/bonding/bonding.ko miimon=1000 mode=0

其他配置

删除模块命令

代码语言:javascript
复制
rmmod /lib/modules/`uname -r`/kernel/drivers/net/bonding/bonding.ko miimon=1000 mode=0

license原因bond指定配置文件mac地址MACADDR=mac地址

查看状态

cat /proc/net/bonding/bond*

查看bond状态

ethtool bond0| grep -i speed

查看网卡速率如:Speed: 2000Mb/s

display link-aggregation verbose | include /0/2

Status状态为 ‘S’

配置脚本.py

代码语言:javascript
复制
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# --------------------------------------------------
#Author:        Lghost
#Email:         admin@attacker.club
#Site:           attacker.club
# --------------------------------------------------
import  sys,os,re
ip = "192.168.16.25"
netmask = "255.255.254.0"
gateway = "192.168.16.1"
bond = "0"
def warn (Text):
    print ">>>>>\t\033[1;31m%s\033[0m\t<<<<<" % Text
def info (Text):
    print ">>>>>\t\033[1;33m%s\033[0m\t<<<<<" % Text
#提示
def shell(cmd):
    os.system(cmd)
def shellinfo(cmd):
    r=os.popen(cmd)
    text=r.read()
    r.close()
    return text
#shell
def file(path,method,content):
    f=open(path,method)
    f.write(content)
    f.close()
#file
if __name__ == "__main__":
    ethx_info = shellinfo("ip add |grep ^2|awk '{print $2}'")
    eth0 = (re.match('\w+\d',ethx_info).group())
    ethx_info = shellinfo("ip add |grep ^3|awk '{print $2}'")
    eth1 = (re.match('\w+\d',ethx_info).group())
    file('/etc/sysconfig/network-scripts/ifcfg-%s' % eth0,'w',
     '''DEVICE=%s
     BOOTPROTO=none
     ONBOOT=yes
     USERCTL=no
     MASTER=bond0
     SLAVE=yes
     ''' % (eth0))
    file('/etc/sysconfig/network-scripts/ifcfg-%s' % eth1,'w',
     '''DEVICE=%s
     BOOTPROTO=none
     ONBOOT=yes
     USERCTL=no
     MASTER=bond0
     SLAVE=yes
     ''' % (eth1))
    file('/etc/sysconfig/network-scripts/ifcfg-bond0','w',
     '''DEVICE=bond0
     BOOTPROTO=static
     IPADDR=%s
     NETMASK=%s
     GATEWAY=%s
     ONBOOT=yes
     USERCTL=no
     TYPE=Ethernet
     ''' % (ip,netmask,gateway))
    file('/etc/modprobe.d/bond.conf','w',
     '''
     alias bond bonding
     options bond0 miimon=1000 mode=%s
     '''% (bond)
    info('配置文件修改完毕')
    info('本机地址:%s' % ip)
    warn('重启网卡中。。。')
    shell( 'service network restart')
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019年2月13日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • H3Cs5560交换机
  • 服务器
    • 配置文件开机启用bond0
      • 命令方式启用bond0模块
      • 其他配置
        • 删除模块命令
          • license原因bond指定配置文件mac地址MACADDR=mac地址
          • 查看状态
          • 查看bond状态
          • 查看网卡速率如:Speed: 2000Mb/s
          • Status状态为 ‘S’
            • 配置脚本.py
            领券
            问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档