1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MySQLのダンプをCloud Foundryに流し込む - vmc tunnelを使って

Last updated at Posted at 2012-04-19

vmc tunnelコマンドを使うとmysqlのダンプファイルをクラウド上のMySQLに流し込むことができる。

用意するもの

  • ローカルにmysqlクライアントがインストールされていること
  • mysqldumpで生成したダンプファイル

下記のgemをインストールする。

Gemfile
source :gemcutter
gem 'vmc',:git => "git://github.com/cloudfoundry/vmc.git"
gem 'caldecott',:git => "git://github.com/cloudfoundry/caldecott.git"
$ bundle install --path=your_gem_dir

vmc appsでアプリに紐づけられているmysqlのサービス名を確認する

例えば、クラウド側のサービス名をmydb01、ダンプファイルをfoo.dmpとすると

$ bundle exec vmc tunnel mydb01 mysql < foo.dmp

ローカルのmysqlクラアイントがトンネルを経由してクラウド側に接続に行き、ダンプ内のSQL文を実行する。

クラウド側のデータのダンプをとる

逆にクラウド側のデータのダンプをとるときには

$ bundle exec vmc tunnel 

で対話型シェルが立ち上がるのでクライアントをmysqldumpと指定すると出力ファイルを聞かれるので、そこに適当なファイル名を入れればOK

(参考)
http://blog.udcp.net/2011/11/22/vmc-tunnel/

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?