Upload
kazuhiro-murota
View
1.122
Download
2
Embed Size (px)
Citation preview
Mac miniで作るMySQL ClusterMac miniを使った理由と何をやっているか!
MySQL Cluster Casual Talks #2
まず始めに、自己紹介をさせてください!
プロフィール名前 : 室田 和大
会社名 : CYBERWEB ENGINNERING
通称 : CWE
役職 : CEO
主な業務 : OpenSourceを使ったIT関係の仕事
OpenPNEの開発しています
• 日本で最大級のシェアを持つSNSのmixiにそっくりなインターフェースを持つ、オープンソースのSNSのソフトウェア
• OpenPNE 1系の時から色々と参加
OpenPNEでは!
OpenPNEでは
• ライトユーザ向けのOpenPNE 2系の後継になる。OpenPNE 2 CEの全体の開発をしています。
開発の方は少々忙しくて停滞していますが…
忙しいですが、
緊急性のあるものには対応をできるようには
一応しています。
OpenPNE 2 CE http://op2ce.org
現在は…
先ほど紹介した自社の経営の他に、美容業界のコンサルタントの
株式会社ケイアートファクトリーにてIT事業部でも仕事をしています。
こんな感じで、
特殊な業界でのお仕事もお手伝いしておりますが、
これからもよろしくお願い致します。
それでは本題へ!
今回、話す経緯となった理由!
オープンソースが好きだからです!
主にインフラ系!
インフラ系が好きで、自宅 兼 事務所に42Uラックを置いてしまってます。
42Uラックが三つ並んでたり…
契約回線にケイオプティコムやNTTさんの
1Gbpsを7本ほど引いてたり…
月の電気代なども含めたインフラ代が、約20万ぐらいかかってますw
そういうインフラでやってしまった、MySQL ClusterでのWordPressの構築秘話
SAMSUNGのSSDを大量に購入
最近では、SAMSUNGのSSDのEVOに変えました。
一部ですが32個購入W
内蔵の一台あたりの読み書きは…
Thunderbolt 2 接続で…
IOPSの計測
1万IOPS × 4KB = 4万KB/s (≠40MB/秒)
約30万IOPS
書き込み IOPS
約26万IOPS
読み込み IOPS
このディスク速度の上に…
Oracle VM VirtualBOXを使い、Ubuntuをインストール
断然早い!
とりあえず、接続…
じゃ、今は何をやっているか?
贅沢なWordPressの運用!
MySQL Cluster ( ndbcluster engine ) 環境
• MySQL Cluster 上に WordPress 用のデータベースとユーザを作成 • Web サーバ上に WordPress 日本語版を展開 • WordPress 初期設定でテーブルを作成 •各テーブルを ndbcluster engine に変更 • SQLノードでの動作確認
大まかな流れ
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
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
•ここが重要になります! •11個のテーブルが作成されていますが、この状態だとInnoDBに作成されただけなので、ndbclusterエンジンを利用するようにクエリの実行をしてください。
各テーブルを ndbcluster engine に変更
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;
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 !
…⋯…⋯…⋯…⋯…⋯…⋯…⋯…⋯…⋯…⋯.省略
SQLノードでの動作確認
alter table テーブル名 engine=ndb; を実施したことで参照できるようになることを確認!
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
じゃ、これを使ってWordPressでどれくらいの処理が可能なのか?
一ヶ月での自動書き込み…
…………………
約一ヶ月で100万記事ほど自動更新でも、問題なく動いています。
WordPressって普通に何万記事とか何十万記事を書いても動作するのもすごいのですが、
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;
今後は、MySQL Clusterを使った
SNSの運用等も議論し
運営していきたいと思います。
アトーという会社の製品等
最近ではThunderboltを使った、外付けのNIC等も出てきています。
価格は一台あたり、 約15万円~です。
スイッチはHPの10Gbpsが接続できる、 HP 5900番台等を使う事で
安価に安定した運営も可能かと思います。
スイッチはHPの10Gbpsが接続できる、 HP 5900番台等を使う事で
安価に安定した運営も可能かと思います。
Sonnetなどの製品を使う事によって、Thunderboltを使った
PCIの拡張が可能になります。
Fusion-ioなども接続が可能です。
まっ!運用もコストも大変ですけどねw
Mac mini12台を使った運用方法は以上です!
宣伝ではないのですが
丁寧に説明されている書籍なので、 これからやってみようという方には
おススメです。
ご清聴ありがとうございました!