免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5087 | 回复: 5
打印 上一主题 下一主题

如何在Piranha环境下做Socket应用服务的负载 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-04-17 11:28 |只看该作者 |倒序浏览
感觉lvs是可以为socket做均衡负载的,只要调整一下monitor script脚本


可是最近一直没能做成功。

我做了个shell脚本如下

#!/bin/sh

if nc $1 1111 -w 3 -z;then
    echo "OK"
else
    echo "FAIL"
fi

可以检测1111端口

然后把monitor script上改为
Sending Program ="/opt/test.sh %h"
Send 不需要
Expact="OK"

realserver一直没有被检测到,不知道我这样做对不对,错在哪里。请做过的有经验的朋友指点指点。

补充一下错误日志

Apr 17 03:26:44 localhost nanny[11343]: READ from xxx.xxx.xxx.xxx:1111 was too short
Apr 17 03:26:44 localhost nanny[11274]: READ from xxx.xxx.xxx.xxx:1111 was too short
Apr 17 03:26:45 localhost nanny[11276]: READ from xxx.xxx.xxx.xxx:1111 was too short
Apr 17 03:26:45 localhost nanny[11345]: READ from xxx.xxx.xxx.xxx:1111 was too short
Apr 17 03:26:45 localhost nanny[16487]: Trouble. Received results are not what we expected from (xxx.xxx.xxx.xxx:1111)
Apr 17 03:26:45 localhost nanny[16485]: Trouble. Received results are not what we expected from (xxx.xxx.xxx.xxx:1111)
Apr 17 03:26:46 localhost nanny[12934]: Trouble. Received results are not what we expected from (xxx.xxx.xxx.xxx:1111)
Apr 17 03:26:46 localhost nanny[12936]: Trouble. Received results are not what we expected from (xxx.xxx.xxx.xxx:1111)
Apr 17 03:26:47 localhost nanny[15045]: Trouble. Received results are not what we expected from (xxx.xxx.xxx.xxx:1111)
Apr 17 03:26:47 localhost nanny[15047]: Trouble. Received results are not what we expected from (xxx.xxx.xxx.xxx:1111)

论坛徽章:
0
2 [报告]
发表于 2010-04-18 06:20 |只看该作者
本帖最后由 johnyo 于 2010-04-18 06:38 编辑

日志显示是expect值不对。你把手动运行命令的结构放上来,然后把配置文件放上来看看?

论坛徽章:
0
3 [报告]
发表于 2010-04-19 11:01 |只看该作者
本帖最后由 cnhome_2008 于 2010-04-19 11:09 编辑

我直接用的这个脚本


#!/bin/sh

if nc $1 1111 -w 3 -z;then
    echo "OK"
else
    echo "FAIL"
fi

send program里边

检测对端1111端口是否存在


当然也可以用telnet,登陆

[root@localhost ~]# telnet xxx.xxx.xxx.xxx 1111
Trying xxx.xxx.xxx.xxx...
Connected to xxx.xxx.xxx.xxx(xxx.xxx.xxx.xxx).
Escape character is '^]'.
+ Input login password please:

如果输入内容回车则显示一下提示:

+ Authentication succeeded! Input monitoring command:

用telnet那种方式的我一直没有配通,所以采用了第一种检测端口的脚本

论坛徽章:
0
4 [报告]
发表于 2010-04-19 11:31 |只看该作者
[root@localhost opt]# ./test.sh xxx.xxx.xxx.xxx
Connection to xxx.xxx.xxx.xxx 1111 port [tcp/lmsocialserver] succeeded!
OK

这个是shell脚本的测试

论坛徽章:
0
5 [报告]
发表于 2010-04-19 11:45 |只看该作者
改了一下配置

Send Program 为空
Sending "\n"
Expect "*"

测试通过

论坛徽章:
0
6 [报告]
发表于 2010-04-21 14:21 |只看该作者
[root@localhost opt]# ./test.sh xxx.xxx.xxx.xxx
Connection to xxx.xxx.xxx.xxx 1111 port [tcp/lmsocialserver] succeeded!
OK

如果是这样,expect 应该就是Connection to xxx.xxx.xxx.xxx 1111 port [tcp/lmsocialserver] succeeded!
OK
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP