Skip to content

Instantly share code, notes, and snippets.

@huacnlee
Created February 22, 2011 03:28
Show Gist options
  • Save huacnlee/838170 to your computer and use it in GitHub Desktop.
Save huacnlee/838170 to your computer and use it in GitHub Desktop.
Coreseek for MySQL 数据源 安装教程
Coreseek (Sphinx) for MySQL 数据源 安装教程
1. 下载源代码
$ wget http://www.coreseek.cn/uploads/csft/3.2/coreseek-3.2.13.tar.gz
$ tar xzf coreseek-3.2.13.tar.gz
$ cd coreseek-3.2.13
2. 中文测试环境检查:
$ locale
以下为核心项,locale为zh_CN.UTF-8,就可以正常显示和输入中文;locale设置功能由操作系统自身支持,BSD/Linux均可开启;该功能,不是coreseek提供的!!!
如果不能正常显示中文,则后面的中文测试部分无法正常进行,但不会影响coreseek的实际功能;
LANG=zh_CN.UTF-8
LANGUAGE=zh_CN:zh
LC_ALL="zh_CN.UTF-8"
如果显示的不是zh_CN.UTF-8,请参考以下网址进行设置:
locale设置
命令行显示中文
putty显示中文
SecureCRT显示中文
确保可以正常显示,否则请检查当前环境的locale配置,以及当前环境或者客户端已设置好支持UTF-8中文字符显示
$ cat testpack/var/test/test.xml
3. 安装coreseek开发的mmseg,为coreseek提供中文分词功能
$ sudo apt-get install gcc g++ automake libtool mysql-client libmysqlclient15-dev libxml2-dev libexpat1-dev
$ cd mmseg-3.2.13
$ ./bootstrap
ubuntu环境下,可能需要使用 ACLOCAL_FLAGS="-I /usr/share/aclocal" ./bootstrap
$ ./configure --prefix=/usr/local/mmseg3 --with-gnu-ld --with-readline
$ make && sudo make install
安装完成后,mmseg使用的词典和配置文件,将自动安装到/usr/local/mmseg3/etc中
4. 中文分词测试,如果显示不正常,请检查当前环境下的locale和UTF-8中文字符显示设置
$ /usr/local/mmseg3/bin/mmseg -d /usr/local/mmseg3/etc src/t1.txt
中文/x 分/x 词/x 测试/x
中国人/x 上海市/x
Word Splite took: 1 ms.
tip: coreseek 安装错误预警:如果编译中出现如下错误,可以按照解决方法处理:
DWORD定义冲突:
/usr/local/mmseg3/include/mmseg/csr_typedefs.h:64: 错误: 相互冲突的声明‘typedef unsigned int DWORD’
/usr/include/sqltypes.h:97: 错误: ‘DWORD’早先被声明为‘typedef long unsigned int DWORD’
解决方法:vi /usr/local/mmseg3/include/mmseg/csr_typedefs.h,到64行,注释该行,保存退出重新编译即可!
5. 安装coreseek:
$ cd ../csft-3.2.13
$ ./configure --prefix=/usr/local/coreseek --without-python --without-mysql \
--with-mmseg --with-mmseg-includes=/usr/local/mmseg3/include/mmseg/ --with-mmseg-libs=/usr/local/mmseg3/lib/
$ make && sudo make install
6. 配置测试,测试是否可以正确运行
$ /usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/sphinx-min.conf.dist
以下为正常测试时的提示信息:
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 '/usr/local/coreseek/etc/sphinx-min.conf.dist'...
total 0 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
total 0 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
7. 数据源支持:支持MySQL数据源
$ cd csft-3.2.13
$ make clean
$ sudo ./configure --prefix=/usr/local/coreseek --with-mmseg --with-mmseg-includes=/usr/local/mmseg3/include/mmseg/ \
--with-mmseg-libs=/usr/local/mmseg3/lib/ --with-mysql
$ make
$ sudo make install
8. 测试
$ cd ../testpack
$ /usr/local/coreseek/bin/indexer -c etc/csft.conf
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'...
total 0 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
total 0 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
$ /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'...
collected 3 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 3 docs, 7585 bytes
total 0.011 sec, 672012 bytes/sec, 265.79 docs/sec
total 2 reads, 0.000 sec, 4.2 kb/call avg, 0.0 msec/call avg
total 7 writes, 0.000 sec, 3.1 kb/call avg, 0.0 msec/call avg
@huacnlee
Copy link
Author

huacnlee commented Jun 2, 2011

Mac OS X环境需要提前安装好 XCode 里面带的 Unix 开发环境工具
如果出现 libtool 什么的 command not found 那就下载 libtool 并编译安装,需要 libtool-2.2.4
http://ftp.gnu.org/gnu/libtool/libtool-2.2.4.tar.gz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment