MySQL + Q4M インストール ハマリどころまとめ

Q4Mをインストールしたときの作業メモ。
とエラーが数回でたので回避方法メモ。

MySQLのインストール

MySQLのバージョンは5.1以上でないといけないみたいです。
今回はソースからインストールしました。

$ cd /usr/local/src
$ wget http://www-jp.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.46.tar.gz/from/http://ftp.iij.ad.jp/pub/db/mysql/
$ tar zxf mysql-5.1.46.tar.gz
$ cd mysql-5.1.46
$ ./configure \
  --prefix=/usr/local/mysql \
  --with-mysqld-user=mysql \
  --with-unix-socket-path=/tmp/mysql.sock \
  --witad-safe-client \
  --with-extra-charsets=all \
  --with-big-tables \
  --with-readline \
  --with-plugins=max
$ make 
$ make test
$ sudo make install

configureのオプションは色々なのでこれはただの例です。

あとは初期DBを作って起動させておきます。

$ cp -ip /usr/local/src/mysql-5.1.46/support-files/my-large.cnf /etc/my.cnf 
$ cd /usr/local/mysql/
$ sudo ./bin/mysql_install_db 
$ sudo chown -R mysql:mysql var
$ sudo ./bin/mysqld_safe &

これでとりあえず起動できます。

q4mのインストール

公式からダウンロードしてソースからインストします

$ cd /usr/local/src
$ wget http://q4m.31tools.com/dist/q4m-0.9.2.tar.gz
$ tar zxf q4m-0.9.2.tar.gz
$ cd q4m-0.9.2
$ ./configure --prefix=/usr/local/mysql --with-mysql=/usr/local/src/mysql-5.1.46
$ make 
$ make test
$ sudo make install
$ /usr/local/mysql/bin/mysql -uroot < support-files/install.sql 

これでインストールできました。
同封されているrun_tests.plでテストしたり、
MySQLにログインしてshow enginesを打ってインストールできたか確認できます。

mysql> show engines;
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine     | Support | Comment                                                        | Transactions | XA   | Savepoints |
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| ndbcluster | NO      | Clustered, fault-tolerant tables                               | NULL         | NULL | NULL       |
| MRG_MYISAM | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
| QUEUE      | YES     | Queue storage engine for MySQL                                 | NO           | NO   | NO         |
| CSV        | YES     | CSV storage engine                                             | NO           | NO   | NO         |
| MEMORY     | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
| FEDERATED  | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |
| ARCHIVE    | YES     | Archive storage engine                                         | NO           | NO   | NO         |
| InnoDB     | YES     | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
| MyISAM     | DEFAULT | Default engine as of MySQL 3.23 with great performance         | NO           | NO   | NO         |
| BLACKHOLE  | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
10 rows in set (0.00 sec)

mysql> quit

EngineにQUEUEが追加されてる。

ハマリどころ

2つほどエラーがでました。

q4mのmakeでエラー

エラー内容は↓な感じです。

ha_queue.cc:32:24: error: mysql_priv.h: No such file or directory
ha_queue.cc:46:4: error: #error "support for 64-bit file offsets is mandatory"
queue_cond.h: In member function 'queue_cond_t::value_t queue_cond_t::pow_func::bop(const queue_cond_t::value_t&, const queue_cond_t::value_t&) const':
queue_cond.h:274: error: 'pow' was not declared in this scope
queue_cond.h: In member function 'void queue_cond_t::set_value(size_t, const queue_cond_t::value_t&)':
queue_cond.h:289: error: 'assert' was not declared in this scope
queue_cond.h: In member function 'queue_cond_t::value_t queue_cond_t::get_value(size_t) const':
queue_cond.h:301: error: 'assert' was not declared in this scope
ha_queue.h: At global scope:
ha_queue.h:39: error: 'uchar' does not name a type
ha_queue.h:72: error: ISO C++ forbids declaration of 'uchar' with no type
ha_queue.h:72: error: expected ';' before '*' token
ha_queue.h:73: error: expected `;' before 'static'
ha_queue.h:79: error: 'my_off_t' does not name a type
ha_queue.h:93: error: 'my_off_t' does not name a type
ha_queue.h:94: error: 'my_off_t' has not been declared
ha_queue.h: In constructor 'queue_row_t::queue_row_t(unsigned int, unsigned int)':
ha_queue.h:55: error: 'assert' was not declared in this scope
ha_queue.h:56: error: 'int4store' was not declared in this scope
ha_queue.h: In member function 'unsigned int queue_row_t::size() const':
ha_queue.h:60: error: 'uint4korr' was not declared in this scope
<省略>
make[2]: *** [libqueue_engine_la-ha_queue.lo] Error 1
make[2]: Leaving directory `/usr/local/src/q4m-0.9.2/src'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/usr/local/src/q4m-0.9.2/src'
make: *** [all-recursive] Error 1

こんな感じです。"error: mysql_priv.h: No such file or directory"と言っているので
単純なヘッダーファイルが見つからないエラーですが、これはconfigureのオプションが間違っていました。
このときのconfigureオプションは

./configure --with-mysql=/usr/local/mysql

としていて--with-mysqlにMySQLのインストールパスを指定していました。
これがまったくの勘違いで--with-mysqlへはソースファイルのパスを指定しなければなりません。
(てかインストールマニュアル読めよ俺)
インストールマニュアルには

--with-mysql=mysql-source-dir
set the directory of MySQL source code (required)
--prefix=mysql-dir
set the directory under which MySQL 5.1 is installed (optional)

と書いてあるのでMySQLのインストールパスは--prefixで指定します。
なので正しくはこうですね。

./configure --prefix=/usr/local/mysql --with-mysql=/usr/local/src/mysql-5.1.46

これで上記エラーは解消できました。

install.sqlしたときのエラー

無事make installまで終わって最後にinstall.sqlを実行したときにエラーがでました。

$ /usr/local/mysql/bin/mysql -uroot < support-files/install.sql 
ERROR 1289 (HY000): The 'plugin' feature is disabled; you need MySQL built with 'HAVE_DLOPEN' to have it working

これはMySQLインストール時のconfigureオプションに"--disable-shared"を付加してた為です。
また、"--with-mysqld-ldflags=-all-static" "--with-client-ldflags=-all-static"辺りのオプションを付けてると
同様のエラーになるかもしれません(こっちは未検証)
どうでもいいけど最後の最後でエラーでてMySQLのconfigureからやり直しって精神的にパネェっす。