Monday, November 14, 2011

A Quicky Queue

Q4m is a lovely looking package which brings queue semantics to MySQL rather than having to use another server (say RabbitQM) for your queues. However being a good open source project installation is a challenge. I'm not one to back away from a challenge though. So this is how I managed to install Q4m on my Mac. First some points of interest

  • Don't install it on your Mac. Create a virtual Linux box using VirtualBox
  • Install a decent distro on there like Debian (I'm assuming Debian 6; Squeeze)
  • Make sure MySQL 5.1 is installed
Assuming you've done that you will want to install the following packages

apt-get install mysql-server-5.1 libmysqld-dev libssl-dev g++ libmysqlclient-dev gcc4.1 libdata-compare-perl liblist-moreutils-perl

You will be asked for the root user password here. Keep it blank for the moment if you are using this guide as a way of evaluating q4m. If not then please set it with sensible password.

Then it's off to get the MySQL source (I've used 5.1.49 here so change according the version of MySQL you had installed) and q4m (0.9.5). Then we'll un-tar the archives

cd $HOME
wget http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.49.tar.gz
wget http://q4m.kazuhooku.com/dist/q4m-0.9.5.tar.gz

tar zxvf mysql-5.1.49.tar.gz
tar zxvf q4m-0.9.5-tar.gz

cd q4m-0.9.5

Once you're in this situation you are so nearly there :). You'll need to configure and then make like so

./configure --with-mysql="$HOME/mysql-5.1.49" --prefix="$HOME/mysql-5.1.49" CPPFLAGS="-I/usr/include/mysql"

make

Assuming everything worked you will want to install the plugin to MySQL, run some scripts and then some tests. Doing this as root will make things work.

su
cp src/.libs/libqueue_engine.so /usr/lib/plugin/.
cp support-files/q4m-forward /usr/bin/.
mysql --user=root < support_files/install.sql
services mysql restart

DBI='dbi:mysql:database=test;host=127.0.0.1;port=3306' DBI_USER='root' DBI_PASSWORD='' ./run_tests.pl

Assuming everything is good you should see a lot of messages flying up the screen and a 100% pass rate. Congratulations on install q4m. Go have a coffee; you deserve it.