1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
//csft.conf配置 source main{ sql_query_pre = set names utf8 sql_query_pre = replace into sphinx_count select 1,max(id) from test sql_query = select * from test where id <= (select sphinx_id from sphinx_count where id = 1) } source delta:main{ sql_query_pre = set names utf8 sql_query = select * from test where id > (select sphinx_id from sphinx_count where id = 1) } index main{ //不变 } index delta:main{ source = delta path = /usr/local/coreseek/var/data/delta } //创建mysql表 create table sphinx_count(id tinyint unsigned not null primary key auto_increment,sphinx_id int unsigned not null default 0); //main.sh #!/bin/bash #更新主索引 /usr/local/coreseek/bin/indexer --all --rotate >> /usr/local/coreseek/var/log/main.log //delta.sh #!/bin/bash #更新增量索引 /usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/csft.conf delta --rotate >> /usr/local/coreseek/var/log/delta.log //merge.sh #!/bin/bash #将增量索引合并到主索引 /usr/local/coreseek/bin/indexer --merge main delta --rotate >> /usr/local/coreseek/var/log/merge.log //安装crontab yum -y install crontab //相关命令如下 service crond status service crond stop service crond start /* > /dev/null 2>&1 可以简单的理解 /dev/null是linux下的回收站 > 默认是把标准输出重定向 2>&1 是把错误输出也定向到标准输出 综合就是把标准输出和错误输出都放到回收站。 */ //分 时 日 月 周 //每天凌晨3点半更新所有索引 每5分钟更新增量索引 crontab -e 30 3 * * * /bin/sh /usr/local/coreseek/dirforsh/main.sh > /dev/null 2>&1 */5 * * * * /bin/sh /usr/local/coreseek/dirforsh/delta.sh > /dev/null 2>&1 |