日々の覚書: InnoDB
Monitorの仲間たち(InnoDBエンジン本体のアレ) で"CREATE TABLE
innodb_monitor .."的なものを紹介しました。あれから2年。
というかよく調べてみたら1年前。
MySQL :: MySQL 5.7 Release Notes :: Changes in
MySQL 5.7.4 (2014-03-31, Milestone 14)
InnoDB: New global configuration parameters, innodb_status_output
and innodb_status_output_locks, allow you to dynamically enable
and disable the standard InnoDB Monitor and InnoDB Lock Monitor
for periodic output. Previously, enabling and disabling these
monitors for periodic output required creating and dropping
specially named tables (innodb_monitor and innodb_lock_monitor).
For additional information, see …
MySQL 5.7.6-m16で導入されたgenerated
columnについてメモ。タイトルでしゃらっと関数インデックスとか言っているけれど、俺はその機能を知らない。
MySQL :: MySQL 5.7 Reference Manual :: 13.1.14
CREATE TABLE Syntax
generated
columnはあるカラムの値に関数を噛ませた結果をカラムとして実体化できたり、実体化せずに毎回計算できたりするカラム定義のことらしくて、
mysql57> CREATE TABLE t1 (num int, val varchar(32)) Engine = MyISAM;[さらに読む]
Query OK, 0 rows affected (0.01 sec)
mysql57> INSERT INTO t1 SET num = 1, val = 'one';
Query OK, 1 row affected (0.00 sec)
mysql57> SELECT * FROM t1;
+-----+------+
| num | val |
+-----+------+
| 1 | …
MySQL SlapをNDB対して実行して、メモリー割り当て変化の簡単な確認
[root@misc bin]# /usr/local/mysql/bin/mysqlslap --no-defaults --create-schema=SLAP --engine=ndb --auto-generate-sql --auto-generate-sql-add-autoincrement --engine=ndb --number-int-cols=3 --number-char-cols=5 --concurrency=10 --auto-generate-sql-write-number=10000 --auto-generate-sql-execute-number=10000 --auto-generate-sql-load-type=mixed -h 192.168.56.114 -u admin -p
Enter password:
Benchmark
Running for engine ndb
Average number of seconds to run all queries: 135.323 seconds
Minimum number of seconds to run all queries: 135.323 seconds
Maximum number of seconds to run all queries: 135.323 seconds
Number of clients running queries: 10
Average number of queries per client: 10000
[root@misc bin]#
Node, …
[さらに読む]
日々の覚書: MySQL
5.7.6は--secure-file-privを設定してないとWarningを吐くようになった のちょっと続き。
--secure-file-priv
そのものについては↑の記事を読んでいただけると幸い。LOAD DATA INFILEやSELECT .. INTO
OUTFILEの動きを制限する。
ドキュメントのsysvarのところに書いてある けれど、
* -DINSTALL_LAYOUT=STANDALONE, WIN でビルドされた場合は暗黙のデフォルトなし
* -DINSTALL_LAYOUT=DEB, RPM, SLES, SVR4
でビルドされた場合は"/var/lib/mysql-files" …
今回は、検証用に2台のノードにMySQL Clusterを導入してみました。
検証目的なので2台で設定してますが、本番ではデータノードは分けた方が良さそうです。
————————-
Node1: 192.168.56.114
Node2: 192.168.56.115
————————-
mysql> select * from ndbinfo.nodes; +---------+--------+---------+-------------+-------------------+ | node_id | uptime | status | start_phase | config_generation | +---------+--------+---------+-------------+-------------------+ | 1 | 3994 | STARTED | 0 | 1 | | 2 | 3948 | STARTED | 0 | 1 | +---------+--------+---------+-------------+-------------------+ 2 rows in set (0.05 sec) mysql> mysql> select * from ndbinfo.arbitrator_validity_detail; +---------+------------+------------------+---------------+-----------+ | node_id | arbitrator | arb_ticket …[さらに読む]
MySQL 監査ログのローテション
MySQL Enterprise Auditで取得した監査ログをMySQL Utilitiesを利用して、
定期的にローテーション出来るかどうか確認してみました。
Audit Logのローテーションとしては、以下の2パターンがあります。
1) ログサイズによる自動ローテーション
sysvar_audit_log_rotate_on_size
If the audit_log_rotate_on_size value is greater than 0,
the audit log plugin closes and reopens its log file
if a write to the file causes its size to exceed this value.
2) …
[さらに読む]
MySQL :: MySQL 5.7 Release Notes :: Changes in
MySQL 5.7.6 (2015-03-09, Milestone 16) から抜粋。
MySQL Server from Community Edition distributions now tries to
deploy with SSL support enabled automatically if no SSL options
are specified explicitly and it finds any of the ca.pem,
server-cert.pem, and server-key.pem files in the data directory.
In this case, clients can use a secure connection merely by
specifying --ssl on the command line.
今までは--ssl指定するとついでに--ssl-ca, --ssl-cert,
--ssl-keyを指定してやらないといけなかったのが、datadirからその辺のファイルが見つかれば指定しなくてもよしなにやってくれるらしい。
あと、サーバー側の--sslはデフォルトで有効状態に。
というわけで、 …
MySQL 5.7.5のmysql_install_dbだと
$ bin/mysql_install_db --no-defaults --basedir=./ --datadir=./test_575 -v
2015-03-12 11:23:45 [NOTE] Creating data directory ./test_575
2015-03-12 11:23:45 [NOTE] Generating random password to /root/.mysql_secret...done.
2015-03-12 11:23:45 [NOTE] Executing /opt/mysql/5.7.5/bin/mysqld --no-defaults --bootstrap --datadir=./test_575 --lc-messages-dir=./share --lc-messages=en_US --basedir=.
2015-03-12 11:23:46 [NOTE] Creating system tables...done.
2015-03-12 11:23:46 [NOTE] Filling system tables with data...done.
2015-03-12 11:23:47 [NOTE] Filling help table with data...done.
2015-03-12 11:23:47 [NOTE] Creating default user root@localhost
2015-03-12 11:23:47 [NOTE] Creating default proxy root@localhost
2015-03-12 11:23:48 [NOTE] Success!
…
日々の覚書: プレビュー "MySQL 5.7.6のInnoDB日本語全文検索 MeCab
Plugin" に引き続き、今度はngramなトークナイザー。ドキュメントは ここ 。
MeCab Pluginと違って特にINSTALL
PLUGINとかせずに即使える。
mysql> ALTER TABLE articles ADD FULLTEXT KEY (title, content) WITH PARSER ngram;
Query OK, 0 rows affected (6 hours 25 min 20.67 sec)
Records: 0 Duplicates: 0 Warnings: 0
( д ) ゚ ゚ 6時間半!? …
取り敢えずダミーデータを突っ込んだテーブルを自己結合しつつぐりぐりソートしてテンポラリーテーブルを作らせる。
$ perl -M"Digest::MD5 'md5_hex'" -e 'for ($n = 1; $n <= 1000000; $n++) { printf("%d\t%s\n", $n, md5_hex($n)); }' > /tmp/md5
mysql> create table t1 (num serial, val varchar(32));
Query OK, 0 rows affected (0.01 sec)
mysql> LOAD DATA INFILE '/tmp/md5' INTO TABLE t1;
Query OK, 1000000 rows affected (8.88 sec)
Records: 1000000 Deleted: 0 Skipped: 0 Warnings: 0
mysql> explain SELECT * FROM t1 LEFT JOIN t1 AS t2 USING(num) LEFT JOIN t1 AS t3 USING(num) ORDER BY t1.val ASC, t2.val DESC, t3.val ASC;
+----+-------------+-------+------------+--------+---------------+------+---------+-----------+--------+----------+---------------------------------+
| id | select_type | table | partitions | type | possible_keys | key | …[さらに読む]