Sphinx 0.9.8起步

又是俄罗斯产的.
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.
  1. 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 ../



  2. tar zxvf mysql-5.1.26-rc.tar.gz
  3. tar zxvf sphinx-0.9.8-rc2.tar.gz
  4. cd sphinx-0.9.8-rc2/
  5. patch -p1 < ../sphinx-0.98rc2.zhcn-support.patch
  6. patch -p1 < ../fix-crash-in-excerpts.patch
  7. cp -rf mysqlse ../mysql-5.1.26-rc/storage/sphinx
  8. cd ../
  9. cd mysql-5.1.26-rc/
  10. sh BUILD/autorun.sh
  11. ./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
  12. make && make install
  13. 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

输出:
  1. Sphinx 0.9.8-rc2 (r1234)
  2. Copyright (c) 2001-2008, Andrew Aksyonoff
  3. using config file '/usr/local/sphinx/etc/sphinx.conf'...
  4. indexing index 'test1'...
  5. collected 4 docs, 0.0 MB
  6. sorted 0.0 Mhits, 100.0% done
  7. total 4 docs, 184 bytes
  8. 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来调用.








评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值