sphinx無(wú)法啟動(dòng)的解決
索引或者查詢時(shí)提示:ERROR: invalid token in 配置文件 line 1 col 1.:
該提示表示當(dāng)前的配置文件的編碼不是UTF-8(無(wú)BOM頭)格式,無(wú)法正確解析,請(qǐng)使用編輯軟件打開配置文件,另存為UTF-8(無(wú)BOM頭)格式;
錯(cuò)誤的編碼格式包括:Unicode、Unicode BOM、Unicode big endian、Unicode 低位在前、UTF-8 + BOM、UTF-8 Signature、UTF-8 包含簽名等;
特別注意:Windows自帶的記事本(Notepad)或者寫字板(WordPad)無(wú)法正確保存為所需格式,請(qǐng)勿使用其編輯配置文件;
在sphinx中處理使用特殊字符時(shí)所引起錯(cuò)誤的辦法
用sphinx搜索引擎時(shí),有時(shí)會(huì)遇到一些特殊字符,這些特殊字符可能會(huì)是sphinx致命性錯(cuò)誤來(lái)源:
如 “$”、“^”,在sphinx搜索關(guān)鍵字的最前或最尾出現(xiàn)這樣的字符時(shí)(單獨(dú)使用也一樣),就會(huì)導(dǎo)致sphinx致命的錯(cuò)誤。例如用“$筆記本”或“筆記本^”作為關(guān)鍵字搜索時(shí),就會(huì)引起類似Query failed: index product: syntax error, unexpected "。
在搜索關(guān)鍵字的前面和后面自動(dòng)加上半角的空格符“ ”可以解決此問(wèn)題,且不會(huì)影響搜索結(jié)果。
ERROR: index ‘product’: raw_hits: write error: 122070 of 262017 bytes written
A:此類問(wèn)題是索引寫入磁盤錯(cuò)誤導(dǎo)致,有多個(gè)原因。注意查看磁盤空間是否已滿。另外,還可能是因?yàn)槭欠裼卸鄠€(gè)indexer進(jìn)程在進(jìn)行,寫入索引失敗!還有個(gè)解決方法是:減少 indexer配置中 max_iosize的大小。max_iosize是sphinx最大允許的I/O操作大小,以字節(jié)為單位,用于I/O節(jié)流。比如可以設(shè)置為 524288(512KB)
1、增量索引,注意刪除的問(wèn)題 2、對(duì)大數(shù)據(jù),一定要給sphinx數(shù)據(jù)目錄留出大量空間,因?yàn)榕R時(shí)文件會(huì)占據(jù)非常大的空間
Q、編譯安裝時(shí)出現(xiàn)這個(gè)問(wèn)題….sphinx.cpp; then mv -f “.deps/sphinx.Tpo” “.deps/sphinx.Po”; else rm -f “.deps/sphinx.Tpo”; exit 1; fi In file included from sphinx.cpp:14:sphinx.h:54:19: error: mysql.h: No such file or directory….
A:缺少libmysqlclient15.so,安裝mysql-devel.如果已經(jīng)存在。請(qǐng)使用ldconfig加載一下這個(gè)動(dòng)態(tài)鏈接庫(kù)(linux)
Q: sphinx在rotate時(shí)出現(xiàn)以下問(wèn)題。(searchd.log) WARNING: rotating index ‘sphinx’: prealloc: mmap() failed: Cannot allocate memory (length=431854320); using old index,同時(shí),在索引數(shù)據(jù)目錄中會(huì)出現(xiàn)sphinx.spl sphinx.new.spl的情況,導(dǎo)致原來(lái)的索引不能正確的檢索到
sphinx indexer有2個(gè)進(jìn)程同時(shí)在運(yùn)行,sphinx 的indexer不能同時(shí)使用,導(dǎo)致無(wú)法分配內(nèi)存。并使indexer使用舊的索引文件
先了解一下sphinx的 –rotate機(jī)制:
indexer完成索引->發(fā)送SIGHUP 給searchd(同時(shí)在終端輸出索引已經(jīng)完成)->searchd接到中斷信號(hào)->等待所有子進(jìn)程退出->重命名 當(dāng)前索引為舊索引為 .old
->重命名 .new 索引文件作為當(dāng)前索引->嘗試加載當(dāng)前索引文件->如果加載失敗,searchd會(huì)把.old文件回滾為當(dāng)前文件,并把剛建立的新索引重命名 為 .new ->加載成的話:完成無(wú)縫銜接
執(zhí)行 rotate開關(guān)情況下,indexer在完成索引后會(huì)首先會(huì)發(fā)送一個(gè)中斷信號(hào)給searchd(并且會(huì)輸出已經(jīng)索引完成)。
接著 searchd會(huì)做以下事情:
1)等待所有子進(jìn)程退出
2)重命名 當(dāng)前索引為舊索引為 .old
3)重命名 .new 索引文件作為當(dāng)前索引
4)嘗試加載當(dāng)前索引文件
5)如果加載失敗,searchd會(huì)把.old文件回滾為當(dāng)前文件,并把剛建立的新索引重命名為 .new
鑒于以上情況,很可能是開啟了2個(gè)檢測(cè)目錄訪問(wèn)權(quán)限的進(jìn)程。用戶同時(shí)使用2個(gè)indexer且 searchd運(yùn)行其下 等等
sphinx的searchd在啟動(dòng)時(shí)會(huì)創(chuàng)建一個(gè) .spl 鎖文件,并在關(guān)閉時(shí)會(huì)刪除它。在indexer創(chuàng)建索引時(shí)如果發(fā)現(xiàn)有 .spl文件,則不會(huì)創(chuàng)建新索引,除非使用 –rotate
所以,出現(xiàn)這樣的問(wèn)題可能是 鎖文件不知咋的就丟失啦,或者重建索引時(shí)沒(méi)有使用 –rotate開關(guān)
原文:
http://www.sphinxsearch.com/forum/view.html?id=274
It seems that
a) the lock files were lost somehow, and
b) you ran indexer without –rotate switch.
Normally, searchd would create .spl lock files on startup (and kill them on shutdown),
and indexer would then refuse to reindex without –rotate switch.
indexers sends SIGHUP to searchd when completed (and it should print that out). searchd
then does the following:
1) waits for all children to exit
2) renames current index files to .old
3) renames .new index files to current
4) tries to load current index files
5) if something failed, it rollbacks current files from .old and new to .new
In your case I would start with double checking directory access rights, users which both
indexer and searchd run under, etc.
具體操作:
killall searchd 然后重啟。重啟后會(huì)自動(dòng)加載重命名 sphinx.new.sp*為 sphinx.sp*
另外,出現(xiàn)這樣的問(wèn)題時(shí),最好注意 –rotate的使用,在應(yīng)用許可 的情況下,不妨直接采用 關(guān)閉searchd 再索引,然后再開啟 searchd
Q:關(guān)于updateAttribute更新索引的問(wèn)題
sphinx使用api不能馬上真正的更新索引,但更新后api能顯示索引已經(jīng)是更新了。不過(guò)使用cli端的search就不能搜索到。只有在searchd重啟后才會(huì)寫入磁盤文件中。切記!
Q、sphinx安裝make時(shí),碰到libiconv的問(wèn)題。
查了半天,改Makefile,configure都不可靠。最后在官站上查到:
./configure –without-iconv,就好了。NND,那干嘛還要這個(gè)iconv嘛。
看出錯(cuò)代碼里,是在xmlunknowencode時(shí)才用到。我們都用utf-8,很多時(shí)候可能壓根用不著這個(gè)功能!如若需要的話,可以加上這個(gè)lib
Q、檢索出來(lái)后結(jié)果id排序問(wèn)題
SELECT * FROM documents WHERE id IN (3,5,7) ORDER BY FIELD(id,3,5,7);
或
SELECT * FROM documents WHERE id IN (3,5,7) ORDER BY substring_index((id,3,5,7),id,1)
Q、WARNING: sort_hits: merge_block_size=248 kb too low, increasing mem_limit may improve performance
A、增大mem_limit的值
Q:sphinx排序問(wèn)題
$sphinx->SetSortMode(SPH_SORT_EXTENDED,’status DESC,is_deleted DESC’); //組內(nèi)排序 setGroupBy排序的話,分成組間排序和組內(nèi)排序,比如:(317,1,hello),(317,0,world)。如果組內(nèi)排序的話,需先使用SetSortMode(),進(jìn)行自然排序,然后 使用group排序,這樣在組間排序和組內(nèi)排序都成自然狀態(tài)了!
Q、WARNING: maxed out, dismissing client
這是sphinx 客戶端找不到searchd守護(hù)進(jìn)程。具體可能是索引的鎖文件了 (***.spl)丟失, 這個(gè)文件通常是用來(lái)標(biāo)識(shí)searchd是否開啟。
通常客戶端也會(huì)返回“zero-sized searchd response”。 解決辦法: 重啟searchd即可 作者的話: It seems that a) the lock files were lost somehow, and b) you ran indexer without --rotate switch. http://www.sphinxsearch.com/forum/view.html?id=247
Q、CentOS5.4 安裝coreseek-3.2.13的mmseg 時(shí),./configure 出現(xiàn)錯(cuò)誤:config.status: error: cannot find input file: src/Makefile.in
coreseek安裝需要預(yù)裝的軟件:# yum install gcc gcc-c++ libtool autoconf automake imake mysql-devel libxml2-devel expat-devel#aclocal#libtoolize --force#automake --add-missing#autoconf#autoheader
重新configure即可!原文請(qǐng)參考:http://www.coreseek.cn/news/6/100/
Q:coreseek 在安裝 make 時(shí)候出現(xiàn) undefined reference to `libiconv’
A:編輯:
./src/MakeFile文件
將
LIBS = -lm -lexpat -L/usr/local/lib
改成
LIBS = -lm -lexpat -liconv -L/usr/local/lib
Q:在分布式搜索中api調(diào)用出現(xiàn) search Error: unknown local index ‘allindex’ in search request
具體配置是index allindex
{
type = distributed
local =usertest1stemmed
local =testidx
agent = localhost:3306:agentdata1,agentdata2
agent_connect_timeout = 1000
agent_query_timeout = 3000
}
A:這里是sphinx在解析localhost的時(shí)候不能正確指向127.0.0.1 ,所以更改一下配置中的localhost即可。即:
agent = 127.0.0.1:3306:agentdata1,agentdata2
新聞熱點(diǎn)
疑難解答
圖片精選