MySQL Sandboxを使ってレプリケーション環境を作る

インストール方法などは
MySQL Sandbox - MySQL Forge Wiki
http://forge.mysql.com/wiki/MySQL_Sandbox

1. download the sandbox package and expand it somewhere;
2. download a MySQL binary tarball;
3. run this command

MySQL Sandbox in Launchpad
https://launchpad.net/mysql-sandbox

毎回、Downloadを探すのに苦労する。。。

MySQL Sandbox project files
https://launchpad.net/mysql-sandbox/+download

ダウンロードして、展開


続いて、mysqlのサイトより、ダウンロードする

$ ./make_sandbox /path/to/mysql-X.X.XX-osinfo.tar.gz
By default, the sandbox creates a new instance for you under $HOME/sandboxes/msb_X_X_XX

ということで、~/sandboxes にできる

レプリケーション環境を作る

./make_replication_sandbox mysql-5.1.30-linux-i686-glibc23.tar.gz

デフォルトでは、マスターが1つで、スレーブが2つの環境が作られる

    • how_many_slaves=X

こういうオプションでいくつのスレーブを作るかをきめられる。
そのほかのオプションは、--helpで確認できる

便利なコマンド

sandboxの中にあるディレクト

~/sandbox/msb_5_1_30
~/sandbox/rsandbox_5_1_30

の中に以下のようなコマンドある

start サーバーを起動する
stop サーバーを停止する
restart サーバーを再起動する
use コマンドラインクライアントを起動する
clear データをすべて消して、スクラッチから開始できるようにする

レプリケーションでインストールするとほかに次のようなコマンドがある

start_all レプリケーション環境をスタート
stop_all レプリケーション環境を停止
restart_all レプリケーション環境を再起動
clear_all レプリケーション環境のデータを消す
use_all command すべてのmysqlにコマンドを送る
m マスターにつなぐ
s1 スレーブ1につなぐ
s2 スレーブ2につなぐ