php - Sphinx 搜索 Cron 问题

标签 php mysql apache cron sphinx

我正在尝试将 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

定时任务

# /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

谁能帮我解决这个问题?

最佳答案

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

sphinx.conf 是小写的

在您的第一个 block 中,您将标题写为 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

查看手动运行的结果

关于php - Sphinx 搜索 Cron 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15582638/

相关文章:

php - 将 MySQLi 与 PDO 一起使用?

mysql - mysql IF条件中的多个表达式

php - PHP循环内的Mysql查询

php - Laravel Ajax 调用 Controller 中的函数

php - JavaScript 重新加载,而 mysql 结果

mysql - 如何删除和更改 mysql 事件调度程序?

linux - 使用 cut 将 cat 限制为值 1 或以上 我不这样做

linux - 自动安装 Apache Ant

php - 如何为我的 Apache2 根目录中的所有文件设置根访问权限?

php - 无法创建文件夹 Zipper/laravel