思考狮身人面像 - 当我尝试重新索引时出错?

时间:2011-10-27 13:21:32

标签: ruby-on-rails ruby-on-rails-3 crontab thinking-sphinx

好的,我的服务器上有一个rails应用程序,我安装了thinking shinx。每天早上12:30我都会运行一个cron作业,截断帐户和联系表并重新插入它们......这是我的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'

正如你所看到的那些crons执行重新插入联系人和帐户的Account.db_insert,但每天我收到一封错误的电子邮件....这是我最近得到的两个......

昨天错误

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.

今日错误

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

任何想法我做错了什么......

更新

建议运行后

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

我收到了这个错误

 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'.

1 个答案:

答案 0 :(得分:4)

如错误消息所示,您可能希望使用--rotate开关运行索引器。

我也使用Thinking Sphinx,但发现直接使用Sphinx索引器更容易。我有思考Sphinx为我生成我的配置,然后我可以直接呼叫searchdindexer,在我的cron中:

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

我发现这比通过Rake任务更有帮助。另外,它的速度要快得多,因为不需要加载整个Rails堆栈。