How gracefully restart Sphinx search daemon after reindexing
Asked Answered
J

4

16

I've reindexed my Sphinx search with /usr/local/sphinx/bin/indexer --all --rotate and renamed my original index output files to something else. Simply changing the index argument passed to $sphinx->Query($query, $index); returns no results.

I suspected the daemon doesn't know the new index files exist. So I ran

sudo /usr/local/sphinx/bin/searchd

again to try to restart it. But it threw

FATAL: failed to lock pid file '/usr/local/sphinx/var/log/searchd.pid': Resource temporarily unavailable (searchd already running?)

I had to kill the 2 processes of the search daemon and start it again to grab from the new index files. Is there a graceful way to restart it?

Jeffjeffcoat answered 26/10, 2011 at 12:23 Comment(0)
A
30

I know this is a late answer, but just so you know, to 'restart' Sphinx, you need to stop it then start it (as in, two distinct processes).

To stop it, call searchd --stop then just start it again with searchd.

Anti answered 30/11, 2011 at 12:34 Comment(3)
Imho /etc/init.d/sphinxsearch restart is betterIonogen
The command /etc/init.d/sphinxsearch restart appears to be distribution-specific.Candlenut
Building on @Anti answer, you can wrap up both calls in a shell scriptJehad
U
9

You'll need to call indexer on the new index to create it and then --rotate to update it.

So it would be something like

indexer --config /path/to/config.conf indexname

And then when you just want to update your indexes

indexer --config /path/to/config.conf --rotate --all

This will create a temporary copy of each index and replace the old ones when finished. For more info on what actually happens see http://sphinxsearch.com/docs/manual-0.9.9.html#ref-indexer

On the other error your getting Do

ps aux | grep searchd

if it returns no results, then remove /usr/local/sphinx/var/log/searchd.pid and start searchd again

Unbelief answered 27/10, 2011 at 16:2 Comment(0)
N
4

It seems there is an issue with the searchd --stop command failing to stop the daemon on some instances of Sphinx.

Try: service sphinxsearch stop

See: https://bugs.launchpad.net/ubuntu/+source/sphinxsearch/+bug/990395

Numbskull answered 14/11, 2012 at 22:44 Comment(1)
In my case I run into this because of having nonstandard pid file in /etc/sphinxsearch/sphinx.conf - which was different from /etc/init.d/sphinxsearch.Ionogen
M
0

service searchd start worked for me on CentOS

Meimeibers answered 23/5, 2017 at 23:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.