sphinx有两大关键工具,一个是indexer索引,另一个就是搜索服务searchd。通常searchd就是作为一个服务指定配置文件启动,但实际searchd还有其它一些有意思的选项,比如:本文地址:http://www.04007.cn/article/590.html,未经许可,不得转载.
--stop选项停止searchd服务,send SIGTERM to currently running searchd
--stopwait 也是停止服务,在停止时能更好的保存信息,文档:send SIGTERM and wait until actual exit
--status 选项查看sphinx的运行状态:包括运行时间,连接数等详细数据。
--console 用来强制searchd以控制台模式启动,方便调试
--iostats 当使用日志时(sphinx.conf启用query_log选项)启用--iostats会对每条查询输出关于查询过程中发生的输入输出操作的详细信息。
--cpustats 使实际CPU时间报告(不光是实际度量时间(wall time))出现在查询日志文件(每条查询输出一次)和状态报告(累加之后)中。
--console 用来强制searchd以控制台模式启动本文地址:http://www.04007.cn/article/590.html,未经许可,不得转载.
在停止sphinx服务的时候,通过可能是直接强硬地KILL掉进程,虽然一般也不出意外,但最好是能使用searchd自带的停止命令,--stop和--stopwait选项。推荐使用--stopwait时,不过我在使用--stopwait时发现执行后searchd并不是立即就停止服务,查看仍然有searchd进程,但是已经不再监控原来的端口。而此时searchd也不能启动新的进程,grep searchd还会发现有一些addr2line命令在执行,像是出了什么错误。不确定是--stopwait导致的还是什么问题。启动后使用--status查看sphinx的状态信息。本文地址:http://www.04007.cn/article/590.html,未经许可,不得转载.
#使用--stop选项停止searchd服务 [dev@SERVER coreseek]$ sudo bin/searchd -c etc/market.conf Coreseek Fulltext 4.1 [ Sphinx 2.0.2-dev (r2922)] Copyright (c) 2007-2011, Beijing Choice Software Technologies Inc (http://www.coreseek.com) using config file 'etc/market.conf'... listening on all interfaces, port=9314 precaching index 'market' rotating index 'market': success precached 1 indexes in 0.295 sec [dev@SERVER coreseek]$ ps -ef | grep searchd root 25109 1 0 15:50 ? 00:00:00 bin/searchd -c etc/market.conf root 25110 25109 7 15:50 ? 00:00:00 bin/searchd -c etc/market.conf 30548 25115 21570 0 15:50 pts/1 00:00:00 grep searchd #使用--status查看统计信息 [dev@SERVER sphinx]$ sudo bin/searchd --config etc/market.conf --status Sphinx 2.1.7-release (rel21-r4638) Copyright (c) 2001-2014, Andrew Aksyonoff Copyright (c) 2008-2014, Sphinx Technologies Inc (http://sphinxsearch.com) using config file 'etc/market.conf'... searchd status -------------- uptime: 254 connections: 6 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 [dev@SERVER coreseek]$ sudo bin/searchd -c etc/market.conf --stop Coreseek Fulltext 4.1 [ Sphinx 2.0.2-dev (r2922)] Copyright (c) 2007-2011, Beijing Choice Software Technologies Inc (http://www.coreseek.com) using config file 'etc/market.conf'... stop: successfully sent SIGTERM to pid 25110 [dev@SERVER coreseek]$ ps -ef | grep search 30548 25121 21570 0 15:51 pts/1 00:00:00 grep search [dev@SERVER coreseek]$ #再次启动后执行--stopwait选项,两个命令在输出是一样的。 [dev@SERVER coreseek]$ sudo bin/searchd -c etc/market.conf --stopwait Coreseek Fulltext 4.1 [ Sphinx 2.0.2-dev (r2922)] Copyright (c) 2007-2011, Beijing Choice Software Technologies Inc (http://www.coreseek.com) using config file 'etc/market.conf'... stop: successfully sent SIGTERM to pid 25125 #addr2line 不知道是什么情况 [dev@SERVER coreseek]$ps -ef | grep searchd root 25140 1 0 15:52 ? 00:00:00 bin/searchd --config etc/market.conf root 25828 25140 0 15:55 ? 00:00:00 bin/searchd --config etc/market.conf root 25829 25828 17 15:55 ? 00:00:00 addr2line -e bin/searchd 0x6545b0 0x490f63 0x6e60eca0 0x6de7b89e 0x517e56 0x52ed97 0x52f32e 0x53a40a 0x5801bf 0x55e636 0x48f5c7 0x4ca5e4 0x4f4587 0x4f6325 0x6de1d9c4 0x48dc69 30548 25831 21570 0 15:55 pts/1 00:00:00 grep searchd #searchd进程服务仍然在执行,但是已经不再监控原来的端口: [dev@SERVER coreseek]$ sudo bin/searchd --config etc/market.conf --status Coreseek Fulltext 4.1 [ Sphinx 2.0.2-dev (r2922)] Copyright (c) 2007-2011, Beijing Choice Software Technologies Inc (http://www.coreseek.com) using config file 'etc/market.conf'... WARNING: failed to connect to 0.0.0.0:9314: Connection refusedsearchd搜索服务启动时还可以带上--iostats --cpustats选项,分别指示打开io和cpu统计并记录日志。但只会记录通过searchd监听的端口发来的请求才会进行记录,而通过如下使用search命令进行直接查询的方式则不会进行记录:本文地址:http://www.04007.cn/article/590.html,未经许可,不得转载.
[dev@SERVER coreseek]$ bin/search -c etc/market.conf 中国人力资源网 Coreseek Fulltext 4.1 [ Sphinx 2.0.2-dev (r2922)] Copyright (c) 2007-2011, Beijing Choice Software Technologies Inc (http://www.coreseek.com) using config file 'etc/market.conf'... index 'market': query '中国人力资源网 ': returned 4 matches of 4 total in 0.004 sec displaying matches: 1. document=64443, weight=7574, downloads=2, installs=131, boutique=0, boutique_pc=0, title=中国人力资源网, py=_ z h o n g g u o r e n l i z i y u a n w a n g, ipy=_ z g r l z y w, style=2 2. document=156022, weight=7574, downloads=0, installs=15247, boutique=0, boutique_pc=0, title=中国人力资源网, py=_ z h o n g g u o r e n l i z i y u a n w a n g, ipy=_ z g r l z y w, style=14 3. document=178156, weight=7574, downloads=2, installs=12, boutique=0, boutique_pc=0, title=中国人力资源网, py=_ z h o n g g u o r e n l i z i y u a n w a n g, ipy=_ z g r l z y w, style=7 4. document=303947, weight=7574, downloads=0, installs=0, boutique=0, boutique_pc=0, title=中国人力资源网, py=_ z h o n g g u o r e n l i z i y u a n w a n g, ipy=_ z g r l z y w, style=25 words: 1. '中': 20817 documents, 20996 hits 2. '国': 23230 documents, 23532 hits 3. '人': 26755 documents, 27327 hits 4. '力': 6998 documents, 7031 hits 5. '资': 2688 documents, 2708 hits 6. '源': 1625 documents, 1626 hits 7. '网': 19727 documents, 19821 hits #以上的请求并不会记录到日志中,而通过端口发过来的请求,可以看一下开启--iostats --cpustats选项和不开启的记录差别。 #开启--iostats --cpustats ==> query.log <== [Fri Mar 15 16:35:56.788 2019] 0.007 sec [all/0/rel 11 (0,20)] [market] [ios=5 kb=342.1 ioms=0.4 cpums=4.8] 中国人力 [Fri Mar 15 16:39:46.330 2019] 0.004 sec [all/0/rel 1 (0,20)] [market] [ios=8 kb=378.3 ioms=0.3 cpums=4.4] 中国人力资源平台 #不开启--iostats --cpustats ==> query.log <== [Fri Mar 15 16:40:21.512 2019] 0.005 sec [all/0/rel 1 (0,20)] [market] 中国人力资源平台 [Fri Mar 15 16:42:25.464 2019] 0.004 sec [all/0/rel 1 (0,20)] [market] 中国人力资源平台 #另外开启--console选项会直接将query的日志显示在控制台 [dev@SERVER coreseek]$ sudo bin/searchd --config etc/market.conf --console Coreseek Fulltext 4.1 [ Sphinx 2.0.2-dev (r2922)] ...... accepting connections [Fri Mar 15 16:42:32.493 2019] 0.004 sec [all/0/rel 1 (0,20)] [market] 中国人力资源平台searchd其它一些选项:
-p, --port <port> listen on given port (overrides config setting)
-l, --listen <spec> listen on given address, port or path (overrides config settings)
指定searchd监听的端口,用于调试。
-i, --index <index> only serve one given index
强制searchd只提供针对指定索引的搜索服务。用于调试。
--logdebug enable additional debug information logging
显示一些附加的调试信息,我到是试过加了,不过没发现其它调试信息
--nodetach do not detach into background本文地址:http://www.04007.cn/article/590.html,未经许可,不得转载.
本文地址:http://www.04007.cn/article/590.html 未经许可,不得转载. 手机访问本页请扫描右下方二维码.
![]() |
![]() |
手机扫码直接打开本页面 |