MySQL clusterは「waku2とらふぃっくすHAクラスタ化プロジェクト」のひとつです。 PCエンジンデータベースをはじめ現在のデータベースはpostgreSQLで稼動していますが、これを機会に移行も行う予定です。 本日は、「MySQL Cluster(primary/primary)のインストール[データ同期の確認]」についてです。
こんにちは。猫ITソリューションズ広報の齊藤メイ(♀)です。 本日は、MySQL Cluster(primary/primary)のインストール[データ同期の確認]についてです。
関連記事:
- MySQL Cluster(primary/primary)のインストールその1[管理ノードのインストール]
- MySQL Cluster(primary/primary)のインストールその2[データノード/SQLノードのインストール]
- MySQL Cluster(primary/primary)のインストールその3[データ同期の確認]
- MySQL Cluster(primary/primary)のインストールその4[起動・停止・管理]
- MySQL Cluster(primary/primary)のインストール[第一次インストール後調査メモ]
【中古】Xen徹底入門 オ-プンソ-スで実現するOS仮想化環境 第2版/翔泳社/宮本久仁男(大型本)
貴重な情報ありがとうございます。深く感謝の意を表します。
参考:
管理ノード/SQLノード/データノードと必要になる。 ここでの構成は以下の通り。(xenが前提です。洒落のつもりはないです)
- (Domain-0)
mikeneko.waku2traffics.com
eth1
10.0.0.20
管理ノード - (Domain-U)
buchineko.waku2traffics.com
eth1
10.0.0.21
データノード/SQLノード - (Domain-0)
toraneko.waku2traffics.com
未使用
※いつか管理ノードを冗長化させたい - (Domain-U)
shironeko.waku2traffics.com
eth1
10.0.0.31
データノード/SQLノード
OS:CentOS5.2 x86_64版
まずは、buchineko でSQL発行してみる。
1 2 3 4 5 6 |
# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 2 Server version: 5.1.30-ndb-6.3.20-cluster-gpl-log MySQL Cluster Server (GPL) Type 'help;' or 'h' for help. Type 'c' to clear the buffer. |
現在のデータベースの確認
1 2 3 4 5 6 7 8 9 |
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | +--------------------+ 3 rows in set (0.01 sec) |
データベースの新規作成
1 2 3 4 5 6 7 8 9 10 11 12 |
mysql> create database cluster_test; Query OK, 1 row affected (0.20 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | cluster_test | | mysql | | test | +--------------------+ 4 rows in set (0.00 sec) |
shironekoで確認
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 2 Server version: 5.1.30-ndb-6.3.20-cluster-gpl-log MySQL Cluster Server (GPL) Type 'help;' or 'h' for help. Type 'c' to clear the buffer. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | cluster_test | ←できている | mysql | | test | +--------------------+ 4 rows in set (0.00 sec) |
そのままshironekoでSQL発行
1 2 3 4 5 |
mysql> use cluster_test Database changed mysql> create table foo(bar int(10) primary key, name varchar(255)) -> engine=ndbcluster; Query OK, 0 rows affected (1.55 sec) |
buchineko で確認
1 2 3 4 5 6 7 8 9 |
mysql> use cluster_test Database changed mysql> show tables; +------------------------+ | Tables_in_cluster_test | +------------------------+ | foo | ←できている +------------------------+ 1 row in set (0.04 sec) |
そのまま buchineko でSQL発行
1 2 3 4 5 6 7 8 9 10 |
mysql> insert into foo values(1, 'ggrecus!'); Query OK, 1 row affected (0.04 sec) shironeko で確認 mysql> select * from foo; +-----+---------+ | bar | name | +-----+---------+ | 1 | ggrecus | ←できている +-----+---------+ 1 row in set (0.00 sec) |
動作確認OK。
ちなみに、テーブルを作るときに engine=ndbcluster を入れ忘れると同期されないので注意する。 以下には MySQL Cluster の構成の基本(メモリや設定など)について軽く触れているのでチューニング前に読んでおこう。
http://thinkit.jp/article/492/3/
http://thinkit.jp/article/505/1/
次回は、起動・停止・管理です。