Last active
December 25, 2015 06:29
-
-
Save yhara/6932989 to your computer and use it in GitHub Desktop.
ISUCON3のAMIイメージが公開されたので、Vagrantからコマンドラインでインスタンス起動したり停止したりできるようにしてみました
http://isucon.net/archives/32971265.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vagrant.configure("2") do |config| | |
config.vm.box = "dummy" | |
config.vm.provider :aws do |aws, override| | |
# AWSのAPIキー(「セキュリティ証明書」のページから取得) | |
aws.access_key_id = "TODO" | |
aws.secret_access_key = "TODO" | |
# 鍵対の名前と秘密鍵のパス | |
aws.keypair_name = "TODO" | |
override.ssh.private_key_path = "TODO" | |
# インスタンスタイプ(m3.xlargeは毎時$0.76なので、付けっぱなしで放置すると結構高いので注意) | |
aws.instance_type = 'm3.xlarge' | |
# Asia Pasific (Tokyo) Regionを指定 | |
aws.region = 'ap-northeast-1' | |
# SSH(22)とHTTP(80)が空いているsecurity groupを作成して指定 | |
aws.security_groups = ['TODO'] | |
# isucon3のイメージを指定 | |
aws.ami = 'ami-b34ad3b2' | |
# SSHユーザ(isucon3のイメージではec2-userで入ってsudo su - isuconすることになっている) | |
override.ssh.username = "ec2-user" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Vagrantをインストール (Mac + vagrant 1.3.3で試してます) | |
2. vagrant plugin install vagrant-aws | |
3. AWS上でsecurity group作ったり、Tokyoリージョンに鍵を登録したりなど | |
3. vagrant up --provider=aws | |
4. インスタンスが起動するまで待つ | |
(なんか私の環境では以下のようなエラーがたくさん出ます) | |
Invalid Excon request keys: :host | |
/Users/yhara/.vagrant.d/gems/gems/excon-0.27.2/lib/excon/connection.rb:231:in `request' | |
/Users/yhara/.vagrant.d/gems/gems/fog-1.10.1/lib/fog/core/connection.rb:21:in `request' | |
/Users/yhara/.vagrant.d/gems/gems/fog-1.10.1/lib/fog/aws/compute.rb:384:in `_request' | |
/Users/yhara/.vagrant.d/gems/gems/fog-1.10.1/lib/fog/aws/compute.rb:379:in `request' | |
5. 赤字で「mkdir -p /vagrantが失敗したよ」と出たら成功 | |
(isucon3のイメージでは、ログインユーザで'/'にディレクトリが作れないため) | |
6. vagrant ssh | |
sshで接続するので、sudo su - isuconして、あとはsudo isucon3 testなどお好きに | |
7. 起動しっぱなしにすると毎時$0.76課金されるため、使い終わったらインスタンスを削除する | |
vagrant destroyで削除できます | |
また遊びたくなった場合はvagrant up --provider=awsからやり直せば新しいインスタンスが起動します、便利ですね | |
(もちろん加えた変更はdestoy時に消えてしまうのでローカルにコピーする必要あり) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment