Sphinx可以从linux控制台运行,但不能从phpapi运行


Sphinx runs OK from linux console but not from php api

我的sphinx在linux控制台上运行正常

This program (CLI search) is for testing and debugging purposes only;
it is NOT intended for production use.
[root@coinsaver sphinx]# search -i product -q iphone
Sphinx 2.1.8-id64-release (rel21-r4675)
Copyright (c) 2001-2014, Andrew Aksyonoff
Copyright (c) 2008-2014, Sphinx Technologies Inc (http://sphinxsearch.com)
using config file '/etc/sphinx/sphinx.conf'...
index 'product': query 'iphone ': returned 88 matches of 88 total in 0.014 sec
displaying matches:
1. document=205267, weight=2773
2. document=470963, weight=2696
3. document=432191, weight=1696
4. document=125460, weight=1642
5. document=186938, weight=1642
6. document=199461, weight=1642
7. document=222081, weight=1642
8. document=249572, weight=1642
9. document=310231, weight=1642
10. document=395051, weight=1642
11. document=395052, weight=1642
12. document=430649, weight=1642
13. document=438066, weight=1642
14. document=468067, weight=1642
15. document=470947, weight=1642
16. document=470961, weight=1642
17. document=471161, weight=1642
18. document=482581, weight=1642
19. document=484640, weight=1642
20. document=490590, weight=1642
words:
1. 'iphon': 88 documents, 97 hits

但在重新启动后,它不能从PHP API 工作

$sphinx = new SphinxClient();
// options....
$result = $sphinx->Query("$string*", '*');

它返回false。在我重新启动服务器之前,它就起了作用,看起来Nginx和Sphinx不再相处了,我甚至不知道从哪里开始寻找。。。。

的结果searchd --status

searchd status
--------------
uptime: 361
connections: 1
maxed_out: 0
command_search: 0
command_excerpt: 0
command_update: 0
command_keywords: 0
command_persist: 0
command_status: 1
command_flushattrs: 0
agent_connect: 0
agent_retry: 0
queries: 0
dist_queries: 0
query_wall: 0.000
query_cpu: OFF
dist_wall: 0.000
dist_local: 0.000
dist_wait: 0.000
query_reads: OFF
query_readkb: OFF
query_readtime: OFF
avg_query_wall: 0.000
avg_query_cpu: OFF
avg_dist_wall: 0.000
avg_dist_local: 0.000
avg_dist_wait: 0.000
avg_query_reads: OFF
avg_query_readkb: OFF
avg_query_readtime: OFF

此外,自重新启动以来,sphinx查询日志中没有任何条目。

AHA!重新启动后,我的服务器决定将Sphinx的端口从9312更改为3312

我运行这个命令是为了查看开放端口(CENTOS)$ netstat -tulpn | less

tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      4928/php-fpm
tcp        0      0 127.0.0.1:27017             0.0.0.0:*                   LISTEN      1166/mongod
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      4645/mysqld
tcp        0      0 0.0.0.0:3690                0.0.0.0:*                   LISTEN      1565/svnserve
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      3428/nginx
-----------------------------------------------------------------------------------------
tcp        0      0 127.0.0.1:3312              0.0.0.0:*                   LISTEN      3278/searchd
-----------------------------------------------------------------------------------------
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      529/sshd
tcp        0      0 :::22                       :::*                        LISTEN      529/sshd

所以通过改变这个

$sphinx->SetServer('localhost', 9312);

到这个

$sphinx->SetServer('localhost', 3312);

我的噩梦结束了。因此,即使您有充分的理由重新启动生产服务器,也应该三思而后行,特别是如果您不是linux专家的话。

相关文章: