为 MySQL 5.5.x 编译安装 SphinxSE

首先:关于什么是SphinxSE,请前往学习了解;如果需要Windows版本,请前往查看下载


然后,你可以从头全新编译安装MySQL,并启用SphinxSE存储插件;也可以将该插件安装到已经安装的MySQL中。

请仔细查看下面的文档,选择适合自己的安装方式一或者安装方式二。

coreseek-4.0.1-beta开始,已经提供了对MySQL5.5.8及以上版本的支持。如果使用Sphinx原始SVN版本,请前往下载支持MySQL5.5的补丁文件

coreseek-4.1-beta/Sphinx-2.0.1-beta开始,已经提供了对MySQL5.5.15及以上版本的支持。


Coreseek-4.0.1-beta/为MySQL 5.5提供SphinxSE支持的安装指南:

  • 软件版本:

    系统软件:cmake libncurses5-dev bison

    MySQL:MySQL 5.5.8/5.5.9

    Coreseek:coreseek-4.0.1-beta
  • MySQL 5.5 基本设置编译:(用于为后续安装做准备)

    #下载coreseek-4.0.1:前往下载
    #下载 mysql-5.5.8.tar.gz , mysql-5.5.9.tar.gz , 或者更新版本的mysql-5.5:前往下载
    #以下指令中的VERSION表示MySQL的版本,例如:5.5.8,或者5.5.9
    $ tar xzvf coreseek-4.0.1.tar.gz
    $ tar xzvf mysql-VERSION.tar.gz
    $ cp -R coreseek-4.0.1/csft-4.0.1/mysqlse mysql-VERSION/storage/sphinx
    $ cd mysql-VERSION
    $ cmake . -DCMAKE_BUILD_TYPE=Release -DWITH_SPHINX_STORAGE_ENGINE=1
    #如要查看cmake可用参数,请执行:cmake . -LH
    $ make
    
    #make中途会显示:
    
    Scanning dependencies of target sphinx
    [ 30%] Building CXX object storage/sphinx/CMakeFiles/sphinx.dir/ha_sphinx.cc.o
    Linking CXX shared module ha_sphinx.so
    [ 30%] Built target sphinx
    
  • 安装方式一、#从头全新编译安装MySQL,并启用SphinxSE存储插件:

    #首先执行:MySQL 5.5 基本设置编译过程
    $ make install
    #make install中途会显示:
    
    [ 30%] Built target sphinx
    
    $ cd /usr/local/mysql $ mkdir -p /var/log/mysql /usr/local/mysql/etc $ cp support-files/my-medium.cnf /usr/local/mysql/etc/my.cnf #然后修改/etc/my.cnf
    [mysqld]
    basedir         = /usr/local/mysql
    datadir         = /usr/local/mysql/data
    
    $ chown -R mysql . $ chgrp -R mysql . $ ./scripts/mysql_install_db --basedir=/usr/local/mysql --user=mysql $ chown -R root . $ chown -R mysql data $ ./bin/mysqld_safe --defaults-extra-file=/usr/local/mysql/etc/my.cnf --user=mysql & $ mysql -uroot mysql>install plugin sphinx soname "ha_sphinx.so"; mysql>show engines; #ENGINE列表显示出SPHINX表示安装成功
  • 安装方式二、#将SphinxSE安装到已经安装的MySQL 5.5中:

    #首先执行:MySQL 5.5 基本设置编译过程
    #特别注意:需要选择与当前已安装的MySQL 5.5对应的版本进行编译
    $ cp storage/sphinx/ha_sphinx.so /path_to_your_mysql_5.5/lib/plugin
    $ mysql -uroot -p
    mysql>install plugin sphinx soname "ha_sphinx.so";
    mysql>show engines;
    #ENGINE列表显示出SPHINX表示安装成功
    



Sphinx SVN版本为MySQL 5.5提供SphinxSE支持的安装指南:

  • 因为Sphinx SVN版本尚未提供对MySQL 5.5的支持,需要下载MySQL 5.5补丁并打上才可提供支持。
  • Software :

    System software : cmake libncurses5-dev bison
    MySQL : MySQL 5.5.8/5.5.9
    Sphinx : http://sphinxsearch.googlecode.com/svn/trunk
    Patch : Sphinx_1.11-dev_sphinxse_mysql-5.5.8.diff, Sphinx_1.11-r2652-dev_sphinxse_mysql-5.5.8.diff
    
  • Install SphinxSE from Sphinx SVN

    #ready:
    #download mysql from : http://www.mysql.com/downloads/mirror.php?id=401062#mirrors
    $ wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.9.tar.gz/from/http://mysql.he.net/
    $ wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.8.tar.gz/from/http://mysql.he.net/
    $ svn co http://sphinxsearch.googlecode.com/svn/trunk sphinx-trunk
    $ wget http://www.coreseek.cn/uploads/csft/patch/Sphinx_1.11-dev_sphinxse_mysql-5.5.8.diff
    $ wget http://www.coreseek.cn/uploads/csft/patch/Sphinx_1.11-r2652-dev_sphinxse_mysql-5.5.8.diff
    $ tar xzvf mysql-5.5.8.tar.gz
    $ tar xzvf mysql-5.5.9.tar.gz
    
    #patch:
    $ cd sphinx-trunk
    $ patch -p0 < ../Sphinx_1.11-dev_sphinxse_mysql-5.5.8.diff
    $ cp -R mysqlse ../mysql-5.5.9/storage/sphinx
    $ rm mysqlse/CMakeLists.txt mysqlse/ha_sphinx.cc mysqlse/ha_sphinx.h
    $ svn up -r 2652
    $ patch -p0 < ../Sphinx_1.11-r2652-dev_sphinxse_mysql-5.5.8.diff
    $ cp -R mysqlse ../mysql-5.5.8/storage/sphinx
    
    
    #build:
    $ cd ../mysql-5.5.9
    $ cmake . -DCMAKE_BUILD_TYPE=Release -DWITH_SPHINX_STORAGE_ENGINE=1
    $ make
    $ ls -l storage/sphinx/ha_sphinx.*
    #you'll see ha_sphinx.so.
    
    $ cd ../mysql-5.5.8
    $ cmake . -DCMAKE_BUILD_TYPE=Release -DWITH_SPHINX_STORAGE_ENGINE=1
    $ make
    $ ls -l storage/sphinx/ha_sphinx.*
    #you'll see ha_sphinx.so.
    
    #tip:
    #now ,you can run "make install" to install mysql at /usr/local/mysql.
    #or , you can copy ha_sphinx.so to the patch lib/plugin/ in your mysql install directory.
    
    #install plugin:
    #login mysql with user root
    mysql>INSTALL PLUGIN sphinx SONAME "ha_sphinx.so"
    mysql>SHOW ENGINES;
    #you'll see SPHINX in the ENGINE list.
    



SphinxSE Usage (SphinxSE基本使用)