找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 7779|回复: 25

[负载平衡] NTH负载均衡的断线切换讨论

[复制链接]
发表于 2008-8-12 22:43:01 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×
做过NTH负载均衡的都知道,无论多少条接入做均衡,只要其中一条或多条线出故障,整个网络将瘫痪,为了保证整个网络的正常运行,必需有一个完整的切换脚本。以4条线接入为例,思路如下:
1.减线均衡法
  把剩下的线三条或二条线再重新做负载均衡,当线路恢复后,再做回4线均衡。但脚本太复杂还没想通,请高人.....发表
2.均衡转分流(包括IP分流和端口分流)
  禁止现在的/ ip firewall nat / ip firewall mangle 均衡设置,启用里面预先设置好的分流方式。当检测到线路恢复后,再禁用分流,转为均衡。
routeros
发表于 2008-8-12 22:49:58 | 显示全部楼层
不知道
routeros
回复

使用道具 举报

发表于 2008-8-12 23:08:32 | 显示全部楼层
不会做均衡,如果会做了理解了,切换脚本应该能做出来的
routeros
回复

使用道具 举报

 楼主| 发表于 2008-8-13 05:16:27 | 显示全部楼层
以你的智慧还不会做这个,不信哦!
下面这个是我做的
http://bbs.routerclub.com/thread-32986-1-2.html
routeros
回复

使用道具 举报

发表于 2008-8-13 14:43:18 | 显示全部楼层
呵呵,前段时间帮别人做了个4线均衡,完整考虑到了其中某一线或某几线断开时的调整,以下是检测调整的脚本
:global ip
:global gateold
:global address
:global ii 0

/interface pppoe-client monitor pppoe-out1 once do={:global adsl-statu $status}
:if ($adsl-statu="connected") do={

:set ip [/ip add  get [/ip add find inter=pppoe-out1 dynamic=yes] address]
:set address [:pick $ip 0 [:find $ip "/"]]
:set gateold [/ip route  get [/ip route find comm=adsl1] gateway]
    :if ($gateold!=$address) do={
    /ip add set [/ip add find comm=adsl1] address=$ip  network=$address broadcast=$address
    /ip route set [/ip route find comm=adsl1] gateway=$address
    }
:set ii ($ii+1)
}

/interface pppoe-client monitor pppoe-out2 once do={:global adsl-statu $status}
:if ($adsl-statu="connected") do={

:set ip [/ip add  get [/ip add find inter=pppoe-out2 dynamic=yes] address]
:set address [:pick $ip 0 [:find $ip "/"]]
:set gateold [/ip route  get [/ip route find comm=adsl2] gateway]
    :if ($gateold!=$address) do={
    /ip add set [/ip add find comm=adsl2] address=$ip  network=$address broadcast=$address
    /ip route set [/ip route find comm=adsl2] gateway=$address
    }
:set ii ($ii+1)
}

/interface pppoe-client monitor pppoe-out3 once do={:global adsl-statu $status}
:if ($adsl-statu="connected") do={

:set ip [/ip add  get [/ip add find inter=pppoe-out3 dynamic=yes] address]
:set address [:pick $ip 0 [:find $ip "/"]]
:set gateold [/ip route  get [/ip route find comm=adsl3] gateway]
    :if ($gateold!=$address) do={
    /ip add set [/ip add find comm=adsl3] address=$ip  network=$address broadcast=$address
    /ip route set [/ip route find comm=adsl3] gateway=$address
    }
:set ii ($ii+1)
}

/interface pppoe-client monitor pppoe-out4 once do={:global adsl-statu $status}
:if ($adsl-statu="connected") do={

:set ip [/ip add  get [/ip add find inter=pppoe-out4 dynamic=yes] address]
:set address [:pick $ip 0 [:find $ip "/"]]
:set gateold [/ip route  get [/ip route find comm=adsl4] gateway]
    :if ($gateold!=$address) do={
    /ip add set [/ip add find comm=adsl4] address=$ip  network=$address broadcast=$address
    /ip route set [/ip route find comm=adsl4] gateway=$address
    }
:set ii ($ii+1)
}

:if ($ii=2) do={
:if ([ip fi man get [/ip fi man find comm=adsl1] disabled]=yes) do={/ip fi man en [/ip fi man find comm=adsl1]}
:if ([ip fi man get [/ip fi man find comm=adsl2] disabled]=yes) do={/ip fi man en [/ip fi man find comm=adsl2]}
:if ([ip fi man get [/ip fi man find comm=adsl3] disabled]=no) do={/ip fi man dis [/ip fi man find comm=adsl3]}
:if ([ip fi man get [/ip fi man find comm=adsl4] disabled]=no) do={/ip fi man dis [/ip fi man find comm=adsl4]}
:if ([ip fi man get [/ip fi man find comm=adsl1 action=mark-connection] nth]!=1,1,0) do={/ip fi man set [/ip fi man find comm=adsl1 action=mark-connection] nth=1,1,0}
:if ([ip fi man get [/ip fi man find comm=adsl2 action=mark-connection] nth]!=1,1,1) do={/ip fi man set [/ip fi man find comm=adsl2 action=mark-connection] nth=1,1,1}
}
:if ($ii=3) do={
:if ([ip fi man get [/ip fi man find comm=adsl1] disabled]=yes) do={/ip fi man en [/ip fi man find comm=adsl1]}
:if ([ip fi man get [/ip fi man find comm=adsl2] disabled]=yes) do={/ip fi man en [/ip fi man find comm=adsl2]}
:if ([ip fi man get [/ip fi man find comm=adsl3] disabled]=yes) do={/ip fi man en [/ip fi man find comm=adsl3]}
:if ([ip fi man get [/ip fi man find comm=adsl4] disabled]=no) do={/ip fi man dis [/ip fi man find comm=adsl4]}
:if ([ip fi man get [/ip fi man find comm=adsl1 action=mark-connection] nth]!=2,3,0) do={/ip fi man set [/ip fi man find comm=adsl1 action=mark-connection] nth=2,3,0}
:if ([ip fi man get [/ip fi man find comm=adsl2 action=mark-connection] nth]!=2,3,1) do={/ip fi man set [/ip fi man find comm=adsl2 action=mark-connection] nth=2,3,1}
:if ([ip fi man get [/ip fi man find comm=adsl3 action=mark-connection] nth]!=2,3,2) do={/ip fi man set [/ip fi man find comm=adsl3 action=mark-connection] nth=2,3,2}
}
:if ($ii=4) do={
:if ([ip fi man get [/ip fi man find comm=adsl1] disabled]=yes) do={/ip fi man en [/ip fi man find comm=adsl1]}
:if ([ip fi man get [/ip fi man find comm=adsl2] disabled]=yes) do={/ip fi man en [/ip fi man find comm=adsl2]}
:if ([ip fi man get [/ip fi man find comm=adsl3] disabled]=yes) do={/ip fi man en [/ip fi man find comm=adsl3]}
:if ([ip fi man get [/ip fi man find comm=adsl4] disabled]=yes) do={/ip fi man en [/ip fi man find comm=adsl4]}
:if ([ip fi man get [/ip fi man find comm=adsl1 action=mark-connection] nth]!=3,4,0) do={/ip fi man set [/ip fi man find comm=adsl1 action=mark-connection] nth=3,4,0}
:if ([ip fi man get [/ip fi man find comm=adsl2 action=mark-connection] nth]!=3,4,1) do={/ip fi man set [/ip fi man find comm=adsl2 action=mark-connection] nth=3,4,1}
:if ([ip fi man get [/ip fi man find comm=adsl3 action=mark-connection] nth]!=3,4,2) do={/ip fi man set [/ip fi man find comm=adsl3 action=mark-connection] nth=3,4,2}
:if ([ip fi man get [/ip fi man find comm=adsl4 action=mark-connection] nth]!=3,4,3) do={/ip fi man set [/ip fi man find comm=adsl4 action=mark-connection] nth=3,4,3}
}


脚本可能有冗余,但是运行半个月表现良好。

[ 本帖最后由 171594765 于 2008-8-13 14:44 编辑 ]
routeros
回复

使用道具 举报

发表于 2008-8-13 14:46:46 | 显示全部楼层
路由表的调整就不贴出来了,呵呵~~
routeros
回复

使用道具 举报

 楼主| 发表于 2008-8-13 23:02:02 | 显示全部楼层
不错,略看一下能够根据正常的线路来调整均衡,有空拷来试试。
routeros
回复

使用道具 举报

发表于 2008-8-19 02:44:03 | 显示全部楼层
:if([/interface get pppoe-out1 run]) do={
在这里写ADSL运行时要执行的脚本
} else={
在这里写ADSL断开时要执行的脚本
}
pppoe-out1是ADSL的接口名


用这个就解决了
routeros
回复

使用道具 举报

发表于 2008-8-19 06:20:56 | 显示全部楼层
NTH是什么意思?
routeros
回复

使用道具 举报

 楼主| 发表于 2008-8-20 04:52:32 | 显示全部楼层
原帖由 ee007 于 2008-8-19 02:44 发表
:if([/interface get pppoe-out1 run]) do={
在这里写ADSL运行时要执行的脚本
} else={
在这里写ADSL断开时要执行的脚本
}
pppoe-out1是ADSL的接口名


用这个就解决了

多线路就没这么简单了。比如原来A状态,是1.2.3.4线正常的,工作在NTH下;现在3出问题,要把1.2.4改为NTH工作,3恢复后返回A状态等等。
routeros
回复

使用道具 举报

发表于 2008-8-20 12:07:15 | 显示全部楼层
/ip fir man 启停里面的规则就是!
routeros
回复

使用道具 举报

发表于 2008-8-20 12:50:31 | 显示全部楼层
我的ADSL很稳定,不需要这东西.呵呵.
routeros
回复

使用道具 举报

发表于 2008-8-20 12:51:45 | 显示全部楼层
我的ADSL很稳定,不需要这东西.呵呵.
routeros
回复

使用道具 举报

发表于 2008-8-20 12:51:57 | 显示全部楼层

我的ADSL很稳定,不需要这东西.呵呵.

我的ADSL很稳定,不需要这东西.呵呵.
routeros
回复

使用道具 举报

发表于 2008-8-22 11:37:20 | 显示全部楼层

回复 5# 的帖子

我不熟悉ROS的脚本,不过看程序流程这个脚本好像还是有问题的,他假设的掉线似乎是comm=ADSL4-ADSL1递减按顺序掉线,这在实际运行中似乎是不太可能的。
routeros
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|小黑屋|软路由 ( 渝ICP备15001194号-1|渝公网安备 50011602500124号 )

GMT+8, 2024-5-18 10:59 , Processed in 0.062171 second(s), 4 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表