coreseek sphinx mmseg mysql 全文检索 安装 配置

张映 发表于 2014-08-01

分类目录: mysql

标签:, , , , , , ,

上次搞全文检索的东西 ,还要追溯到2010了,当时个人觉得coreseek还不成熟,就用了原始的sphinx,请参考:sphinx mmseg mysql 中文分词,这次呢,决定用一下coreseek,看看有什么区别。

一,安装环境和工具

服务器用的是centos6.5 x86

coreseek 4.0.1下载地址:http://www.coreseek.cn/uploads/csft/4.0/coreseek-4.0.1-beta.tar.gz

mysql 5.5.8下载地址:http://downloads.mysql.com/archives/community/

二,mmseg中文分词安装

1,旧版本安装方法

  1. # tar zxvf coreseek-4.0.1-beta  
  2. # cd coreseek-4.0.1-beta/mmseg-3.2.14/  
  3. # aclocal  
  4. # libtoolize --force  
  5. # automake --add-missing  
  6. # autoconf  
  7. # autoheader  
  8. # make clean  
  9. # ./configure --prefix=/usr/local/mmseg3  
  10. # make  
  11. # make install  

2,新版本安装方法

  1. # ./bootstrap  
  2. # ./configure --prefix=/usr/local/mmseg3  
  3. # make  
  4. # make install  

mmseg-3.2.14,二种方法都可以安装成功,在编译时有报warning,但不影响安装。

3,新版本mmseg安装后,分词的东西就好了,不要用mmseg去生成了

  1. [root@localhost mmseg-3.2.14]# ll /usr/local/mmseg3/etc/  
  2. 总用量 5432  
  3. -rwxr-xr-x 1 root root 229 7月 31 01:44 mmseg.ini  
  4. -rwxr-xr-x 1 root root 1826251 7月 31 01:44 unigram.txt  
  5. -rwxr-xr-x 1 root root 3729280 7月 31 01:44 uni.lib  

4,mmseg.ini配置的官方说明

  1. [mmseg]  
  2. merge_number_and_ascii=0; #合并英文和数字 abc123/x  
  3. number_and_ascii_joint=-; #定义可以连接英文和数字的字符  
  4. compress_space=1;         #暂不支持  
  5. seperate_number_ascii=0; #就是将字母和数字打散  

三,csft(sphinx)安装

1,旧版安装

  1. # cp /coreseek的解压目录/mmseg-3.2.14/src/*/*.h /usr/local/mmseg3/include/mmseg/  
  2. # cd /home/tank/download/coreseek-4.0.1-beta  
  3. # aclocal  
  4. # libtoolize --force  
  5. # automake --add-missing  
  6. # autoconf  
  7. # autoheader  
  8. # perl -pi -e 's/lpthread/lpthread -liconv/g' src/Makefile*  
  9. # make clean  
  10. # ./configure --prefix=/usr/local/sphinx --enable-id64 \  
  11. --with-mysql=/usr/local/mysql2 --with-mmseg \  
  12. --with-mmseg-includes=/usr/local/mmseg3/include/mmseg/ \  
  13. --with-mmseg-libs=/usr/local/mmseg3/lib/  
  14. # make && make install  

2,新版安装

  1. # cd /home/tank/download/coreseek-4.0.1-beta  
  2. # ./buildconf.sh  
  3. # ./configure --prefix=/usr/local/sphinx --enable-id64 \  
  4. --with-mysql=/usr/local/mysql2 --with-mmseg \  
  5. --with-mmseg-includes=/usr/local/mmseg3/include/mmseg/ \  
  6. --with-mmseg-libs=/usr/local/mmseg3/lib/  
  7. # make && make install  

coreseek-4.0.1,二种安装方式都是可以的,但是安装时,还是会报错。

四,mysql插件 sphinxse的安装

1,将mysqlse复制到mysql程序目录storage

  1. # cp -R coreseek-4.0.1-beta/csft-4.0.1-beta/mysqlse /home/tank/download/mysql-5.5.8/storage/sphinx  

2,cmake安装mysql 5.5.8

  1. #cd /home/tank/download/mysql-5.5.8  
  2. # cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql2 \  
  3.  -DMYSQL_UNIX_ADDR=/usr/local/mysql2/mysql.sock \  
  4.  -DCMAKE_BUILD_TYPE=Release -DWITH_SPHINX_STORAGE_ENGINE=1 \  
  5.  -DDEFAULT_CHARSET=utf8 \  
  6.  -DDEFAULT_COLLATION=utf8_general_ci \  
  7.  -DWITH_MYISAM_STORAGE_ENGINE=1 \  
  8.  -DWITH_INNOBASE_STORAGE_ENGINE=1 \  
  9.  -DWITH_MEMORY_STORAGE_ENGINE=1 \  
  10.  -DWITH_READLINE=1 \  
  11.  -DENABLED_LOCAL_INFILE=1 \  
  12.  -DMYSQL_DATADIR=/usr/local/mysql2/data \  
  13.  -DMYSQL_USER=mysql  
  14.   
  15. # make && make install  

cmake安装mysql高版本,请参考:linux cmake 安装mysql5.5.11,以及更高版本

3,configure安装mysql5.5.8

  1. # cd /home/tank/download/mysql-5.5.8  
  2. # sh BUILD/autorun.sh  
  3. # ./configure --prefix=/usr/local/mysql2 \  
  4. --with-plugins=partition,innobase,myisam,sphinx \  
  5. --with-charset=utf8  
  6. # make && make install  

4,初始化数据库

  1. # cd /home/tank/download/mysql-5.5.8  
  2. chmod +x scripts/mysql_install_db  
  3. # scripts/mysql_install_db --basedir=/usr/local/mysql2 \ #初始化数据  
  4. --datadir=/usr/local/mysql2/data --user=mysql  
  5. # cp support-files/my-medium.cnf /etc/my.cnf #copy配置文件  
  6. chown -R mysql:mysql /usr/local/mysql2 #更改权限   
  7.   
  8. # vim /etc/my.cnf      #加上以下内容  
  9. [mysqld]  
  10. basedir = /usr/local/mysql2  
  11. datadir = /usr/local/mysql2/data  
  12. log-error = /usr/local/mysql2/mysql_error.log  
  13. pid-file = /usr/local/mysql2/mysql.pid  
  14. user = mysql  
  15. tmpdir = /tmp  

5,启动并登录mysql

  1. # cd /usr/local/mysql2/support-files/  
  2. # cp ./mysql.server /etc/init.d/mysql5  
  3. # /etc/init.d/mysql5 start              #启动服务端  
  4. # /usr/local/mysql2/bin/mysql           #客户端连接  

6,启用sphinxse

sphinxse

sphinxse

在这里和以前安装sphinxse,有一点不同的是,以前mysql编译安装好了以后,就会有,不用在用root登录去install了。

五,配置sphinx.conf

  1. # cd /usr/local/mysql2/support-files/  
  2. # cp ./mysql.server /etc/init.d/mysql5  
  3. # /etc/init.d/mysql5 start  
  4.   
  5. # cd /usr/local/sphinx/etc  
  6. # cp sphinx.conf.dist sphinx.conf  
  7. # vim sphinx.conf   
  8.   
  9. source src1  
  10. {  
  11.  type = mysql  
  12.  sql_host = localhost  
  13.  sql_user = root //用名改一下  
  14.  sql_pass = 111111 //密码改一下,无密码,留空  
  15.  sql_db = test  
  16.  sql_query_pre = SET NAMES utf8 //这行注释去掉  
  17.  。。。。。。。。。。。省略。。。。。。。。。。。。。。  
  18. }  
  19. 。。。。。。。。。。。省略。。。。。。。。。。。。。。  
  20. index rt //在index里面添加以下三行,加入中文分词功能  
  21. {  
  22.  type = rt  
  23.  path = /usr/local/sphinx/var/data/rt  
  24.  charset_dictpath = /usr/local/mmseg3/etc/ //添加  
  25.  charset_type = zh_cn.utf-8 //添加  
  26.  ngram_len = 0 //添加  
  27.  rt_field = title  
  28.  rt_field = content  
  29.  rt_attr_uint = gid  
  30. }  
  31. 。。。。。。。。。。。省略。。。。。。。。。。。。。。  

六,启动sphinx

  1. //启动indexer  
  2. [root@localhost etc]# /usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/sphinx.conf --all  
  3. Coreseek Fulltext 4.0 [ Sphinx 1.11-id64-dev (r2540)]  
  4. Copyright (c) 2007-2011,  
  5. Beijing Choice Software Technologies Inc (http://www.coreseek.com)  
  6.   
  7.  using config file '/usr/local/sphinx/etc/sphinx.conf'...  
  8. indexing index 'test1'...  
  9. collected 4 docs, 0.0 MB  
  10. sorted 0.0 Mhits, 100.0% done  
  11. total 4 docs, 193 bytes  
  12. total 0.012 sec, 15540 bytes/sec, 322.08 docs/sec  
  13. indexing index 'test1stemmed'...  
  14. collected 4 docs, 0.0 MB  
  15. sorted 0.0 Mhits, 100.0% done  
  16. total 4 docs, 193 bytes  
  17. total 0.002 sec, 75097 bytes/sec, 1556.42 docs/sec  
  18. skipping non-plain index 'dist1'...  
  19. skipping non-plain index 'rt'...  
  20. total 6 reads, 0.000 sec, 0.1 kb/call avg, 0.0 msec/call avg  
  21. total 18 writes, 0.000 sec, 0.1 kb/call avg, 0.0 msec/call avg  
  22.   
  23. //启动searchd  
  24. [root@localhost etc]# /usr/local/sphinx/bin/searchd --config /usr/local/sphinx/etc/sphinx.conf  
  25. Coreseek Fulltext 4.0 [ Sphinx 1.11-id64-dev (r2540)]  
  26. Copyright (c) 2007-2011,  
  27. Beijing Choice Software Technologies Inc (http://www.coreseek.com)  
  28.   
  29. using config file '/usr/local/sphinx/etc/sphinx.conf'...  
  30. listening on all interfaces, port=9312  
  31. listening on all interfaces, port=9306  
  32.  precaching index 'test1'  
  33. precaching index 'test1stemmed'  
  34. WARNING: multiple addresses found for 'localhost', using the first one (ip=127.0.0.1)  
  35. precaching index 'rt'  
  36. precached 3 indexes in 0.001 sec  


转载请注明
作者:海底苍鹰
地址:http://blog.51yip.com/mysql/1641.html?utm_source=ld246.com

1 条评论

  1. 飯糰 留言

    您好,首先感謝您的分享有關如何架設文章,針對內容我有些問題想提問
    1. 您是否有測試coreseek與mmseq的中文分詞效果與差異
    2. 現在下載不到coreseek,是否還有好的解決方案可以對應有關中文分詞的問題??
    3. 是否有對window架設的文章可以參考

    以上打擾,盡請見諒,謝謝!!