1. sphinx 全文检索引擎,有分tar.gz包安装和rpm包安装
2. 目前本人用的是rpm包进行安装,经过一番折腾,终于安装成功。
3. 安装rpm 时遇到的问题:如图
解决方式: 下载依赖包。 历时三个步骤下载安装. 前两个需要下载,第三个直接安装
rpm -ivh MySQL-shared-compat-5.1.47-1.rhel5.x86_64.rpm
rpm -ivh perl-DBD-MySQL-3.0007-2.el5.x86_64.rpm
yum -y installmysql-connector-odbc(libodbc.so)
4. 解决完问题,直接安装sphinx,如图显示安装成功
5. sphinx执行启动,需四个步骤
编辑 /etc/sphinx/sphinx.conf
## Minimal Sphinx configuration sample (clean, simple,functional)
#
source src1
{
type = mysql
sql_host = 127.0.0.1//数据库地址
sql_user = root //数据库账号
sql_pass = root//数据库密码
sql_db = test//数据库
sql_port =3306 # optional, default is 3306//数据库端口
sql_query = select id,group_id,UNIX_TIMESTAMP(date_added) as date_added,title,content fromdocuments //select所有你想要查询的字段从你的表里
sql_query_info =SELECT * FROM documents WHERE id=$id//从你的表里查询出id
}
index test1
{
source =src1//数据源这里指上门
path =/var/lib/sphinx/test1//简历索引后文档存放位置
docinfo =extern
charset_type = utf-8//数据编码
}
indexer
{
mem_limit = 256M//索引器最大使用内存
}
searchd//这里基本不用动
{
listen =9312
listen =9306:mysql41
log =/var/log/sphinx/searchd.log
query_log =/var/log/sphinx/query.log
read_timeout =5
max_children =30
pid_file =/var/run/sphinx/searchd.pid
max_matches = 1000
seamless_rotate = 1
preopen_indexes = 1
unlink_old = 1
workers =threads # for RT to work
binlog_path = /var/lib/sphinx/
}
管理索引 sudo �Cu sphinx indexer �Call --rotate
启动搜索守护进程 service searchd start
使用mysql的查询搜索守护线程, 查询包含关键字test的字段
本文出自 “生如夏花” 博客,谢绝转载!