安装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