LoginSignup
2
3

More than 5 years have passed since last update.

CentOS 7 に Q4M をインストールする

Posted at

CentOS 7環境に Q4M をインストールしてみた。

# cat /etc/redhat-release
CentOS Linux release 7.0.1406 (Core)
# uname -a
Linux q4m 3.10.0-123.el7.x86_64 #1 SMP Mon Jun 30 12:09:22 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

といっても以下のスクリプトを使わせて貰っただけ。

Q4Mを簡単に導入する方法 for MySQL 5.6 - blog.nomadscafe.jp
http://blog.nomadscafe.jp/2014/01/q4m-for-mysql-56.html

スクリプトの実行前に以下のパッケージのインストールが必要。

# yum install -y git gcc gcc-c++ bison perl-Data-Dumper

後は git clone して setup.sh を実行すれば OK。

# cd /usr/local/src
# git clone git://github.com/kazeburo/mysetup.git
# cd mysetup/q4m_mysql56
# sh ./setup.sh

cmake, libaio-devel, ncurses-devel は入っていなければこのスクリプトが自動的に yum から入れてくれる。
しばらく待つとビルドが完了し mysql が起動してくる。

ただ、CentOS 7 だと起動スクリプトが上手く動かないっぽい。
インストール完了後、以下の表示の所で止まってしまう。

New default config file was created as /usr/local/q4m/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server

Starting q4m (via systemctl):

Ctrl-C して ps すると mysql のプロセスは上がっているが、確認してみると Engine がインストールされていない状態になってしまっている。

これは setup.sh 内の /etc/init.d/q4m start している所で実行が止まってしまうため、その後で起動後に実行している install.sql が実行されていないことが原因。

install.sql は以下にあった。

/usr/local/src/mysql-5.6.20/storage/q4m/support-files/install.sql

CentOS 7 の起動スクリプトとか全然わからないので取り敢えず直接 install.sql を実行する。

mysql に入ってスクリプトを読込み。

# /usr/local/q4m/bin/mysql -uroot
mysql> source /usr/local/src/mysql-5.6.20/storage/q4m/support-files/install.sql

これで QUEUE エンジンがインストールされた。

mysql>show engines;
+------------+---------+-----------------------------------------------------------+--------------+------+------------+
| Engine     | Support | Comment                                                   | Transactions | XA   | Savepoints |
+------------+---------+-----------------------------------------------------------+--------------+------+------------+
| MEMORY     | YES     | Hash based, stored in memory, useful for temporary tables | NO           | NO   | NO         |
| MRG_MYISAM | YES     | Collection of identical MyISAM tables                     | NO           | NO   | NO         |
| MyISAM     | DEFAULT | MyISAM storage engine                                     | NO           | NO   | NO         |
| QUEUE      | YES     | Queue storage engine for MySQL                            | NO           | NO   | NO         |
| CSV        | YES     | CSV storage engine                                        | NO           | NO   | NO         |
+------------+---------+-----------------------------------------------------------+--------------+------+------------+
5 rows in set (0.00 sec)

mysql>show plugins;
+-----------------------+--------+----------------+--------------------+---------+
| Name                  | Status | Type           | Library            | License |
+-----------------------+--------+----------------+--------------------+---------+
| binlog                | ACTIVE | STORAGE ENGINE | NULL               | GPL     |
| mysql_native_password | ACTIVE | AUTHENTICATION | NULL               | GPL     |
| mysql_old_password    | ACTIVE | AUTHENTICATION | NULL               | GPL     |
| sha256_password       | ACTIVE | AUTHENTICATION | NULL               | GPL     |
| MEMORY                | ACTIVE | STORAGE ENGINE | NULL               | GPL     |
| MyISAM                | ACTIVE | STORAGE ENGINE | NULL               | GPL     |
| CSV                   | ACTIVE | STORAGE ENGINE | NULL               | GPL     |
| MRG_MYISAM            | ACTIVE | STORAGE ENGINE | NULL               | GPL     |
| partition             | ACTIVE | STORAGE ENGINE | NULL               | GPL     |
| QUEUE                 | ACTIVE | STORAGE ENGINE | libqueue_engine.so | GPL     |
+-----------------------+--------+----------------+--------------------+---------+
10 rows in set (0.00 sec)

試しに適当な DB を作って QUEUE Engine を使ったテーブルを作ってみる。
テーブルの DDL は以下の記事のものを使用させて頂いた。

第10回 ジョブキューで後回し大作戦―TheSchwartz,Qudo,Q4M(3):Perl Hackers Hub|gihyo.jp … 技術評論社
http://gihyo.jp/dev/serial/01/perl-hackers-hub/001003

mysql>CREATE DATABASE example_db DEFAULT CHARACTER SET utf8;
mysql>use example_db
Database changed

root@localhost mysql>CREATE TABLE welcome (
    ->     nickname       varchar(255) NOT NULL,
    ->     email          varchar(255) NOT NULL,
    ->     created_on int(10) unsigned NOT NULL
    -> ) ENGINE=QUEUE DEFAULT CHARSET=utf8;
Query OK, 0 rows affected, 2 warnings (0.00 sec)

root@localhost mysql>show create table welcome\G
*************************** 1. row ***************************
       Table: welcome
Create Table: CREATE TABLE `welcome` (
  `nickname` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `created_on` int(10) unsigned NOT NULL
) ENGINE=QUEUE DEFAULT CHARSET=utf8
1 row in set (0.00 sec)

起動スクリプトさえ上手く動くようになれば CentOS 7 でもお手軽に環境構築できそう。

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3