分类: 系统运维
为什么要写这篇文章?
答:通过常规的三大步(./configure,make,make install)的编译安装mmseg时,总是出现找不到src/Makefile.in文件的错误(config.status: error: cannot find input file: src/Makefile.in)。即便是依照官方教程所说的先安装好依赖软件(yum -y install glibc-common libtool autoconf automake mysql-devel expat-devel,如果是用编译安装的方法安装的Mysql就不用装mysql-devel,在编译csf时指定Mysql的安装目录即可)也无法解决问题。
官方安装说明:(原文)
============================================================
依赖环境安装:
Debina等使用deb系统:
aptitude -y install yum glibc-common build-essential libtool autoconf automake libexpat-dev mysql-client (如果是用编译安装的方法安装的Mysql就不用装mysql-client ,在编译csf时指定Mysql的安装目录即可)
Centos等使用yum系统:
yum -y install glibc-common libtool autoconf automake expat-devel mysql-devel (如果是用编译安装的方法安装的Mysql就不用装mysql-devel,在编译csf时指定Mysql的安装目录即可)
BSD系统:
pkg_add -r libtool autoconf automake mysql5-client iconv
安装升级autoconf
coreseek需要autoconf 2.64以上版本,因此需要升级autoconf,不然会报错从http://download.chinaunix.net/download.php?id=29328&ResourceID=648下载autoconf-2.64.tar.bz2,安装方法如下:
http://www.coreseek.cn/uploads/csft/3.2/coreseek-3.2.14.tar.gz
mmseg安装:
一定要执行以上的拷贝,否则coreseek在make编译时会出错。
coreseek安装:
备注:需要预先设置好字符集为zh_CN.UTF-8,确保正确显示中文,我的系统字符集为en_US.UTF-8也是可以的。
**************分词库*****************
mkdir -p /usr/local/mmseg3/etc
cp <mmseg_soft_rootdir>/data/unigram.txt /usr/local/mmseg3/etc/
cd /usr/local/mmseg3/etc
../bin/mmseg -u unigram.txt
生成unigram.txt.uni
cp unigram.txt.uni uni.lib
【分词库配置说明】
vi mmseg.ini
在里面添加内容
[mmseg]
merge_number_and_ascii=1;
number_and_ascii_joint=-.;
compress_space=0;
seperate_number_ascii=1;
以上解释如下
//
merge_number_and_ascii: 字母和数字连续出现是非切分
number_and_ascii_joint:连接数字和字母可用的符号,如’-’ ‘.’ 等
compress_space:暂时无效
seperate_number_ascii:是否拆分数字,如 1988 -> 1/x 9/x 8/x 8/x
//
*********************************
cd /usr/local/coreseek/
bin/indexer --all [--config sphinx.conf] 用于创建全文索引
bin/search <搜索关键字> 一个简单的命令行(CLI) 的测试程序,用于测试全文索引;
bin/searchd [--config sphinx.conf] 一个守护进程,其他软件可以通过这个守护进程进行全文检索;
附加:
1. 如需启用python支持,请安装或者升级至python2.6,configure之中,去掉--without-python,加上--with-python,然后重新编译安装
python data source演示:下载
2. 如果不可以搜索中文,请首先检查英文是否正常;如英文正常,则请检查:
a. charset_dictpath = etc/dict/ #请确保uni.lib在此目录下
charset_type = zh_cn.utf-8
b. charset_table的配置请注释掉
c. 请确保从数据来源读取的数据,为utf-8字符集;
MySQL4.1起可以通过SET NAMES设定输出字符集,即使原始数据为GBK;
MySQL4.1以下版本,请直接联系我们解决GBK问题;
d. 请确保你测试检索时,传送到search或者searchd的字符串尾utf-8
e. 请查看search或者Query返回信息中,分词信息是否正确
d. 词典的设置和构建,具体请查看mmseg
f. 请前往 论坛 提出问题
3. 如果提示:iniparser: cannot open /usr/local/csft/mmseg.ini
请前往查看mmseg.ini具体设置方法
4. 如果提示no working pthreads library found,请参考。
===============================================================
5. coreseek启动脚本
coreseek源码包里没有启动程序,只能手动通过命令来启动,将下面的文件命名为shinxed,保存在/etc/ini.d/里,就可以实现相应的系统自动启过徎。
然后可以使用 sudo /etc/inid.d/sphinxed start来启动
ubuntu下开机自动启动:sudo update-rc.d sphinxed defaults
start-stop-daemon是一个很优秀的后台运行管理程序,采用C开发。Ubuntu上使用start-stop-daemon比较方便,CetnOS就要手动安装下。
5. SphinxClient 安装php扩展sphinx
或者可以直接使用$root_path/coreseek-version/testpack/api/目录中的提供的api接口文件
1.安装
1、安装sphinx
请参照文档http://linux008.blog.51cto.com/2837805/622088
2、编写测试文件