zoukankan      html  css  js  c++  java
  • sphinx 安装 笔记

    系统版本:

    [root@localhost ~]# lsb_release  -a

    LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch

    Distributor ID: CentOS

    Description: CentOS release 5.5 (Final)

    Release: 5.5

    Codename: Final

     

    1.   下载 sphinx  

    [root@localhost ~]# cd  /usr/local/src

    wget http://www.sphinxsearch.com/downloads/sphinx-0.9.9.tar.gz -c 

    wget  http://cdn.mysql.com/Downloads/MySQL-5.1/mysql-5.1.66.tar.gz   -c

    解压:

    tar  zxvf  sphinx-0.9.9.tar.gz 

    tar zxvf  mysql-5.1.66.tar.gz 

    mkdir  /usr/local/src/mysql-5.1.66/storage/sphinx

    cp /usr/local/src/sphinx-0.9.9/mysqlse/*  /usr/local/src/mysql-5.1.66/storage/sphinx/

     

    进入MYSQL 编译安装MYSQL

    cd  mysql-5.1.66

    mkdir  /usr/local/mysql

    yum  -y  install   gcc gcc-c++    

    ./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-extra-charset=all --enable-thread-safe-client --enable-assembler --with-readline --with-big-tables --with-named-curses-libs=/usr/lib/libncursesw.so.5  --with-plugins=sphinx 

     

    出现错误:

    configure: error: unknown plugin: sphinx

     首先安装:

     yum  -y install  imake  automake  libtool

     

    然后  

     sh  BUILD/cleanup 

     sh  BUILD/autorun.sh 

     

    然后再编译:

     ./configure  -h

     

    底部出现:

       === Sphinx Storage Engine ===
      Plugin Name:      sphinx
      Description:      Sphinx Storage Engines
      Supports build:   static and dynamic
      Configurations:   max, max-no-ndb 

     

     

    然后重新编译MYSQL

      ./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-extra-charset=all --enable-thread-safe-client --enable-assembler --with-readline --with-big-tables --with-named-curses-libs=/usr/lib/libncursesw.so.5  --with-plugins=sphinx 

     

     

    make  &&  make install 

     

    [root@localhost mysql-5.1.66]# groupadd mysql  

    [root@localhost mysql-5.1.66]# useradd  -g mysql mysql

    [root@localhost mysql-5.1.66]# chown  -R root:mysql   /usr/local/mysql/

     

     /usr/local/mysql/bin/mysql_install_db   --user=mysql  --datadir=/usr/local/mysql/var

     

    [root@localhost mysql-5.1.66]# chown  -R mysql /usr/local/mysql/var

     

    [root@localhost mysql-5.1.66]# cp  support-files/mysql.server   /etc/init.d/

    [root@localhost mysql-5.1.66]# chmod  700  /etc/init.d/mysql.server 

    [root@localhost mysql-5.1.66]# cp support-files/my-medium.cnf  /etc/my.cnf

    [root@localhost mysql-5.1.66]# /etc/init.d/mysql.server  start

    shell> vi ~/.bash_profile
    修改PATH变量:
    PATH=$PATH:$HOME/bin:/usr/local/mysql/bin/
    让修改马上生效,可以执行如下命令:source ~/.bash_profile 

     

     

     

    第二天:

    [root@localhost mysql-5.1.66]# ldconfig   /usr/local/mysql/lib/mysql/

    [root@localhost mysql-5.1.66]# ldconfig   /usr/local/mysql/include/mysql

    [root@localhost mysql-5.1.66]# cd ..

    [root@localhost src]# ls 

    mysql-5.1.66  mysql-5.1.66.tar.gz  sphinx-0.9.9  sphinx-0.9.9.tar.gz

    [root@localhost src]# cd  sphinx-0.9.9

    [root@localhost sphinx-0.9.9]# mkdir /usr/local/sphinx

    [root@localhost sphinx-0.9.9]# ./configure  --prefix=/usr/local/sphinx/  --with-mysql=/usr/local/mysql

    [root@localhost sphinx-0.9.9]# make install

    [root@localhost sphinx-0.9.9]# cd /usr/local/sphinx/etc

    [root@localhost etc]# cp  sphinx.conf.dist  sphinx.conf

    [root@localhost etc]# vim sphinx.conf  对 sphinx 进行配置

    [root@localhost etc]# mysql -u mysql </usr/local/sphinx/etc/example.sql

    mysql> show databases;

     

     

     

    索引建立:

    /usr/local/sphinx/bin/indexer

          创建索引是报了一个这样的错误:/usr/local/sphinx/bin/indexer: error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: No such file or directory,主要原因是在上一篇中安装完mysql后没有设置环境变量,可以用下面方法解决:

    locate libmysqlclient    #运行该命令找到关于libmysqlclient.so.16的文件
    cp /usr/local/mysql/lib/mysql/libmysqlclient.so.16 /usr/lib/libmysqlclient.so.16    #然后把该文件的一个连接复制到在环境变量的文件夹/usr/lib/

     

     

    创建索引:

    /usr/local/sphinx/bin/indexer  --all

     

     

    测试:

    [root@localhost bin]# /usr/local/sphinx/bin/search test

     

    安装完成了!

     

     

    中文分词包:

    # cd /usr/local/src

    wget http://www.coreseek.cn/uploads/csft/3.2/coreseek-3.2.14.tar.gz  -c

    tar  zxvf  coreseek-3.2.14.tar.gz 

    cd  coreseek-3.2.14

    cd  mmseg-3.2.14

     ./configure  --prefix=/usr/local/mmseg

    报错:

     

    解决方法:

    aclocal
    libtoolize --force
    automake --add-missing
    autoconf
    autoheader
    make clean 

         然后再进行编译和安装:

    ./configure --prefix=/usr/local/mmseg
    make && make install

     

    把 mmseg 命令键入到环境变量中,然后运行 mmseg  

    [root@localhost mmseg-3.2.14]# ln -s /usr/local/mmseg/bin/mmseg /bin/mmseg

    [root@localhost mmseg-3.2.14]# mmseg

    Coreseek COS(tm) MM Segment 1.0

    Copyright By Coreseek.com All Right Reserved.

    Usage: mmseg <option> <file>

    -u <unidict>           Unigram Dictionary

    -r           Combine with -u, used a plain text build Unigram Dictionary, default Off

    -b <Synonyms>           Synonyms Dictionary

    -t <thesaurus>          Thesaurus Dictionary

    -h            print this help and exit

     

     

    安装完成

  • 相关阅读:
    Spring bean的自动装配
    JSP三大指令
    JSP九大内置对象
    Java异常的捕获顺序(多个catch)
    Integer.parseInt(s)和Integer.valueOf(s)之间的区别
    mysql忘记密码(MySQL5.7)
    java的四种内部类
    内存泄露查询
    深度优先和广度优先比较
    循环队列
  • 原文地址:https://www.cnblogs.com/rhythmK/p/2736873.html
Copyright © 2011-2022 走看看