Installing Sphinx for MySQL 5.1

Posted by Nessa | Posted in ,, | Posted on July 21, 2007

12

This is probably one of the two things that drove me crazy over the last two weeks. The first was trying to get cPanel to stop being such a MySQL nazi, the second was getting Sphinx installed into MySQL 5.1 for one of the clients. I’ve installed it with 5.0 on Ubuntu before, but 5.1 with cPanel can be pretty torturous. After talking to the developer who was able to fill in the blanks, I’ve decided to write my own documentation on how to install Sphinx as a dynamic MySQL plugin for an existing MySQL 5.1 installation.

Before we start...

You need MySQL 5.1 installed to use the plugin feature. If you’re running on cPanel or other version-dependent software it’s a really really bad idea to install MySQL from source, so you’ll probably want to read this as a guide to upgrading via RPM. Also, this walkthrough is specific to MySQL 5.1.20 (beta), since that’s the latest release out at the time of this writing.

You also need to have root access, and a decent knowledge of Linux and MySQL.


Download the Sphinx binaries and MySQL 5.1.20 patch:


wget http://sphinxsearch.com/downloads/sphinx-0.9.7.tar.gz
tar -xvzf sphinx-0.9.7.tar.gz
cd sphinx-0.9.7/mysqlse/
wget http://v-nessa.net/imh_files/sphinxse097-mysql5120.patch


patch -p1 < sphinxse097-mysql5120.patch

I should point out that Andrew Aksyonoff (the developer) provided that patch to make Sphinx compatible with MySQL 5.1.20, but you’d probably have to check back on his site for version ugprades and such, esp. for newer versions of MySQL.

Now download the MySQL 5.1 sources — these are only going to be used to compile the Sphinx module:

cd /usr/src
wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.20-beta.tar.gz/from/http://mysql.he.net/
tar -xvzf mysql-5.1.20-beta.tar.gz
cd mysql-5.1.20-beta
cp -Rf /usr/src/sphinx-0.9.7/mysqlse/ storage/sphinx

Compile the Sphinx module against the MySQL 5.1 sources, but don’t install:

sh BUILD/autorun.sh
./configure
make

If you look in storage/sphinx/.libs you’ll see the loadable .so files that can plug in to MySQL easily. I suggest you copy them into a more permanent location:

mkdir /var/lib/mysql/plugins
cp storage/sphinx/.libs/ha_sphinx.* /var/lib/mysql/plugins

Now add this line to /etc/my.cnf and restart mysql:

plugin_dir=/var/lib/mysql/plugins

To install, log into the MySQL root and issue the ‘INSTALL PLUGIN’ command:

mysql -u root
mysql> INSTALL PLUGIN sphinx SONAME 'ha_sphinx.so';

To verify its installation, just run the ‘SHOW ENGINES’ command:

mysql> show engines;
| CSV | YES | CSV storage engine
.....
| SPHINX | YES | Sphinx storage engine 0.9.7


If you need further info, check out the doc-u-men-ta-tion.

Share and Enjoy:
  • Digg
  • DZone
  • del.icio.us
  • Technorati
  • Facebook
  • Google Bookmarks
  • StumbleUpon
  • Twitter
  • Sphinn
  • Mixx
  • blogmarks
  • Furl
  • Reddit
  • Slashdot
  • RSS

Related posts:

  1. Upgrading to MySQL 5.1.x on cPanel
  2. Installing Ruby on cPanel
  3. Installing IonCube loader with Zend Optimizer
  4. Installing suPHP on cPanel
  5. The [pretty much] Complete Guide to Installing ffMPEG and Audio Binaries

Comments (12)

Genius! That patch for mysql 5.1. worked like a charm – I’ve been fighting with that for hours :0)

Cheers!

Steve

Thank you very much,

Hi! great page! On 5.1.28-rc and sphinx 0.9.8 the patch is not needed anymore and if you work on Debian you’ll want to use alien to port the RPMs…

Things change over time but this still a great guide to get this thing running quick :)

great tip!
but when I make,the following error occured,
ha_sphinx.cc:273: error: extra qualification ‘CSphSEFilter::’ on member ‘CSphSEFilter’
ha_sphinx.cc:283: error: extra qualification ‘CSphSEFilter::’ on member ‘CSphSEFilter’
ha_sphinx.cc: In function ‘bool ParseUrl(CSphSEShare*, TABLE*, bool)’:
ha_sphinx.cc:651: warning: deprecated conversion from string constant to ‘char*’
ha_sphinx.cc:652: warning: deprecated conversion from string constant to ‘char*’
ha_sphinx.cc:685: warning: deprecated conversion from string constant to ‘char*’
ha_sphinx.cc:697: warning: deprecated conversion from string constant to ‘char*’
ha_sphinx.cc: In constructor ‘CSphSEQuery::CSphSEQuery(const char*, int, const char*)’:
ha_sphinx.cc:828: warning: deprecated conversion from string constant to ‘char*’
ha_sphinx.cc:828: warning: deprecated conversion from string constant to ‘char*’
ha_sphinx.cc:828: warning: deprecated conversion from string constant to ‘char*’
ha_sphinx.cc:828: warning: deprecated conversion from string constant to ‘char*’
make[2]: *** [ha_sphinx_la-ha_sphinx.lo] Error 1
make[2]: Leaving directory `/usr/src/mysql-5.1.28-rc/storage/sphinx’
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/src/mysql-5.1.28-rc/storage’
make: *** [all-recursive] Error 1
how to fix that?
Shore

use 0.9.8 version and it’s ok,
except:
mysql> install plugin sphinx soname ‘ha_sphinx.so.0′;
ERROR 1126 (HY000): Can’t open shared library ‘ha_sphinx.so.0′ (errno: 0 API version for STORAGE ENGINE plugin is too different)

Hi nessa, do you have any tutorial on how to use sphinx se ? or do you mind to share your experience in implementing sphin se with mysql ? I really need you help.

hey nessa – any update to the patch file? it sounds very useful but doesn’t work with sphinx-0.9.8.1 and on…

hmm i can’t get it to work for 0.9.8 either…

4 out of 4 hunks FAILED — saving rejects to file ha_sphinx.cc.rej

yea… trying to get this going with mysql 5.1.32 ( from dotdeb ) and sphinx 0.9.8.1 ( sphinxse ).

everything builds, I See the storage engine, but when I go to create a table with the sphinxse, mysql crashes.

it looks like ha_sphinx::open is using older parameters that have changed in mysql 5.1.32 :(

any help, or an updated patch would be GREAT ! ( Cant find anything at Andrews Site )

I followed the directions exactly except I’m using sphinx 0.9.8.1 and MySQL 5.1.31. The only problem is I’m not getting an “so” file when make is all done with MySQL.

It was really awesome…. I was struggling with it for weeks together.. Thanks a lot Nessa…

Hey,

Did anyone solve this with the latest sphinx 1.10?

I’m thinking about trying, but to me Linux is like a flying saucer, so I thought I’d ask first.

Post a comment