Coreseek/Sphinx安装测试配置指南

 

Coreseek安装测试配置指南

Sphinx--强大的开源全文检索引擎,Coreseek--免费开源的中文全文检索引擎

软件版本:coreseek-4.1

          mmseg-3.2.14

          autoconf-2.64            

老版本的coreseek-3.2mmseg-3.2.13安装过程一样。

一、安装前准备编译环境

1.1 yum安装编译环境和mysql开发包

# yum install   libtool gcc-c++

# yum install   mysql-devel libxml2-devel expat-devel

1.2 编译安装autoconf

autoconf automake手工编译安装(因aclocal.m4文件由autoconf 2.64生成)。

# tar xzvf autoconf-2.64.tar.gz

# ./configure 

# make

# make install

1.3 编译安装automake

# tar xzvf automake-1.11.2.tar.gz

# cd automake-1.11.2

# ./configure 

# make

# make install

二、安装mmseg

# cd coreseek-3.2.13

# cd mmseg-3.2.13

# ./bootstrap    #输出的warning信息可以忽略,如果出现error则需要解决

# ./configure --prefix=/usr/local/mmseg

# make 

# make install

三、安装coreseek

# cd csft-3.2.13

检查系统环境

# sh buildconf.sh    #输出的warning信息可以忽略,如果出现error则需要解决

配置时要加上mysql数据源的支持

# ./configure --prefix=/usr/local/coreseek  --without-unixodbc --with-mmseg --with-mmseg-includes=/usr/local/mmseg/include/mmseg/ --with-mmseg-libs=/usr/local/mmseg/lib/ --with-mysql    

# make

# make install

# cd ..

四、mmseg中文分词测试,coreseek搜索测试

4.1 mmseg中文分词测试

# cd testpack

此时应该正确显示中文,需要预先设置好字符集为zh_CN.UTF-8,确保正确显示中文。

# cat var/test/test.xml    

中文分词测试

# /usr/local/mmseg/bin/mmseg -d /usr/local/mmseg/etc/ /root/coreseek-3.2.13/mmseg-3.2.13/src/t1.txt 

# /usr/local/mmseg/bin/mmseg -d /usr/local/mmseg/etc/ /root/coreseek-3.2.13/testpack/var/test/test.xml 

配置测试,测试是否可以正确运行

# /usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/sphinx-min.conf.dist

csft-4.0版显示:ERROR: nothing to do.

4.2 coreseek中文全文检索测试

查看正常索引指定数据时的提示信息

# /usr/local/coreseek/bin/indexer -c /root/coreseek-4.1-beta/testpack/etc/csft.conf 

# /usr/local/coreseek/bin/indexer -c /root/coreseek-3.2.13/testpack/etc/csft.conf

查看正常索引全部数据时的提示信息

# /usr/local/coreseek/bin/indexer -c /root/coreseek-3.2.13/testpack/etc/csft.conf  --all

查看正常测试搜索时的提示信息

# /usr/local/coreseek/bin/search  -c /root/coreseek-3.2.13/testpack/etc/csft.conf 

# /usr/local/coreseek/bin/search  -c /root/coreseek-4.1-beta/testpack/etc/csft.conf 

查看正常测试搜索关键词时的提示信息

# /usr/local/coreseek/bin/search  -c /root/coreseek-3.2.13/testpack/etc/csft.conf -a 提供了搜索服务

# /usr/local/coreseek/bin/search  -c /root/coreseek-4.1-beta/testpack/etc/csft.conf -a 提供了搜索服务

4.3 搜索服务的启动与关闭

开启搜索服务

# /usr/local/coreseek/bin/searchd  -c /root/coreseek-3.2.13/testpack/etc/csft.conf 

# /usr/local/coreseek/bin/searchd -c /root/coreseek-4.1-beta/testpack/etc/csft.conf 

停止搜索服务

# /usr/local/coreseek/bin/searchd  -c /root/coreseek-3.2.13/testpack/etc/csft.conf --stop

# /usr/local/coreseek/bin/searchd -c /root/coreseek-4.1-beta/testpack/etc/csft.conf --stop

五、配置、测试mysql数据源搜索

5.1 准备mysql环境

sql测试数据路径

/root/coreseek-4.1-beta/testpack/var/test/documents.sql 

创建test数据库

mysql>create database test;

导入sql测试数据

mysql -uroot -p123456 test < /root/coreseek-4.1-beta/testpack/var/test/documents.sql 

拷贝mysql示例配置文件到coreseek安装目录

# cp /root/coreseek-4.1-beta/testpack/etc/csft_mysql.conf /usr/local/coreseek/etc/

修改上述配置文件的数据库主机地址,账号,密码等。

5.2 启动搜索服务

启动搜索服务,这里选择后台运行的方式

# /usr/local/coreseek/bin/searchd -c /usr/local/coreseek/etc/csft_mysql.conf

以在log中记录每个查询的iocpu状态的方式启动搜索服务

# /usr/local/coreseek/bin/searchd  --iostats --cpustats -c /usr/local/coreseek/etc/csft_mysql.conf

停止搜索服务

# /usr/local/coreseek/bin/searchd -c /usr/local/coreseek/etc/csft_mysql.conf --stop

查看搜索服务状态

# /usr/local/coreseek/bin/searchd -c /usr/local/coreseek/etc/csft_mysql.conf --status

5.3 本机搜索测试

# /usr/local/coreseek/bin/search -c /usr/local/coreseek/etc/csft_mysql.conf -a 百度成立

停止mysql,观察以上本机搜索测试是否正常

# /etc/init.d/mysqld stop

启动mysql,观察以上本机搜索测试是否正常

# /etc/init.d/mysqld start

5.4 异机php客户端api调用测试

API路径:/root/coreseek-4.1-beta/testpack/api

拷贝test.php sphinxapi.php到支持php环境的机器,然后修改数据库地址,账号,密码等配置,测试如下:

# php test.php  中国  

PHP Warning:  Module 'redis' already loaded in Unknown on line 0

Query '中国 ' retrieved 1 of 1 matches in 0.016 sec.

Query stats:

    '中国' found 17 times in 1 documents

六、后期根据需求自定义返回数据格式

七、安装配置过程可能遇到的问题及解决方法

7.1 编译问题及解决方法

# sh buildconf.sh 

aclocal.m4:20: warning: this file was generated for autoconf 2.64.

You have another version of autoconf.  It may work, but is not guaranteed to.

If you have problems, you may need to regenerate the build system entirely.

To do so, use the procedure documented by the package, typically `autoreconf'.

configure.ac:13: error: Autoconf version 2.62 or higher is required

aclocal.m4:518: AM_INIT_AUTOMAKE is expanded from...

configure.ac:13: the top level

autom4te: /usr/bin/m4 failed with exit status: 63

autoheader: /usr/bin/autom4te failed with exit status: 63

我的autoconf版本2.59

# yum list installed|grep autoconf

autoconf.noarch                          2.59-12                       i

解决方法:

手工编译安装autoconf-2.64 automake-1.11.2,(因aclocal.m4文件由autoconf 2.64生成)。

7.2 版本3.2.13生成索引的问题及解决方法

# /usr/local/coreseek/bin/indexer -c etc/csft.conf --all

Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)]

Copyright (c) 2007-2010,

Beijing Choice Software Technologies Inc (http://www.coreseek.com)

 using config file 'etc/csft.conf'...

indexing index 'xml'...

Unigram dictionary load Error

Segmentation fault

解决办法:

# more /root/coreseek-3.2.13/testpack/etc/csft.conf 

词典路径不对,修改实际安装字典路径,默认使用相对路径,建议使用绝对路径。

7.3 版本4.1生成索引的问题及解决方法

# /usr/local/coreseek/bin/indexer -c etc/csft.conf --all

Coreseek Fulltext 4.1 [ Sphinx 2.0.2-dev (r2922)]

Copyright (c) 2007-2011,

Beijing Choice Software Technologies Inc (http://www.coreseek.com)

 using config file 'etc/csft.conf'...

indexing index 'xml'...

Unigram dictionary load Error

FATAL:  Tokenizer initialization failure. 

解决办法:

# more /root/coreseek-3.2.13/testpack/etc/csft.conf 

词典路径不对,修改实际安装字典路径,默认使用相对路径,建议使用绝对路径。

7.4 编译安装软件的小建议:编译安装完成后,不要删除源代码,不然无法unnistall

make的原理是执行一个叫Makefile文件里的指令,make的基本用处是自动根据makefile里的指令来编译源文件。它还可以用来做比如安装软件,卸载软件等事情,但前提是作者在makefile里写了。然后用make install的话,make程序就会按照上面install:后面的指令< commands >执行安装,uninstall也是一样的道理,大部分的作者会写有卸载的部分,这时只要简单地执行make unistall就可以,如果作者懒没有写,那就只有根据make install中的步骤,看它把什么文件拷到哪去了,然后分别手动删除。 

还有关键的一点是,编译安装完成后,不要删除源代码,不然就算作者写了unnistall目标,你也没有makefile可以执行了。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值