Q4Mのインストールからキューの取り出し

MySQLのインストール

ソースの取得
$wget http://downloads.mysql.com/archives/mysql-5.1/MySQL-server-community-5.1.55-1.rhel5.x86_64.rpm
$wget http://downloads.mysql.com/archives/mysql-5.1/MySQL-client-community-5.1.55-1.rhel5.x86_64.rpm
インストール
$rpm -i MySQL-server-community-5.1.55-1.rhel5.x86_64.rpm
$rpm -i MySQL-client-community-5.1.55-1.rhel5.x86_64.rpm
----------------------------------------------
※インストール時に下記のようなエラーが出た場合。
error: Failed dependencies:
        MySQL conflicts with mysql-5.0.77-4.el5_6.6.x86_64

#現在rpmに入っているか確認
$rpm -qa | grep ^mysql
$mysql-5.0.77-4.el5_6.6

#削除する
yum remove mysql
yum remove mysql-libs mysqlclient15

#削除されたかの確認
$rpm -qa | grep ^mysql
---------------------------------------------
インストール後の確認
/etc/init.d/mysql start
mysql -u root
show variables like 'timed_mutexes';

mysql>  show variables like 'timed_mutexes';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| timed_mutexes | OFF   |
+---------------+-------+

Q4Mのインストール

ソースの取得
wget http://q4m.kazuhooku.com/dist/mysql-5.1.55-linux-x86_64-glibc23-without-fast-mutexes-q4m-0.9.5.tar.gz
インストール
tar zxvf mysql-5.1.55-linux-x86_64-glibc23-without-fast-mutexes-q4m-0.9.5.tar.gz
cd q4m-0.9.5-linux-unknown/
cp -f libqueue_engine.so /usr/lib64/mysql/plugin
install -m 755 support-files/q4m-forward /usr/bin/q4m-forward
cat support-files/install.sql | /usr/bin/mysql -uroot
mysql -u root
show plugins
mysql> show plugins;
+------------+----------+----------------+--------------------+---------+
| Name       | Status   | Type           | Library            | License |
+------------+----------+----------------+--------------------+---------+
| binlog     | ACTIVE   | STORAGE ENGINE | NULL               | GPL     |
| partition  | ACTIVE   | STORAGE ENGINE | NULL               | GPL     |
| ARCHIVE    | ACTIVE   | STORAGE ENGINE | NULL               | GPL     |
| BLACKHOLE  | ACTIVE   | STORAGE ENGINE | NULL               | GPL     |
| CSV        | ACTIVE   | STORAGE ENGINE | NULL               | GPL     |
| FEDERATED  | DISABLED | STORAGE ENGINE | NULL               | GPL     |
| MEMORY     | ACTIVE   | STORAGE ENGINE | NULL               | GPL     |
| InnoDB     | ACTIVE   | STORAGE ENGINE | NULL               | GPL     |
| MyISAM     | ACTIVE   | STORAGE ENGINE | NULL               | GPL     |
| MRG_MYISAM | ACTIVE   | STORAGE ENGINE | NULL               | GPL     |
| QUEUE      | ACTIVE   | STORAGE ENGINE | libqueue_engine.so | GPL     |
+------------+----------+----------------+--------------------+---------+

テーブルの作成+キューの取り出し

//キューテーブルの作成
create table image_magick_queue (
id int not null,
member_id int,
img_id int,
created_at datetime
)engine = queue;

//キューのinsert
insert into image_magick_queue(id,member_id,img_id,created_at)values(1,1,1,'2012-10-01');
insert into image_magick_queue(id,member_id,img_id,created_at)values(2,1,2,'2012-10-01');
insert into image_magick_queue(id,member_id,img_id,created_at)values(3,1,3,'2012-10-01');

//オーナーモードに移行
select queue_wait('image_magick_queue');
//1件取り出し
select * from image_magick_queue;
//処理済に変更
SELECT queue_end();