又是俄罗斯产的.
通过国外《High Performance MySQL》专家组的测试可以看出,根据主键进行查询的类似“SELECT ... FROM ... WHERE id = ...”的SQL语句(其中id为PRIMARY KEY),每秒钟能够处理10000次以上的查询,而普通的SELECT查询每秒只能处理几十次到几百次.
建议在mysql编译安装的时候, 把SphinxSE存储引擎(SE目录下)包含了:
Indexer, Searcher....
Nginx, Sphinx, 全是nx结尾, 表明自己很牛.
不比去表明, 有数据说话:
通过国外《High Performance MySQL》专家组的测试可以看出,根据主键进行查询的类似“SELECT ... FROM ... WHERE id = ...”的SQL语句(其中id为PRIMARY KEY),每秒钟能够处理10000次以上的查询,而普通的SELECT查询每秒只能处理几十次到几百次.
下面介绍一下
建议在mysql编译安装的时候, 把SphinxSE存储引擎(SE目录下)包含了:
这段文字来自(http://blog.s135.com/)
先patch一下, 中文支持, 已经修改的一个bug.
patch -p1 < ../sphinx-0.98rc2.zhcn-support.patch
patch -p1 < ../fix-crash-in-excerpts.patch
cp -rf mysqlse ../mysql-5.1.26-rc/storage/sphinx
cd ../
- tar zxvf mysql-5.1.26-rc.tar.gz
- tar zxvf sphinx-0.9.8-rc2.tar.gz
- cd sphinx-0.9.8-rc2/
- patch -p1 < ../sphinx-0.98rc2.zhcn-support.patch
- patch -p1 < ../fix-crash-in-excerpts.patch
- cp -rf mysqlse ../mysql-5.1.26-rc/storage/sphinx
- cd ../
- cd mysql-5.1.26-rc/
- sh BUILD/autorun.sh
- ./configure --with-plugins=sphinx --prefix=/usr/local/mysql-search/ --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile
- make && make install
- cd ../
用的到mysql和python的某些头文件.
aptitude install libmysql++-dev libmysqlclient15-dev checkinstall
aptitude install g++ python-dev
g++, 是因为需要这个编译器.
最后编译sphinx:
没啥好说的, 提醒一下, mmseg的俩路径要找好了:
./configure --prefix=/usr/local/sphinx --with-python --with-mysql --with-mmseg-includes=/usr/local/include/mmseg/ --with-mmseg-libs=/usr/local/lib/
然后make&make install
如果没错误, 就可以动手试试了.
cd /usr/local/sphinx/etc/
cp sphinx.conf.dist sphinx.conf
编辑一下这个配置文件, 主要是数据库的设置.
然后导入同目录下的example.sql
mysql -u root -p < example.sql
注意一下conf文件中的, indexer的index definition部分的名称.
./indexer test1
输出:
- Sphinx 0.9.8-rc2 (r1234)
- Copyright (c) 2001-2008, Andrew Aksyonoff
- using config file '/usr/local/sphinx/etc/sphinx.conf'...
- indexing index 'test1'...
- collected 4 docs, 0.0 MB
- sorted 0.0 Mhits, 100.0% done
- total 4 docs, 184 bytes
- total 0.010 sec, 18400.00 bytes/sec, 400.00 docs/sec
./search 测试
Sphinx 0.9.8-rc2 (r1234)
Copyright (c) 2001-2008, Andrew Aksyonoff
using config file '/usr/local/sphinx/etc/sphinx.conf'...
index 'test1': query '测试 ': returned 1 matches of 1 total in 0.000 sec
displaying matches:
1. document=4, weight=2, group_id=2, date_added=Mon Sep 22 01:25:44 2008
id=4
group_id=2
group_id2=8
date_added=2008-09-22 01:25:44
title=测试
content=this is to test groups
words:
1. '?': 1 documents, 1 hits
2. '?': 1 documents, 1 hits
index 'test1stemmed': search error: failed to open /usr/local/sphinx/var/data/test1stemmed.sph: No such file or directory.
注意到最后出现一个错误.
下次我们试试用python来调用.