安裝coreseek以前須要安裝這些工具,固然使用yum安裝你的機子須要先保證已經聯網php
yum install make gcc g++ gcc-c++ libtool autoconf automake imake mysql-devel libxml2-devel expat-devel
$ wget http://www.coreseek.cn/uploads/csft/3.2/coreseek-3.2.14.tar.gz $ tar xzvf coreseek-3.2.14.tar.gz $ cd coreseek-3.2.14 ##安裝mmseg中文分詞 $ cd mmseg-3.2.14 $ ./bootstrap #輸出的warning信息能夠忽略,若是出現error則須要解決 $ ./configure --prefix=/usr/local/mmseg3 $ make && make install $ cd .. ##安裝coreseek $ cd csft-3.2.14 $ sh buildconf.sh #輸出的warning信息能夠忽略,若是出現error則須要解決 $ ./configure --prefix=/usr/local/coreseek --without-unixodbc --with-mmseg --with-mmseg-includes=/usr/local/mmseg3/include/mmseg/ --with-mmseg-libs=/usr/local/mmseg3/lib/ --with-mysql ##若是提示mysql問題,能夠查看MySQL數據源安裝說明,注意--prifix後面的路徑要和本身安裝的路徑一致 $ make && make install $ cd ..
cp /usr/local/coreseek/etc/sphinx.conf.dist /usr/local/coreseek/etc/sphinx.conf vi /usr/local/coreseek/etc/sphinx.conf
source news { type = mysql sql_host = localhost sql_user = root sql_pass =123456 sql_db = test sql_port =3306 sql_sock =/tmp/mysql.sock sql_query_pre = SET NAMES utf8 sql_query_pre = REPLACE INTO sph_counter SELECT 1, MAX(id) FROM news sql_query = SELECT id, contents, intro, title FROM news WHERE id<=( SELECT max_doc_id FROM sph_counter WHERE counter_id=1) } #設置增量索引,數據量較小時,也能夠不設置而定時從新生成索引 source increment : news { sql_query_pre = SET NAMES utf8 sql_query = SELECT id, contents, intro, title FROM news WHERE id >( SELECT max_doc_id FROM sph_counter WHERE counter_id=1) #這是增量索引的數據源sql。和上面保持一致,惟一的變化,就是where條件以後,這裏查詢的是大於上次從新生成索引的id,即:剛剛添加的數據 } index news { source = news path =/usr/local/coreseek/var/data/news docinfo =extern mlock =0 morphology = none charset_dictpath =/usr/local/mmseg3/etc/ charset_type = zh_cn.utf-8 } index increment : news { source = increment path =/usr/local/coreseek/var/data/increment charset_dictpath =/usr/local/mmseg3/etc/ charset_type = zh_cn.utf-8 } indexer { mem_limit =128M } searchd { log =/usr/local/coreseek/var/log/searchd.log read_timeout =5 client_timeout =300 max_children =30 pid_file =/usr/local/coreseek/var/log/searchd.pid max_matches =1000 seamless_rotate =1 preopen_indexes =0 unlink_old =1 mva_updates_pool =1M max_packet_size =8M max_filter_values =4096 }
生成索引 html
/usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/sphinx.conf --all --rotate
說明:這時sph_counter 表裏會增長一條記錄。存放的就是你內容表中的最大id。若是想要生成單個數據源的索引, /usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/sphinx.conf news --rotate(這條命令只生成news的索引)python
開啓後臺進程 mysql
/usr/local/coreseek/bin/searchd -c /usr/local/coreseek/etc/sphinx.conf
說明:這時候對Mysql數據源進行搜索的話其實已是有數據的。
c++
增量索引git
/usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/sphinx.conf increment --rotate
說明:這裏增量索引的名稱要換成本身對應的增量索引的名稱
sql
合併索引 數據庫
/usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/sphinx.conf --merge news increment --rotate
說明:合併索引後,news索引此時能夠檢索到全部的數據,可是sph_counter表中最大id是沒有變的,所以還須要在必定的時間內再次從新生成全部的索引
爲了保持數據的完整性,從新生成索引bootstrap
/usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/sphinx.conf --all --rotate
*/1****/bin/sh /usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/sphinx.conf increment --rotate */5****/bin/sh /usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/sphinx.conf --merge news increment --rotate 301*** /bin/sh /usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/sphinx.conf --all --rotate
#cd /usr/local/coreseek-3.2.14/csft-3.2.14/api/libsphinxclient #./configure --prefix=/usr/local/sphinxclient #configure: creating ./config.status #config.status: creating Makefile #config.status: error: cannot find input file:Makefile.in #報錯configure失敗 //處理configure報錯 編譯過程當中報了一個config.status: error: cannot find input file: src/Makefile.in這個的錯誤,而後運行下列指令再次編譯就能經過了: # aclocal # libtoolize --force # automake --add-missing # autoconf # autoheader # make clean //重新configure編譯 # ./configure # make && make install [第二步] 安裝sphinx的PHP擴展 # wget http://git.php.net/?p=pecl/search_engine/sphinx.git;a=snapshot;h=9a3d08c67af0cad216aa0d38d39be71362667738;sf=tgz # tar zxvf sphinx-9a3d08c.tar.gz # cd sphinx-9a3d08c # /usr/local/php/bin/phpize # ./configure --with-php-config=/usr/local/php/bin/php-config --with-sphinx=/usr/local/sphinxclient # make && make install
extension = sphinx.so
/etc/init.d/php-fpm restart