90
Mac miniで作るMySQL Cluster Mac miniを使った理由と何をやっているか! MySQL Cluster Casual Talks #2

Mac miniで作るMySQL Cluster

Embed Size (px)

Citation preview

Page 1: Mac miniで作るMySQL Cluster

Mac miniで作るMySQL ClusterMac miniを使った理由と何をやっているか!

MySQL Cluster Casual Talks #2

Page 2: Mac miniで作るMySQL Cluster

まず始めに、自己紹介をさせてください!

Page 3: Mac miniで作るMySQL Cluster

プロフィール名前 : 室田 和大

会社名 : CYBERWEB ENGINNERING

通称 : CWE

役職 : CEO

主な業務 : OpenSourceを使ったIT関係の仕事

Page 4: Mac miniで作るMySQL Cluster

CYBERWEB ENGINNERING URL

http://www.cw-e.jp

Page 5: Mac miniで作るMySQL Cluster

OpenPNEの開発しています

• 日本で最大級のシェアを持つSNSのmixiにそっくりなインターフェースを持つ、オープンソースのSNSのソフトウェア

• OpenPNE 1系の時から色々と参加

Page 6: Mac miniで作るMySQL Cluster

OpenPNEでは!

Page 7: Mac miniで作るMySQL Cluster

OpenPNEでは

• ライトユーザ向けのOpenPNE 2系の後継になる。OpenPNE 2 CEの全体の開発をしています。

Page 8: Mac miniで作るMySQL Cluster

開発の方は少々忙しくて停滞していますが…

Page 9: Mac miniで作るMySQL Cluster

忙しいですが、

緊急性のあるものには対応をできるようには

一応しています。

Page 10: Mac miniで作るMySQL Cluster

OpenPNE 2 CE http://op2ce.org

Page 11: Mac miniで作るMySQL Cluster

現在は…

Page 12: Mac miniで作るMySQL Cluster

先ほど紹介した自社の経営の他に、美容業界のコンサルタントの

株式会社ケイアートファクトリーにてIT事業部でも仕事をしています。

Page 13: Mac miniで作るMySQL Cluster

株式会社ケイアートファクトリー URL

http://www.k-art-factory.jp

Page 14: Mac miniで作るMySQL Cluster

こんな感じで、

特殊な業界でのお仕事もお手伝いしておりますが、

これからもよろしくお願い致します。

Page 15: Mac miniで作るMySQL Cluster

それでは本題へ!

Page 16: Mac miniで作るMySQL Cluster

今回、話す経緯となった理由!

Page 17: Mac miniで作るMySQL Cluster

オープンソースが好きだからです!

Page 18: Mac miniで作るMySQL Cluster

主にインフラ系!

Page 19: Mac miniで作るMySQL Cluster

インフラ系が好きで、自宅 兼 事務所に42Uラックを置いてしまってます。

Page 20: Mac miniで作るMySQL Cluster
Page 21: Mac miniで作るMySQL Cluster

42Uラックが三つ並んでたり…

Page 22: Mac miniで作るMySQL Cluster

契約回線にケイオプティコムやNTTさんの

1Gbpsを7本ほど引いてたり…

Page 23: Mac miniで作るMySQL Cluster

月の電気代なども含めたインフラ代が、約20万ぐらいかかってますw

Page 24: Mac miniで作るMySQL Cluster

そういうインフラでやってしまった、MySQL ClusterでのWordPressの構築秘話

Page 25: Mac miniで作るMySQL Cluster

SAMSUNGのSSDを大量に購入

Page 26: Mac miniで作るMySQL Cluster
Page 27: Mac miniで作るMySQL Cluster

最近では、SAMSUNGのSSDのEVOに変えました。

Page 28: Mac miniで作るMySQL Cluster
Page 29: Mac miniで作るMySQL Cluster

一部ですが32個購入W

Page 30: Mac miniで作るMySQL Cluster

内蔵の一台あたりの読み書きは…

Page 31: Mac miniで作るMySQL Cluster
Page 32: Mac miniで作るMySQL Cluster

Thunderbolt 2 接続で…

Page 33: Mac miniで作るMySQL Cluster
Page 34: Mac miniで作るMySQL Cluster
Page 35: Mac miniで作るMySQL Cluster

IOPSの計測

Page 36: Mac miniで作るMySQL Cluster

1万IOPS × 4KB = 4万KB/s (≠40MB/秒)

Page 37: Mac miniで作るMySQL Cluster

約30万IOPS

書き込み IOPS

Page 38: Mac miniで作るMySQL Cluster

約26万IOPS

読み込み IOPS

Page 39: Mac miniで作るMySQL Cluster

このディスク速度の上に…

Page 40: Mac miniで作るMySQL Cluster
Page 41: Mac miniで作るMySQL Cluster

Oracle VM VirtualBOXを使い、Ubuntuをインストール

Page 42: Mac miniで作るMySQL Cluster

断然早い!

Page 43: Mac miniで作るMySQL Cluster

とりあえず、接続…

Page 44: Mac miniで作るMySQL Cluster
Page 45: Mac miniで作るMySQL Cluster
Page 46: Mac miniで作るMySQL Cluster

じゃ、今は何をやっているか?

Page 47: Mac miniで作るMySQL Cluster
Page 48: Mac miniで作るMySQL Cluster

贅沢なWordPressの運用!

Page 49: Mac miniで作るMySQL Cluster

MySQL Cluster ( ndbcluster engine ) 環境

Page 50: Mac miniで作るMySQL Cluster

• MySQL Cluster 上に WordPress 用のデータベースとユーザを作成 • Web サーバ上に WordPress 日本語版を展開 • WordPress 初期設定でテーブルを作成 •各テーブルを ndbcluster engine に変更 • SQLノードでの動作確認

大まかな流れ

Page 51: Mac miniで作るMySQL Cluster

root@cwe1-virtual-machine:~# mysql -h 127.0.0.1 -u root Welcome to the MySQL monitor.  Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.1.56-ndb-7.1.15a-cluster-gpl MySQL Cluster Server (GPL)   Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL v2 license   Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.   mysql> create database `blog.neoflow.jp`; Query OK, 1 row affected (0.02 sec)   mysql> show databases; +--------------------+ | Database           | +--------------------+ | information_schema | | blog.cw-e.jp    | | mysql              | | ndbinfo            | | test               | +--------------------+ 5 rows in set (0.00 sec) mysql> grant all privileges on `blog.cw-e.jp`.* to 'wp'@'10.0.1.0/255.255.255.0' identified by 'password' with grant option; Query OK, 0 rows affected (0.00 sec)   mysql> select user,host,password from mysql.user; +------+-------------------------------+-------------------------------------------+ | user | host                          | password                                  | +------+-------------------------------+-------------------------------------------+ | root | localhost                     |                                           | | root | 127.0.0.1                     |                                           | | root | ::1                           |                                           | |      | localhost                     |                                           | | wp   | 10.0.1.0/255.255.255.0        | *fo4whhouhhHHJp09ujqfoq93ufjiabfuahqhpqjj | +------+-------------------------------+-------------------------------------------+ 5 rows in set (0.01 sec)   mysql> quit Bye

Page 52: Mac miniで作るMySQL Cluster

root@cwe2-virtual-machine:~# mysql -h 127.0.0.1 -u root Welcome to the MySQL monitor.  Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.1.56-ndb-7.1.15a-cluster-gpl MySQL Cluster Server (GPL)   Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL v2 license   Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.   mysql> grant all privileges on `blog.neoflow.jp`.* to 'wp'@'10.0.1.0/255.255.255.0' identified by 'password' with grant option; Query OK, 0 rows affected (0.00 sec)   mysql> select user,host,password from mysql.user; +------+-------------------------------+-------------------------------------------+ | user | host                          | password                                  | +------+-------------------------------+-------------------------------------------+ | root | localhost                     |                                           | | root | 127.0.0.1                     |                                           | | root | ::1                           |                                           | |      | localhost                     |                                           | | wp   | 10.0.1.0/255.255.255.0        | *12EC34D567890E1B23C4567E8AEA9E01C2345CE6 | +------+-------------------------------+-------------------------------------------+ 5 rows in set (0.01 sec)   mysql> quit Bye

Page 53: Mac miniで作るMySQL Cluster

•ここが重要になります! •11個のテーブルが作成されていますが、この状態だとInnoDBに作成されただけなので、ndbclusterエンジンを利用するようにクエリの実行をしてください。

各テーブルを ndbcluster engine に変更

Page 54: Mac miniで作るMySQL Cluster

alter table wp_commentmeta engine=ndb; alter table wp_comments engine=ndb; alter table wp_links engine=ndb; alter table wp_options engine=ndb; alter table wp_postmeta engine=ndb; alter table wp_posts engine=ndb; alter table wp_term_relationships engine=ndb; alter table wp_term_taxonomy engine=ndb; alter table wp_terms engine=ndb; alter table wp_usermeta engine=ndb; alter table wp_users engine=ndb;

Page 55: Mac miniで作るMySQL Cluster

mysql> alter table wp_commentmeta engine=ndb; Query OK, 0 rows affected (0.30 sec) Records: 0  Duplicates: 0  Warnings: 0   mysql> alter table wp_comments engine=ndb; Query OK, 1 row affected (0.38 sec) Records: 1  Duplicates: 0  Warnings: 0   mysql> alter table wp_links engine=ndb; Query OK, 7 rows affected (0.30 sec) Records: 7  Duplicates: 0  Warnings: 0   mysql> alter table wp_options engine=ndb; Query OK, 155 rows affected (0.73 sec) Records: 155  Duplicates: 0  Warnings: 0   mysql> alter table wp_postmeta engine=ndb; Query OK, 2 rows affected (0.32 sec) Records: 2  Duplicates: 0  Warnings: 0 !

…⋯…⋯…⋯…⋯…⋯…⋯…⋯…⋯…⋯…⋯.省略

Page 56: Mac miniで作るMySQL Cluster

SQLノードでの動作確認

Page 57: Mac miniで作るMySQL Cluster

alter table テーブル名 engine=ndb; を実施したことで参照できるようになることを確認!

Page 58: Mac miniで作るMySQL Cluster

root@cwe1-virtual-machine:~# mysql -h 127.0.0.1 -u root Welcome to the MySQL monitor.  Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.1.56-ndb-7.1.15a-cluster-gpl MySQL Cluster Server (GPL)   Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL v2 license   Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.   mysql> use blog.cw-e.jp Database changed mysql> show tables; Empty set (0.03 sec)   mysql> show tables; +---------------------------+ | Tables_in_blog.cw-e.jp | +---------------------------+ | wp_commentmeta            | | wp_comments               | | wp_links                  | | wp_options                | | wp_postmeta               | | wp_posts                  | | wp_term_relationships     | | wp_term_taxonomy          | | wp_terms                  | | wp_usermeta               | | wp_users                  | +---------------------------+ 11 rows in set (0.01 sec)   mysql> quit Bye

Page 59: Mac miniで作るMySQL Cluster

じゃ、これを使ってWordPressでどれくらいの処理が可能なのか?

Page 60: Mac miniで作るMySQL Cluster

一ヶ月での自動書き込み…

Page 61: Mac miniで作るMySQL Cluster
Page 62: Mac miniで作るMySQL Cluster
Page 63: Mac miniで作るMySQL Cluster
Page 64: Mac miniで作るMySQL Cluster
Page 65: Mac miniで作るMySQL Cluster
Page 66: Mac miniで作るMySQL Cluster
Page 67: Mac miniで作るMySQL Cluster
Page 68: Mac miniで作るMySQL Cluster

…………………

Page 69: Mac miniで作るMySQL Cluster

約一ヶ月で100万記事ほど自動更新でも、問題なく動いています。

Page 70: Mac miniで作るMySQL Cluster

WordPressって普通に何万記事とか何十万記事を書いても動作するのもすごいのですが、

MySQL Clusterにする事によって、よりさくさくと動くのは嬉しい事です

Page 71: Mac miniで作るMySQL Cluster
Page 72: Mac miniで作るMySQL Cluster

/*!40101 SET NAMES utf8 */; !

CREATE TABLE `biz_admin_config` ( `biz_admin_config_id` int(11) NOT NULL auto_increment, `name` text NOT NULL, `value` text NOT NULL, PRIMARY KEY (`biz_admin_config_id`) ) ENGINE=NDB DEFAULT CHARSET=utf8;

Page 73: Mac miniで作るMySQL Cluster

今後は、MySQL Clusterを使った

SNSの運用等も議論し

運営していきたいと思います。

Page 74: Mac miniで作るMySQL Cluster

アトーという会社の製品等

Page 75: Mac miniで作るMySQL Cluster
Page 76: Mac miniで作るMySQL Cluster

最近ではThunderboltを使った、外付けのNIC等も出てきています。

Page 77: Mac miniで作るMySQL Cluster

価格は一台あたり、 約15万円~です。

Page 78: Mac miniで作るMySQL Cluster

スイッチはHPの10Gbpsが接続できる、 HP 5900番台等を使う事で

安価に安定した運営も可能かと思います。

Page 79: Mac miniで作るMySQL Cluster

スイッチはHPの10Gbpsが接続できる、 HP 5900番台等を使う事で

安価に安定した運営も可能かと思います。

Page 80: Mac miniで作るMySQL Cluster
Page 81: Mac miniで作るMySQL Cluster

Sonnetなどの製品を使う事によって、Thunderboltを使った

PCIの拡張が可能になります。

Page 82: Mac miniで作るMySQL Cluster
Page 83: Mac miniで作るMySQL Cluster

Fusion-ioなども接続が可能です。

Page 84: Mac miniで作るMySQL Cluster

まっ!運用もコストも大変ですけどねw

Page 85: Mac miniで作るMySQL Cluster

Mac mini12台を使った運用方法は以上です!

Page 86: Mac miniで作るMySQL Cluster

宣伝ではないのですが

Page 87: Mac miniで作るMySQL Cluster
Page 88: Mac miniで作るMySQL Cluster

丁寧に説明されている書籍なので、 これからやってみようという方には

おススメです。

Page 89: Mac miniで作るMySQL Cluster

ご清聴ありがとうございました!

Page 90: Mac miniで作るMySQL Cluster

–Kazuhiro Murota

“https://www.facebook.com/cyberweb”