coreseek mysql.sock_centos安装coreseek
最近一個老項目需要重寫,由于數據量很大搜索使用了sphinx的擴展版本coreseek,進而可以減少數據庫查詢的壓力,接下來吾愛編程為大家詳細的介紹一下coreseek安裝及使用方法,有需要的小伙伴可以參考一下:
1、介紹:
Coreseek 是一款中文全文檢索/搜索軟件,以GPLv2許可協議開源發布,基于Sphinx研發并獨立發布,專攻中文搜索和信息處理領域,適用于行業/垂直搜索、論壇/站內搜索、數據庫搜索、文檔/文獻檢索、信息檢索、數據挖掘等應用場景。
2、安裝前準備:yum?install?make?gcc?g++?gcc-c++?libtool?autoconf?automake?imake?mysql-devel?libxml2-devel?expat-devel
3、下載并解壓:cd?opt
wget?https://down.itbiancheng.com/uploads/soft/coreseek-4.1-beta.tar.gz
tar?-xzvf?coreseek-4.1-beta.tar.gz
cd?coreseek-4.1-beta
4、安裝mmseg:cd?mmseg-3.2.14
./bootstrap
./configure?--prefix=/opt/coreseek-4.1
make
make?install
make?clean
5、安裝csft:
安裝前先編輯configure.ac,位置13行AM_INIT_AUTOMAKE([-Wall?-Werror?foreign])
修改為
AM_INIT_AUTOMAKE([-Wall?foreign])cd?csft-4.1/
./buildconf.sh
./configure?--prefix=/opt/coreseek-4.1?--without-unixodbc?--with-mmseg?--with-mmseg-includes=/opt/coreseek-4.1/include/mmseg/?--with-mmseg-libs=/opt/coreseek-4.1/lib/?--with-mysql
make
make?install
make?clean
6、配置使用:
(1)、配置數據源:cd?/opt/coreseek-4.1/etc
cp?sphinx-min.conf.dist?csft.conf
vim?/opt/coreseek-4.1/etc/csft.conf
內容如下:source?lkeyw
{
type??????????????????=?mysql
sql_host????????????????=?localhost
sql_user????????????????=?root
sql_pass????????????????=?123456
sql_db?????????????????=?new_itbiancheng
sql_port????????????????=?3306??#?optional,?default?is?3306
sql_sock????????????????=?/tmp/mysql.sock
sql_query_pre???????????=?SET?NAMES?utf8??#命令行查詢時,設置正確的字符集
sql_query_range?????????=?SELECT?MIN(id),MAX(id)?FROM?web_lkeyw1
sql_range_step??????????=?1000
sql_query?????????=?SELECT??ID,ID?as?testid,title,url,updatetime?FROM?web_lkeyw?WHERE?ID?BETWEEN?$start?AND?$end;
sql_attr_uint???????=?testid
sql_attr_timestamp?????=?updatetime
sql_field_string?=?title
sql_field_string?=?url
#sql_query_info?=?SELECT?ID,title,content,updatetime,url_link?FROM?web_lkeyw?WHERE?ID=$id
}
index?lkeyw
{
source??????????????????=?lkeyw
path????????????????????=?/opt/coreseek/lkeyw
docinfo?????????????????=?extern
#?必須設置,表示詞典文件的目錄,該目錄下必須有uni.lib詞典文件存在
charset_dictpath????????=?/opt/coreseek-4.1/etc/
#?必須設置
charset_type????????????=?zh_cn.utf-8
#?必須設置,表示取消原有的一元字符切分模式,不使其對中文分詞產生干擾
ngram_len???????????????=?0
mlock???????????????????=?0
morphology??????????????=?none
min_word_len????????????=?1
stopwords???????????????=?/opt/coreseek/stopwords-cn.txt?/opt/coreseek/stopwords-en.txt
html_strip??????????????=?1
html_remove_elements????=?style,?script
preopen?????????????????=?1
ondisk_dict?????????????=?1
inplace_enable??????????=?1?#?減少了建立索引時的磁盤壓力
inplace_hit_gap?????????=?1M
inplace_docinfo_gap?????=?1M
}
indexer
{
mem_limit???????????????=?256M
max_iops????????????????=?50?#?每秒IO操作限制
write_buffer????????????=?4M?#?寫緩沖區越大則所需的磁盤寫入次數越少
}
searchd
{
listen??????????????????=?9313
log?????????????????????=?/opt/coreseek/searchd.log
#query_log???????????????=?/opt/coreseek/query.log
query_log_format????????=?sphinxql?#?default?plain
binlog_path?????????????=?/opt/coreseek/
read_timeout????????????=?5
max_children????????????=?30
pid_file????????????????=?/opt/coreseek/coreseek.pid
max_matches?????????????=?1000
seamless_rotate?????????=?1
preopen_indexes?????????=?1
unlink_old??????????????=?1
ondisk_dict_default?????=?1?#?keep?all?dictionaries?on?disk
workers?????????????????=?fork?#?for?RT?to?work
compat_sphinxql_magics??=?0
}
(2)、開啟searchd服務,生成索引/opt/coreseek-4.1/bin/searchd?-c?/opt/coreseek-4.1/etc/csft.conf
/opt/coreseek-4.1/bin/indexer?-c?/opt/coreseek-4.1/etc/csft.conf?--all?--rotate
(3)、測試:[[email?protected]?etc]#?/opt/coreseek-4.1/bin/search?-c?/opt/coreseek-4.1/etc/csft.conf??微信為什么刪不了好友
Coreseek?Fulltext?4.1?[?Sphinx?2.0.2-dev?(r2922)]
Copyright?(c)?2007-2011,
Beijing?Choice?Software?Technologies?Inc?(http://www.coreseek.com)
using?config?file?'/usr/local/coreseek-4.1/etc/csft.conf'...
index?'lkeyw':?query?'微信為什么刪不了好友?':?returned?2?matches?of?2?total?in?0.024?sec
displaying?matches:
1.?document=1,?weight=4463,?testid=1,?title=微信為什么刪不了好友,刪了又有,?url=enoz4pgk3w,?updatetime=Sat?May??6?14:45:16?2017
2.?document=4,?weight=2449,?testid=4,?title=微信被人刪好友之后發消息的提示,?url=23ewkejq36,?updatetime=Sat?May??6?15:08:15?2017
words:
1.?'微':?10?documents,?10?hits
2.?'信':?10?documents,?10?hits
3.?'刪':?2?documents,?3?hits
4.?'好友':?3?documents,?3?hits
(4)、配合PHP使用:require_once('sphinxapi');
$s?=?new?SphinxClient();
$s->SetServer('127.0.0.1','9313');?//設置searchd的主機名和TCP端口
$s->SetConnectTimeout(2);?//?設置連接超時
$s->SetMatchMode(SPH_MATCH_BOOLEAN);?//設置全文查詢的匹配模式
$page_size=5;//自己定義的頁數
$s->SetLimits($start,$page_size);?//設置返回結果集偏移量和數目
$s->SetSortMode(?SPH_SORT_EXTENDED,"good_count?DESC,?@id?DESC"?);?//?設置排序
$s->SetArrayResult(true);//控制搜索結果集的返回格式
$res?=?$s->Query($keyword,'*');//?執行搜索查詢
$res_list?=?$res['matches'];
7、常用命令:#啟動
/opt/coreseek-4.1/bin/searchd?-c?/opt/coreseek-4.1/etc/csft_mysql.conf
#停止
/opt/coreseek-4.1/bin/searchd?-c?/opt/coreseek-4.1/etc/csft_mysql.conf?--stop
#建立索引
/opt/coreseek-4.1/bin/indexer?-c?/opt/coreseek-4.1/etc/csft_mysql.conf?--all
#重建索引
/opt/coreseek-4.1/bin/indexer?-c?/opt/coreseek-4.1/etc/csft_mysql.conf?--all?--rotate
8、常見錯誤解決:
以上就是吾愛編程為大家介紹的關于centos安裝coreseek,了解更多相關文章請關注吾愛編程網!
總結
以上是生活随笔為你收集整理的coreseek mysql.sock_centos安装coreseek的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mybatis学习(22):查询排序
- 下一篇: mybatis学习(9):mybatis