简体   繁体   中英

Thinking Sphinx - Errors out when i try to reindex?

Ok so i have a rails application on our server and I have thinking shinx installed. Every day at 12:30am I run a cron job that truncates the account and contact tables and reinserts them...here is my crons

30 0 * * * /bin/bash -l -c 'cd /var/www/active && script/rails runner -e production '\''Account.db_insert'\$
34 0 * * * /bin/bash -l -c 'cd /var/www/active && RAILS_ENV=production bundle exec rake ts:index --silent'
34 0 * * * /bin/bash -l -c 'cd /var/www/active && RAILS_ENV=production bundle exec rake ts:restart --silent'

As you can see the crons executes the Account.db_insert which reinserts contacts and accounts but everyday I get an email with an error....here are the two that i got recently....

Yesterdays Error

using config file '/var/www/active/config/production.sphinx.conf'...
indexing index 'contact_core'...
FATAL: failed to lock /var/www/active/db/sphinx/production/contact_core.spl: Resource temporarily unavailable, will not index. Try --rotate option.

Todays Error

using config file '/var/www/active/config/production.sphinx.conf'...
indexing index 'contact_core'...
collected 403 docs, 0.0 MB
sorted 0.1 Mhits, 100.0% done
ERROR: index 'contact_core': rename /var/www/active/db/sphinx/production/contact_core.tmp.spl to /var/www/active/db/sphinx/production/contact_core.new.spl failed: No such file or directory.
total 403 docs, 25092 bytes
total 0.069 sec, 361571 bytes/sec, 5807.16 docs/sec
distributed index 'contact' can not be directly indexed; skipping.
total 5 reads, 0.001 sec, 133.7 kb/call avg, 0.2 msec/call avg
total 10 writes, 0.012 sec, 177.8 kb/call avg, 1.2 msec/call avg

Any Idea what I am doing wrong....

UPDATE

After the suggestion to run

 /usr/local/bin/indexer --config /etc/sphinxsearch/sphinx.conf --all --rotate

I got this error

 using config file '/etc/sphinxsearch/sphinx.conf'...
 ERROR: unknown key name 'client_timeout' in /etc/sphinxsearch/sphinx.conf line 591 col 16.
 FATAL: failed to parse config file '/etc/sphinxsearch/sphinx.conf'.

As the error message indicates, you might want to run the indexer with the --rotate switch.

I, too, use Thinking Sphinx but found it easier to just use the Sphinx indexer directly. I have Thinking Sphinx generate my config for me, then I can just call out to searchd and indexer directly, in my cron:

*/30 * * * * /usr/local/bin/indexer --config /etc/sphinxsearch/sphinx.conf --all --rotate

I have foundthis to be more helpful than going through the Rake tasks. In addition, its much faster as the whole Rails stack doesnt have to be loaded.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM