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
相关文档:
由于当初表设计的不合理,慢慢的发现浪费许多空间,且对扩展不利。决定不把同类型内容并排列保存,所以今天把多余的列剪掉,补在保留的列下面。
在表名点右键,数据操作,导出SQL脚本数据。照提示操作,这里我喜欢的是可以指定列导出。
然后把不需要的空列删掉,改一下插入的列 ......
1.编写shell脚本
vi /data/www/project_name/bin/mysql_backup.sh
#!/bin/bash
#This is a ShellScript For Auto DB Backup
#Powered by liuzheng
#系统变量定义
DBName=test
DBUser=root
DBPasswd=123456
BackupPath=/tmp/mysql_backup/
NewFile="$BackupPath"db$(date +%y%m%d ......
show tables或show tables from database_name;
解释:显示当前数据库中所有表的名称
show databases;
解释:显示mysql中所有数据库的名称
show processlist;
解释:显示系统中正在运行的所有进程,也就是当前正在执行的查询。大多数用户可以查看
他们自己的进程,但是如果他们拥有process权限,就可以查看所有人的进 ......
默认情况下,innodb的参数设置的非常小,在生产环境中远远不够用
比如最重要的两个参数
innodb_buffer_pool_size
默认是8M
innodb_flush_logs_at_trx_commit 默认设置的是1 也就是同步刷新log(可以这么理解)
innodb_buffer_pool_size:
这是InnoDB最重要的设置,对InnoDB性能有决定性的影响。默认的设置只有8M,所以 ......