sphinx整合到mysql(master/slave)中
sphinx版本使用的是coreseek修改的支 持中文检索的版本,中文词库使用 coreseek开发的libmmseg
mysql受sphinx中sphinxse引擎要求安装了mysql-5.0.37做生产环境的mysql-5.0.70的从库
编译sphinx,libmmseg以及mysql:
编译安装libmmseg:
./configure --prefix=/usr/local/mmseg && make -j5 && make install
copy 解压缩后的sphinx目录中的mysqlse中的文件到mysql下的sql/sphinx/中
给mysql打sphinx的补丁
patch -p1 < sql/sphinx/sphinx.5.0.37.diff
编译mysql:
./configure --prefix=/data/app/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-readlin
e --with-big-tables --enable-local-infile --with-sphinx-storage-engine --without-innobase
make -j5 && make install
编译sphinx
CPPFLAGS=-I/usr/include/python2.5 LDFLAGS=-lpython2.5 ./configure --prefix=/data/app/sphinx --with-mysql=/data/app/mysql --with-mmse
g=/data/app/mmseg --with-mmseg-includes=/data/app/mmseg/include/mmseg --with-mmseg-libs=/data/app/mmseg/lib
make -j5 && make install
配置mysql主从
.master -> slave
生成字典文件:
mmseg -u unigram.txt
mv unigram.txt.lib /data/app/dict/uni.lib
配置sphinx.conf
source source_name {...} #做全文检索的内容源
source source_name_increase:source_name {...} #做增量检索的源
index index_name {...} #做索引的配置
index index_name_increase:index_name {...} #做增量索引的配置
indexer {...} #indexer进程的设置
searched {...} #searched进程的设置
建立在增量索引需要使用的数据表以及SPHINX引擎需要的表:
CREATE TABLE `sphcounter` (
`counterid` int(11) NOT NULL,
`max_doc_id` int(11) NOT NULL,
PRIMARY KEY (`counterid`)
) ENGINE=MyISAM
CREATE TABLE `sphinx` (
`id` int(11) NOT NULL,
`weight` int(11) NOT NULL,
`query` varchar(255) NOT NULL,
KEY `Query` (`query`)
) ENGINE=SPHINX DEFAULT CHARSET=utf8 CONNECTION='sphinx://localhost:3312/cbid_index';
建立启动脚本以及建立索引的脚本:
#!/bin/bash
/data/app/sphinx/bin/indexer --all --config /data/app/sphinx/etc/sphinx.conf
sphinx.increase
#!/bin/bash
/dat
相关文档:
下载地址:http://download.csdn.net/down/434743/yuzhongqing2005
Navicat 8 for MySQL的注册码:
PremiumSoft Navicat for MySQL Enterprise Edition v8.XX
姓名(Name):3ddown.com
组织(Organization):3ddown.com
注册码(Serial):NAVJ-W56S-3YUU-MVHV ......
以下命令可以在任何已经连接上MYSQL服务器的客户端上执行。
show full processlist ;
kill 57725;#杀掉上面查到的某个导致阻塞的连接
SELECT @@profiling;
SET profiling = 1;
SHOW PROFILES;
SHOW PROFILE for QUERY 1;
#系统设置
show variables like '%key%';
show variables like '%key%';
show variables l ......
http://hi.baidu.com/thinkinginlamp/blog/item/a352918fe70d96fd503d925e.html
2009年01月12日 星期一 下午 08:35
作者:老王
在网上随便搜搜,就能找到大把的关于MySQL优化的文章,不过里面很多都不准确,说个常见的:
SELECT a from ... WHERE b = ...
一般来说,很多文章会告诫你类似这样的查询,不要在“a ......
MySQL数据库优化处理实现千万级快速分页分析,来看下吧。
数据表 collect ( id, title ,info ,vtype) 就这4个字段,其中 title 用定长,info 用text, id 是逐渐,vtype是tinyint,vtype是索引。这是一个基本的新闻系统的简单模型。现在往里面填充数据,填充10万篇新闻。
最后collect 为 10万条记录,数据库表占用硬盘1.6G ......