appfog 上に作った mysql は SSHトンネリングすればコマンドラインから直接参照できるとのこと。
Tunneling - AppFog Documentation
ってことでさっそく試す。環境は以下。
まず http://rubyinstaller.org/downloads から「Development Kit」をダウンロード、適当なディレクトリに展開。ここでは C:\Ruby193\devkit\ に展開した。
次にコマンドプロンプトから以下実行して caldecott をインストール(最初の2行はRubyとDevelopment Kit のパス通すコマンド)。
> C:\Ruby193\bin\setrbvars.bat > C:\Ruby193\devkit\devkitvars.bat > gem install caldecott
トンネリングは10000ポートを使うので事前に開けておく。で、さっそく実行。まずはログイン。
> af login Attempting login to [https://api.appfog.com] Email: ********** Password: ********** Successfully logged into [https://api.appfog.com]
次にトンネリング実行。どのサービスをトンネリングするか聞かれるので、ここでは1のmysqlを選択。
> af tunnel 1: mgng_mysql 2: mgng_chimpo Which service to tunnel to?: 1
すると接続情報が表示され、トンネリングが開始されて、どの操作を実行するか聞かれる。
Getting tunnel connection info: OK Service connection info: username : ****** password : ****** name : ****** infra : aws Starting tunnel to mgng_mysql on port 10000. 1: none 2: mysql 3: mysqldump Which client would you like to start?: 2
1はトンネリングのみ(MySQL WorkBench みたいなツール専用)、2はコマンドラインで接続、3はdump取得。
コマンドラインから直接操作したいので 2 を選択。すると以下のように勝手に接続しにいく。
Launching 'mysql --protocol=TCP --host=localhost --port=10000 --user=****** --password=****** ******' Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 20110661 Server version: 5.5.8-log Source distribution Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
接続できたので、試しにクエリキャッシュの状態を確認してみる。
mysql> show variables like 'have_query_cache'; +------------------+-------+ | Variable_name | Value | +------------------+-------+ | have_query_cache | YES | +------------------+-------+ 1 row in set (0.81 sec)
あとはよしなに。