- 论坛徽章:
- 0
|
这几天在部署sphinx,但是遇到了意外的问题,希望有类似经验的给点提示~
基本状况:
1.A主机:www服务器(apache),B主机:数据服务器(mysql+sphinx);
2.mysql的数据连接,以及取sphinx相关索引都能连接成功;
3.当A主机上面的页面连接请求B主机上面的sphinx的索引数据的时候,出错率在20%左右(我用有无返回数据来判断,详细见代码)。
为了说明是不是数据源的问题(mysql+sphinx),我还在c主机上放了同样的代码,获取数据无错误。
4.考虑到数据获取端口因素, 我在A主机上做了一个简单测试:让A主机的一个页面通过url去读取B主机上面的一个页面,看返回值的情况。这个测试同样也出错,错误率也在20%左右。
期间我曾怀疑过服务器的处理能力,导致处理数据超时,然后数据包被扔掉等等。但是cpu的使用率是很低的,内存使用率在90%左右(为了减少磁盘IO),服务器A的下行流量也只有2.4Mb/s。
没有数据能直接说明是内存和下行流量的原因,看起来似乎是这两个主机的网络连接有问题,但是很快就被下面的测试否定了
5.刚才还做了一个A主机取B主机mysql数据的测试,这个没任何问题。同时A ping B,B ping A 都没loss
到目前为止没找到原因,感觉要失去方向了,请大家帮帮忙~给点启发什么的
如果我没说清楚的或者不专业的地方请见谅,今天一直在线。
<?php
//A主机上请求B主机sphinx索引数据测试代码
error_reporting(E_ALL);
ini_set("display_errors",1);
include_once("inc/sphinxapi.php");
$cl = new SphinxClient ();
$cl->SetServer('B-host',3312);
$cl->SetMatchMode(SPH_MATCH_ALL);
$cl->SetLimits(0,50);
$res = $cl->Query ( "Getting Bigger and Better", "main" );
if(is_array($res)){
$out="OK";
}else{
$out="Error";
}
$handle = fopen('_manage_/orders/sphinx_log.html','a');
$now = date("h:i:s");
fwrite($handle,"<br><br>".$now."---------------------".$out);
fclose($handle);
echo '<html><head><meta http-equiv="refresh" content="10;URL=/test.php></head></html>';
?> |
<?php
//A主机上通过url读取B主机一个页面的测试代码
error_reporting(E_ALL);
ini_set("display_errors",1);
$a = file_get_contents("http://www.****.com/test/postinfo.html");
if(strpos($a,"The HTML comments in this page contain the configurationinformation")){
$out="OK";
}else{
$out="Error";
}
$handle = fopen('_manage_/orders/13112_log.html','a');
$now = date("h:i:s");
fwrite($handle,"<br><br>".$now."---------------------".$out);
fclose($handle);
echo '<html><head><meta http-equiv="refresh" content="5;URL=test44.php></head></html>';
?> |
<?php
//放在A主机上的请求B主机mysql数据的测试代码
error_reporting(E_ALL);
ini_set("display_errors",1);
$db_user="";
$db_pass="";
$db_name="";
$db_host="";
mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db($db_name);
$query = "SELECT * FROM table limit 10";
$result = mysql_query($query);
while($array=mysql_fetch_array($result)){
$out_array[]=$array;
}
if(count($out_array)>5){
$out="OK";
}else{
$out="Error";
}
$handle = fopen('_manage_/orders/db_log.html','a');
$now = date("h:i:s");
fwrite($handle,"<br><br>".$now."---------------------".$out);
fclose($handle);
echo '<html><head><meta http-equiv="refresh" content="5;URL=test77.php></head></html>';
?> |
[ 本帖最后由 alexyandy_unix 于 2009-5-15 11:04 编辑 ] |
|