MySQL innodb-memcached on OS X
OS X のMySQLで innodb-memcached を試す。
環境
OS X 10.10.5
公式ドキュメント
https://dev.mysql.com/doc/refman/5.6/ja/innodb-memcached-prereqs.html
https://dev.mysql.com/doc/refman/5.6/ja/innodb-memcached-installing.html
libmemcached.so image not found
1番楽そうなbrew install で試す
mysqlをインストールして、innnodb_memcached_config.sqlを流し込む、プラグインを有効にする
% brew install mysql % mysql -u root < /usr/local/Cellar/mysql/5.7.9/share/mysql/innodb_memcached_config.sql % mysql -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.7.9 Homebrew Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> SELECT * FROM innodb_memcache.containers\G *************************** 1. row *************************** name: aaa db_schema: test db_table: demo_test key_columns: c1 value_columns: c2 flags: c3 cas_column: c4 expire_time_column: c5 unique_idx_name_on_key: PRIMARY 1 row in set (0.00 sec) mysql> SELECT * FROM test.demo_test; +----+--------------+------+------+------+ | c1 | c2 | c3 | c4 | c5 | +----+--------------+------+------+------+ | AA | HELLO, HELLO | 8 | 0 | 0 | +----+--------------+------+------+------+ 1 row in set (0.00 sec) mysql> INSTALL PLUGIN daemon_memcached soname "libmemcached.so"; ERROR 1126 (HY000): Can't open shared library '/usr/local/Cellar/mysql/5.7.9/lib/plugin/libmemcached.so' (errno: 2 dlopen(/usr/local/Cellar/mysql/5.7.9/lib/plugin/libmemcached.so, 2): image not found)
エラー。libmemcached.soが存在しない。lsコマンドでディレクトリをみる限り確かになかった。他をfindしても無い
API version for DAEMON plugin is too different
MySQL :: Download MySQL Community Server
上記のURLのソースコードをダウンロードすればlibmemcached.soは含まれてるけど、バージョンが5.7.10。
brew install mysql でインストールされるmysqlは 5.7.9。
なのでlibmemcached.soを/usr/local/Cellar/mysql/5.7.9/lib/plugin/ディレクトリにコピーしてもエラー。
mysql> INSTALL PLUGIN daemon_memcached soname "libmemcached.so"; ERROR 1126 (HY000): Can't open shared library 'libmemcached.so' (errno: 0 API version for DAEMON plugin is too different)
解決方法
MySQL :: Download MySQL Community Server
dmgでインストールしたmysqlならlibmemcached.soが含まれる。
あとは公式ドキュメント通りの手順でOK
dmgダウンロード後、クリックしてインストール開始。終了ポップアップにrootパスワードが表示されるのでメモっておく
/usr/local/mysql/bin/mysql_secure_installation /usr/local/mysql/bin/mysqld_safe /usr/local/mysql/bin/mysql -u root -p < /usr/local/mysql/share/innodb_memcached_config.sql /usr/local/mysql/bin/mysql -u root -p mysql> INSTALL PLUGIN daemon_memcached soname "libmemcached.so"; Query OK, 0 rows affected (0.01 sec)
telnetでset, get試す
telnet 127.0.0.1 11211 Trying 127.0.0.1... Connected to localhost set key1 0 0 5 abcde STORED get key1 VALUE key1 0 5 abcde END get key2 END