无法使用phpcassa连接到localhost:9160

时间:2011-12-01 12:19:48

标签: cassandra phpcassa

我有这样的问题:当负载增加到每秒脚本200次查询时,phpcassa会导致此类异常

Error connecting to localhost:9160: TException: TSocket: Could not connect to localhost:9160 (Cannot assign requested address [99])
Error connecting to localhost:9160: TException: TSocket: Could not connect to localhost:9160 (Cannot assign requested address [99])
PHP Fatal error:  Uncaught exception 'NoServerAvailable' with message 'An attempt was made to connect to every server twice, but all attempts failed. The last error was: TException:TSocket: Could not connect to localhost:9160 (Cannot assign requested address [99])' in /var/www/megaumnik/context/connection.php:232
Stack trace:
#0 /var/www/megaumnik/context/connection.php(257): ConnectionPool->make_conn()
#1 /var/www/megaumnik/context/connection.php(351): ConnectionPool->get()
#2 /var/www/megaumnik/context/connection.php(286): ConnectionPool->call('describe_keyspa...', 'thegame')
#3 /var/www/megaumnik/context/columnfamily.php(194): ConnectionPool->describe_keyspace()
#4 /var/www/megaumnik/data/getData.class.php(265): ColumnFamily->__construct(Object(ConnectionPool), 'username')
#5 /var/www/megaumnik/data/test.php(6): getData->getDataByKey('username', '317')
#6 {main}
  thrown in /var/www/megaumnik/context/connection.php on line 232

脚本有来自不同列族的4 $ cf-> get()。每个列族有1000行

1 个答案:

答案 0 :(得分:1)

听起来好像你正在达到打开文件限制。您可以通过'ulimit -a'查看当前限制。

要增加限制,您可以通过以下两种方式之一设置新限制。首先,您可以执行类似'ulimit -n 10000'的操作,这是临时的,并且只会影响该shell启动的进程。要永久增加限制,您需要在/etc/security/limits.conf中添加一行,如下所示:

*               -       nofile      10000

为了使此生效,我相信您需要再次登录。