【问题标题】:Sphinx Search Cron Issue狮身人面像搜索 Cron 问题
【发布时间】:2013-05-22 01:46:32
【问题描述】:

我正在尝试将 Sphinx main + delta 系统与 Sphinx 一起使用。除了 Cron 工作不断从日志中说 WARNING: no such index 'listings_delta_index', skipping 之外,我得到了一切工作。当我手动运行命令时,它工作得很好。我正在运行的命令和我正在使用的 sphinx.conf 如下。我还尝试将索引名称更改为 listings_index ,但这也不起作用。

Sphinx.conf

source listings_source
{
    type            = mysql
    sql_host        = localhost
    sql_user        = user2
    sql_pass        = password
    sql_db          = MyVirtuals
    sql_port        = 3306  # optional, default is 3306
    sql_query_pre   = SET NAMES utf8
    sql_query_pre   = REPLACE INTO sph_counter SELECT 1, MAX(listing_id) FROM     listings
    sql_query_pre   = REPLACE INTO sph_last_index SELECT 1, NOW()
    sql_query       = \
    SELECT listing_id, title,CRC32(mainCategoryID) as mainCategoryID,CAST(price AS DECIMAL(12,2)) as price, UNIX_TIMESTAMP(date_created) AS date_created, description \
    FROM listings WHERE listing_id<=(SELECT max_doc_id FROM sph_counter WHERE counter_id=1) AND status = 1
    sql_query_killlist  = SELECT listing_id FROM listings WHERE modified_on >= (SELECT last_reindex_on FROM sph_last_index WHERE counter_id=1)

    sql_attr_timestamp  = date_created
    sql_attr_uint   = mainCategoryID
    sql_attr_float  = price

    #sql_query_info = SELECT * FROM documents WHERE id=$id
}
index listings_index
{
    source      = listings_source
    path        = /usr/local/sphinx/var/data/listings_index
    docinfo     = extern
    charset_type    = sbcs
    min_word_len    = 1
    html_strip      = 1
}
source listings_delta_source : listings_source{
    sql_query_pre       = SET NAMES utf8
    #Pull listings that are new and changed
    sql_query       = SELECT listing_id, title, CRC32(mainCategoryID) as mainCategoryID, CAST(price AS DECIMAL(12,2)) as price, UNIX_TIMESTAMP(date_created) AS date_created, description \
    FROM listings WHERE listing_id>(SELECT max_doc_id FROM sph_counter WHERE counter_id=1) OR modified_on >= (SELECT last_reindex_on FROM sph_last_index WHERE counter_id=1)
}
index listings_delta_index : listings_index{

        source      = listings_delta_source
        path        = /usr/local/sphinx/var/data/listings_delta_index
        docinfo     = extern
        charset_type    = sbcs
        min_word_len    = 1
        html_strip      = 1
}
indexer
{
    mem_limit       = 32M
}
searchd
{
    listen      = 9312
    listen      = 9306:mysql41
    log         = /var/log/sphinxsearch/searchd.log
    query_log       = /var/log/sphinxsearch/query.log
    read_timeout    = 5
    max_children    = 30
    pid_file        = /var/log/sphinxsearch/searchd.pid
    max_matches     = 1000
    seamless_rotate = 1
    preopen_indexes = 1
    unlink_old      = 1
    workers     = threads # for RT to work
    binlog_path     = /usr/local/sphinx/var/data
}

sphinx_update_delta.sh

indexer -c /var/www/scripts-conf/sphinx.conf --rotate listings_delta_index

crontab

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report     /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
*/1 *    * * *   root    sh /var/www/scripts-conf/sphinx_update_delta.sh > /var/log/cronlog.log
*  0    * * *   root    sh /var/www/scripts-conf/sphinx_update_main.sh

谁能帮我解决这个问题?

【问题讨论】:

  • 你是如何从命令行运行它的?通过执行shell脚本还是手动?您使用的是完全相同的配置吗?
  • 我正在运行 crontab 中的 .sh 文件。我将编辑我的帖子以包含 crontab 文件。
  • 但是我问你手动测试时使用的是完全相同的命令吗?
  • 我手动运行它而不是脚本文件本身。这会导致权限问题吗?
  • 尝试在 .sh 文件的命令行中添加 --verbose。这将有望向您显示其实际使用的配置文件的路径。和你期待的一样吗?

标签: php mysql apache cron sphinx


【解决方案1】:

indexer -c /var/www/scripts-conf/sphinx.conf --rotate listings_delta_index

sphinx.conf 是小写的

在您的第一个块中,您将标题写为 Sphinx.conf(不是 sphinx.conf)


提示

sh /var/www/scripts-conf/sphinx_update_delta.sh > /var/log/cronlog.log

>替换为|三通

sh /var/www/scripts-conf/sphinx_update_delta.sh | tee /var/log/cronlog.log

手动运行查看结果

【讨论】: