Home >Backend Development >PHP Tutorial >sphinx增量索引的一个问题_PHP

sphinx增量索引的一个问题_PHP

WBOY
WBOYOriginal
2016-06-01 12:15:35718browse

但最近发现增量的总是搜索不到,今天看了下运行日志,有如下提示:

[Sun Apr 17 19:30:01.876 2011] [ 3400] WARNING: rotating index 'news_delta': cur to old rename failed: rename /dev/shm/sphinx/data/news_delta.spa to /dev/shm/sphinx/data/news_delta.old.spa failed: No such file or directory

[Sun Apr 17 19:30:01.881 2011] [ 3400] WARNING: rotating index 'article_delta': cur to old rename failed: rename /dev/shm/sphinx/data/article_delta.spa to /dev/shm/sphinx/data/article_delta.old.spa failed: No such file or directory

为提高增量索引速度,我将增量索引存放在/dev/shm中,看了下/dev/shm/sphinx/data/目录下的内容:
-rw-r--r-- 1 root root 385762 Apr 17 19:21 article_delta.new.spd
-rw-r--r-- 1 root root 3713 Apr 17 19:21 article_delta.new.sph
-rw-r--r-- 1 root root 46260 Apr 17 19:21 article_delta.new.spi
-rw-r--r-- 1 root root 0 Apr 17 19:21 article_delta.new.spk
-rw-r--r-- 1 root root 0 Apr 17 19:21 article_delta.new.spm
-rw-r--r-- 1 root root 261402 Apr 17 19:21 article_delta.new.spp

奇怪,应该要有article_delta.spd等文件,不应该是.new的文件。
增量索引时是使用--rotate参数的,
复制代码 代码如下:
bin/indexer --rotate news_delta
bin/indexer --rotate article_delta

在rotate时,需要将原article_delta.spa重命名为article_delta.old.spa,然后将article_delta.new.spa重命名为article_delta.spa,再通知searchd重启完成rotate。

想起应该是前几天凌晨重启过机器,原文件都丢了,导致无法rotate:(

解决方法:
运行:bin/indexer article_delta
创建了article_delta.spd,sph等文件。

再运行:bin/indexer article_delta --rotate
运行日志提示:rotating index 'article_delta': success
正常了!

把要做增量索引的命令写了个脚本,放在rc.local中,这样重启过机器就不会再出现这种问题了。
复制代码 代码如下:
echo "start:" $(date +"%y-%m-%d %H:%M:%S")
cd /usr/local/coreseek/bin
./indexer news_delta
./indexer article_delta
echo "end:" $(date +"%y-%m-%d %H:%M:%S")

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn