SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Downloaden Sie, um offline zu lesen
1515分で知る分で知るVagrantVagrant
hiro345@SSS(G)
自己紹介
●
hiro345
twitter: @hiro345
blog: http://www.sssg.org/blogs/hiro345/
●
執筆
 @IT ... Java, Eclipse, Android, C
日経Linux ... Java, Dart, Cloud
日経ソフトウェア ... Java
Java World, WEB+DB Press など
とり急ぎ用意したもの
●
Windows8 マシン
– タッチパネル
– CPU:Core i5 3317U(Ivy Bridge) 1.7GHz/2コア
– メモリ: 4GB
– HDD: 500GB
なにはともあれ用意したソフト
●
エディタ
– サクラエディタ
●
Webブラウザ
– Google Chrome
●
SSHクライアント
– Secure Shell(Chrome)
●
仮想マシンソフト
– Oracle VM VirtualBox
●
VirtualBoxにUbuntu 13 をインストールしてみたら使うにはつらい速度だった
●
SSDに換装すると速いらしい
– シー・エフ・デー販売
TOSHIBA製SSD採用 2.5inch 内蔵型
SATA6Gbps 256GB CSSD-S6T256NHG5Q
– EaseUS Todo Backup Free でクローン
http://www.vector.co.jp/soft/dl/winnt/util/se501336.html
– 厚さがどれくらいか気にしよう(今回は7mm)
– クローンに1時間30分程度かかったが、移行は簡単にできた。
– 速度が劇的によくなった
– 仮想マシンをGUIで使うのはつらいが、それでも許容できる範囲
仮想マシンの速度に問題が...
Vagrant
●
ベイグラントと読むらしい
●
開発などで利用する仮想マシンを簡単に用意するた
めのツール
●
OSS, MITライセンス
●
VirtualBox、VMware、EC2 などに対応
●
Chefなどを使って環境構築ができる
必要な知識
●
仮想マシンソフト
●
ホストマシンのOS(Windowsが多いでしょう)
●
ゲストマシンのOS(Linuxが多いでしょう)
●
Ruby(知っているとよい)
●
Chef (知っているとよい)
注目したきっかけ
●
@IT連載
DevOps時代のJava開発者のためのオープンクラウド入門(2)
Vagrantで手軽に構築してオープンPaaS「Cloud Foundry」を理解する
 http://www.atmarkit.co.jp/ait/articles/1307/31/news029.html
●
噂には聞いていた
●
OpenShift OriginもVagrantで環境用意ができるようになっていた
●
かなり手軽
●
最近よく話に聞く
●
WEB+DB Press Vol.75でも取り上げられていた
インストール
●
http://www.vagrantup.com/ からVagrant_1.2.7.msi
(2013-08-24時点での最新版)をダウンロード
●
インストールウィザードにしたがってインストール
●
インストール先はカスタマイズ
C:applicationsHashiCorpVagrant
●
環境変数PATHの設定
%PATH%;C:applicationsHashiCorpVagrantbin
●
インストール後に再起動が必要
Ruby
●
C:applicationsHashiCorpVagrantembeddedの
実体はWindows版Rubyらしい
●
ruby 1.9.3p448 (2013-06-27) [i386-mingw32]
●
msys
●
MinGW
仮想マシン構築の手順
1.仮想マシンのテンプレートBoxを取得
2.仮想マシンを初期化
3.仮想マシンを起動
Boxの用意
●
vagrant boxコマンドを使い、name に名前、urlにBoxのURLを指定
> vagrant box add name url
●
Ubuntu Precise (12.04) のBox
> vagrant box add precise32 http://files.vagrantup.com/precise32.box
●
有志が作成したイメージ : A list of base boxes for Vagrant – Vagrantbox.es
http://www.vagrantbox.es/
●
CentOS 6.4 のBox (実際は1行)
> vagrant box add CentOS-6.4-i386-v20130427
http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-i386-v20130427.box
●
取り込んだboxのリスト表示するコマンド
> vagrant box list
●
vagrant boxコマンドのヘルプ表示
> vagrant box -h
●
Boxが置かれる場所
> dir C:%HOMEPATH%.vagrant.dboxes
仮想マシン初期化と起動
●
仮想マシンの初期化
> mkdir "C:workspacevagrantprecise32"
> cd C:workspacevagrantprecise32
> vagrant init precise32
●
設定ファイルの確認
> type Vagrantfile
●
仮想マシン起動
> vagrant up
仮想マシン操作用コマンド
●
状態表示
> vagrant status
●
停止
> vagrant halt
●
一時停止
> vagrant suspend
●
再開
> vagrant resume
●
破棄
> vagrant destroy
SSHアクセス用情報取得
●
情報取得
*SSHコマンドがあればこのまま接続できる
> vagrant ssh
(略)
Host: 127.0.0.1
Port: 2222
Username: vagrant
Private key:
C:/Users/xxxx/.vagrant.d/insecure_private_key
Secure Shell
●
vagrant@127.0.0.1:2222でアクセスできる
●
パスはアカウント名と同じ
●
公開鍵方式でアクセスしたい場合
– パスワード認証でSSHログインしてからauthorized_keysを取得
$ cat ~/.ssh/authorized_keys
ssh-rsa A(略)Q== vagrant insecure public key
– この内容をWindows側で下記の名前で保存(%HOMEPATH%は実際の
値に置き換えること)
C:%HOMEPATH%.vagrant.dinsecure_private_key.pub
– これでSecure Shellでinsecure_private_keyの鍵をインポートできる
Vagrantfileによるカスタマイズ
●
Vagrantファイル修正(HTTPのポートフォワードの追加、仮想マシンの画面表示を有効、仮想マシンの
メモリを1024MBに設定)
(略)
config.vm.network :forwarded_port, guest: 80, host: 80
(略)
config.vm.provider :virtualbox do |vb|
# # Don't boot with headless mode
vb.gui = true
#
# # Use VBoxManage to customize the VM. For example to change memory:
vb.customize ["modifyvm", :id, "--memory", "1024"]
End
●
リロードで反映
> vagrant reload
Provisioningによるカスタマイズ
●
Vagrantfileを編集する
– インラインで shell scriptを使う方法
config.vm.provision:shell, :inline => "echo hello world"
– shell script を呼び出す方法
config.vm.provision:shell, :path => "install_apache2.sh"
install_apache2.shの内容は下記(LFの改行コードで作成)
========
#!/bin/sh
sudo apt-get -y install apache2
========
●
適用
> vagrant provision
カスタマイズしたBoxの作成
●
パッケージ化
> vagrant package
--output precise32_apache2.box
--vagrantfile Vagrantfile
●
Boxを自分の環境へ追加
> vagrant box add
precise32_apache2 precise32_apache2.box
●
いずれも表示上の都合で改行してありますが、実際は1行で
入力すること
まとめ
●
Vagrantで簡単に仮想マシンの用意が可能
●
WindowsでLinuxを勉強するのに便利そう
●
ハイスペックなパソコンを用意しよう

Weitere ähnliche Inhalte

Was ist angesagt?

Cq tse-fm3セミナー資料
Cq tse-fm3セミナー資料Cq tse-fm3セミナー資料
Cq tse-fm3セミナー資料
Masaki Muranaka
 
自作x86エミュレータの終焉
自作x86エミュレータの終焉自作x86エミュレータの終焉
自作x86エミュレータの終焉
Daisuke Kamikawa
 

Was ist angesagt? (20)

NetBSDのクロスビルドのしくみとインストール済みLive Imageの作成
NetBSDのクロスビルドのしくみとインストール済みLive Imageの作成NetBSDのクロスビルドのしくみとインストール済みLive Imageの作成
NetBSDのクロスビルドのしくみとインストール済みLive Imageの作成
 
最近のWindowsタブレット、ガジェットLinuxハッキング #osc17sm
最近のWindowsタブレット、ガジェットLinuxハッキング #osc17sm最近のWindowsタブレット、ガジェットLinuxハッキング #osc17sm
最近のWindowsタブレット、ガジェットLinuxハッキング #osc17sm
 
ドライバハッキング。UMPC、Windowsタブレット にLinux、*BSDを入れて遊ぼう  2017年度京都版 #osckyoto
ドライバハッキング。UMPC、Windowsタブレット にLinux、*BSDを入れて遊ぼう  2017年度京都版 #osckyotoドライバハッキング。UMPC、Windowsタブレット にLinux、*BSDを入れて遊ぼう  2017年度京都版 #osckyoto
ドライバハッキング。UMPC、Windowsタブレット にLinux、*BSDを入れて遊ぼう  2017年度京都版 #osckyoto
 
TechBuzz第5回cocos2d-x勉強会 BrainWars発表資料
TechBuzz第5回cocos2d-x勉強会 BrainWars発表資料TechBuzz第5回cocos2d-x勉強会 BrainWars発表資料
TechBuzz第5回cocos2d-x勉強会 BrainWars発表資料
 
Windows10タブレットに各種Linuxディストリを入れて遊ぼう 2017年度東京Spring版
Windows10タブレットに各種Linuxディストリを入れて遊ぼう 2017年度東京Spring版Windows10タブレットに各種Linuxディストリを入れて遊ぼう 2017年度東京Spring版
Windows10タブレットに各種Linuxディストリを入れて遊ぼう 2017年度東京Spring版
 
BrainWars Night 発表資料
BrainWars Night 発表資料BrainWars Night 発表資料
BrainWars Night 発表資料
 
Hacking with x86 Windows Tablet and mobile devices on openSUSE #opensuseasia17
 Hacking with x86 Windows Tablet and mobile devices on openSUSE #opensuseasia17 Hacking with x86 Windows Tablet and mobile devices on openSUSE #opensuseasia17
Hacking with x86 Windows Tablet and mobile devices on openSUSE #opensuseasia17
 
初めてのAndroid-x86インストール #東海道らぐ
初めてのAndroid-x86インストール #東海道らぐ初めてのAndroid-x86インストール #東海道らぐ
初めてのAndroid-x86インストール #東海道らぐ
 
ゼロから始める自作 CPU 入門
ゼロから始める自作 CPU 入門ゼロから始める自作 CPU 入門
ゼロから始める自作 CPU 入門
 
Cq tse-fm3セミナー資料
Cq tse-fm3セミナー資料Cq tse-fm3セミナー資料
Cq tse-fm3セミナー資料
 
Beginner for install US$40 JUNK Intel Macbook in 2020 はじめての4,500円ジャンクIntel Ma...
Beginner for install US$40 JUNK Intel Macbook in 2020 はじめての4,500円ジャンクIntel Ma...Beginner for install US$40 JUNK Intel Macbook in 2020 はじめての4,500円ジャンクIntel Ma...
Beginner for install US$40 JUNK Intel Macbook in 2020 はじめての4,500円ジャンクIntel Ma...
 
Beginner for install Android applications in Xiaomi MiReader  はじめてのXiaomi MiR...
Beginner for install Android applications in Xiaomi MiReader  はじめてのXiaomi MiR...Beginner for install Android applications in Xiaomi MiReader  はじめてのXiaomi MiR...
Beginner for install Android applications in Xiaomi MiReader  はじめてのXiaomi MiR...
 
Windows10タブレットにUbuntu16.04を色々入れてみた 2016年度版 Install Ubuntu16.04 on Windows10 T...
Windows10タブレットにUbuntu16.04を色々入れてみた 2016年度版 Install Ubuntu16.04 on Windows10 T...Windows10タブレットにUbuntu16.04を色々入れてみた 2016年度版 Install Ubuntu16.04 on Windows10 T...
Windows10タブレットにUbuntu16.04を色々入れてみた 2016年度版 Install Ubuntu16.04 on Windows10 T...
 
NetBSD8.0 on UEFI Bootloader and Windows Tablet #osc18hi
NetBSD8.0 on UEFI Bootloader and Windows Tablet #osc18hiNetBSD8.0 on UEFI Bootloader and Windows Tablet #osc18hi
NetBSD8.0 on UEFI Bootloader and Windows Tablet #osc18hi
 
Bug for Install Linux on Atom Z8700 Portabook ポータブックのLinuxインストールバグ対策 2018 #東海道らぐ
Bug for Install Linux on Atom Z8700 Portabook ポータブックのLinuxインストールバグ対策 2018 #東海道らぐBug for Install Linux on Atom Z8700 Portabook ポータブックのLinuxインストールバグ対策 2018 #東海道らぐ
Bug for Install Linux on Atom Z8700 Portabook ポータブックのLinuxインストールバグ対策 2018 #東海道らぐ
 
自作x86エミュレータの終焉
自作x86エミュレータの終焉自作x86エミュレータの終焉
自作x86エミュレータの終焉
 
Androidクラウドブック DynabookAZでLinuxを色々と遊んでみよう
Androidクラウドブック DynabookAZでLinuxを色々と遊んでみようAndroidクラウドブック DynabookAZでLinuxを色々と遊んでみよう
Androidクラウドブック DynabookAZでLinuxを色々と遊んでみよう
 
#GPD-Pocket にUbuntu17.04をインストール Install Ubuntu Linux 17.04 on GPD-Pocket
#GPD-Pocket にUbuntu17.04をインストール Install Ubuntu Linux 17.04 on GPD-Pocket#GPD-Pocket にUbuntu17.04をインストール Install Ubuntu Linux 17.04 on GPD-Pocket
#GPD-Pocket にUbuntu17.04をインストール Install Ubuntu Linux 17.04 on GPD-Pocket
 
openSUSE42.2 on Windows Tablet T100TA
openSUSE42.2 on Windows Tablet T100TAopenSUSE42.2 on Windows Tablet T100TA
openSUSE42.2 on Windows Tablet T100TA
 
AllwinnerタブレットのOSを作ってみる (途中版)
AllwinnerタブレットのOSを作ってみる (途中版)AllwinnerタブレットのOSを作ってみる (途中版)
AllwinnerタブレットのOSを作ってみる (途中版)
 

Andere mochten auch (7)

Developing initial thoughts on holiploigy
Developing initial thoughts on holiploigyDeveloping initial thoughts on holiploigy
Developing initial thoughts on holiploigy
 
Approaches About School Curriculum
Approaches About School CurriculumApproaches About School Curriculum
Approaches About School Curriculum
 
FS 4: Episode 5
FS 4: Episode 5FS 4: Episode 5
FS 4: Episode 5
 
Field study 4
Field study 4Field study 4
Field study 4
 
Exploring the curriculum(fs4)
Exploring the curriculum(fs4)Exploring the curriculum(fs4)
Exploring the curriculum(fs4)
 
Field Study 4 Exploring the Curriculum
Field Study 4 Exploring the CurriculumField Study 4 Exploring the Curriculum
Field Study 4 Exploring the Curriculum
 
Field study 5 assessment
Field study 5 assessmentField study 5 assessment
Field study 5 assessment
 

Ähnlich wie 15分で知るVagrant (NSEG 2013-08-24)

Boost.勉強会 #13 @仙台 鳥小屋
Boost.勉強会 #13 @仙台 鳥小屋Boost.勉強会 #13 @仙台 鳥小屋
Boost.勉強会 #13 @仙台 鳥小屋
Yuto M
 
Windows 8 Developers カンファレンス
Windows 8 Developers カンファレンスWindows 8 Developers カンファレンス
Windows 8 Developers カンファレンス
Kaoru NAKAMURA
 
Windows Azure Media Serviceで作成する割と普通な動画サイト
Windows Azure Media Serviceで作成する割と普通な動画サイトWindows Azure Media Serviceで作成する割と普通な動画サイト
Windows Azure Media Serviceで作成する割と普通な動画サイト
normalian
 
DLR言語によるSilverlightプログラミング
DLR言語によるSilverlightプログラミングDLR言語によるSilverlightプログラミング
DLR言語によるSilverlightプログラミング
terurou
 
たのしいNode.js
たのしいNode.jsたのしいNode.js
たのしいNode.js
ishiki-takai
 
2015/05/23 シニア技術者プログラム第3弾 「第二回IoT勉強会&交流会」 15:00~15:20 Arduinoで簡単回路作成実演
2015/05/23 シニア技術者プログラム第3弾 「第二回IoT勉強会&交流会」  15:00~15:20 Arduinoで簡単回路作成実演2015/05/23 シニア技術者プログラム第3弾 「第二回IoT勉強会&交流会」  15:00~15:20 Arduinoで簡単回路作成実演
2015/05/23 シニア技術者プログラム第3弾 「第二回IoT勉強会&交流会」 15:00~15:20 Arduinoで簡単回路作成実演
aitc_jp
 
OpenStackでつくる開発環境と外道塾
OpenStackでつくる開発環境と外道塾OpenStackでつくる開発環境と外道塾
OpenStackでつくる開発環境と外道塾
外道 父
 
仮想スイッチをフェイルオーバーさせてみる予定
仮想スイッチをフェイルオーバーさせてみる予定仮想スイッチをフェイルオーバーさせてみる予定
仮想スイッチをフェイルオーバーさせてみる予定
Takashi Naito
 

Ähnlich wie 15分で知るVagrant (NSEG 2013-08-24) (20)

Boost.勉強会 #13 @仙台 鳥小屋
Boost.勉強会 #13 @仙台 鳥小屋Boost.勉強会 #13 @仙台 鳥小屋
Boost.勉強会 #13 @仙台 鳥小屋
 
Windows 8 Developers カンファレンス
Windows 8 Developers カンファレンスWindows 8 Developers カンファレンス
Windows 8 Developers カンファレンス
 
Intel graphics
Intel graphicsIntel graphics
Intel graphics
 
78tch
78tch78tch
78tch
 
Windows Azure Media Serviceで作成する割と普通な動画サイト
Windows Azure Media Serviceで作成する割と普通な動画サイトWindows Azure Media Serviceで作成する割と普通な動画サイト
Windows Azure Media Serviceで作成する割と普通な動画サイト
 
Osoljp201204
Osoljp201204Osoljp201204
Osoljp201204
 
DLR言語によるSilverlightプログラミング
DLR言語によるSilverlightプログラミングDLR言語によるSilverlightプログラミング
DLR言語によるSilverlightプログラミング
 
初心者がOpenIndianaで自宅サーバを作ったよって話
初心者がOpenIndianaで自宅サーバを作ったよって話初心者がOpenIndianaで自宅サーバを作ったよって話
初心者がOpenIndianaで自宅サーバを作ったよって話
 
配布用Cacti running with cherokee
配布用Cacti running with cherokee配布用Cacti running with cherokee
配布用Cacti running with cherokee
 
たのしいNode.js
たのしいNode.jsたのしいNode.js
たのしいNode.js
 
2015/05/23 シニア技術者プログラム第3弾 「第二回IoT勉強会&交流会」 15:00~15:20 Arduinoで簡単回路作成実演
2015/05/23 シニア技術者プログラム第3弾 「第二回IoT勉強会&交流会」  15:00~15:20 Arduinoで簡単回路作成実演2015/05/23 シニア技術者プログラム第3弾 「第二回IoT勉強会&交流会」  15:00~15:20 Arduinoで簡単回路作成実演
2015/05/23 シニア技術者プログラム第3弾 「第二回IoT勉強会&交流会」 15:00~15:20 Arduinoで簡単回路作成実演
 
2016年11月19日 AITCシニア技術者勉強会 第1回「Arduinoを使ってみる」
2016年11月19日 AITCシニア技術者勉強会 第1回「Arduinoを使ってみる」 2016年11月19日 AITCシニア技術者勉強会 第1回「Arduinoを使ってみる」
2016年11月19日 AITCシニア技術者勉強会 第1回「Arduinoを使ってみる」
 
Gruntでjava script前作業の自動化!
Gruntでjava script前作業の自動化!Gruntでjava script前作業の自動化!
Gruntでjava script前作業の自動化!
 
OpenStackでつくる開発環境と外道塾
OpenStackでつくる開発環境と外道塾OpenStackでつくる開発環境と外道塾
OpenStackでつくる開発環境と外道塾
 
Halide, Darkroom - 並列化のためのソフトウェア・研究
Halide, Darkroom - 並列化のためのソフトウェア・研究Halide, Darkroom - 並列化のためのソフトウェア・研究
Halide, Darkroom - 並列化のためのソフトウェア・研究
 
仮想スイッチをフェイルオーバーさせてみる予定
仮想スイッチをフェイルオーバーさせてみる予定仮想スイッチをフェイルオーバーさせてみる予定
仮想スイッチをフェイルオーバーさせてみる予定
 
Movidius Neral Compute Stickを使ってみた
Movidius Neral Compute Stickを使ってみたMovidius Neral Compute Stickを使ってみた
Movidius Neral Compute Stickを使ってみた
 
ラズパイ × Bluemix IoTハンズオンセミナー
ラズパイ × Bluemix IoTハンズオンセミナーラズパイ × Bluemix IoTハンズオンセミナー
ラズパイ × Bluemix IoTハンズオンセミナー
 
Runtime c++editing
Runtime c++editingRuntime c++editing
Runtime c++editing
 
プログラマの為のESP-WROOM-02開発ボード組み立て
プログラマの為のESP-WROOM-02開発ボード組み立てプログラマの為のESP-WROOM-02開発ボード組み立て
プログラマの為のESP-WROOM-02開発ボード組み立て
 

Mehr von hiro345

Nseg20120929
Nseg20120929Nseg20120929
Nseg20120929
hiro345
 
Nseg20120825
Nseg20120825Nseg20120825
Nseg20120825
hiro345
 

Mehr von hiro345 (11)

手軽に使ってみようIoTデバイス
手軽に使ってみようIoTデバイス手軽に使ってみようIoTデバイス
手軽に使ってみようIoTデバイス
 
Raspberry Pi を楽しもう
Raspberry Pi を楽しもうRaspberry Pi を楽しもう
Raspberry Pi を楽しもう
 
リーダブルパスワード - SQLアンチパターンより抜粋 -
リーダブルパスワード - SQLアンチパターンより抜粋 -リーダブルパスワード - SQLアンチパターンより抜粋 -
リーダブルパスワード - SQLアンチパターンより抜粋 -
 
Raspberry Pi and WebIOPi
Raspberry Pi and WebIOPiRaspberry Pi and WebIOPi
Raspberry Pi and WebIOPi
 
Frontend framework and Template
Frontend framework and TemplateFrontend framework and Template
Frontend framework and Template
 
WordPress安全運用の基礎
WordPress安全運用の基礎WordPress安全運用の基礎
WordPress安全運用の基礎
 
Arduino、Raspberry Pi、PIC 入門以前(NSEG 2014-04-19)
Arduino、Raspberry Pi、PIC 入門以前(NSEG 2014-04-19)Arduino、Raspberry Pi、PIC 入門以前(NSEG 2014-04-19)
Arduino、Raspberry Pi、PIC 入門以前(NSEG 2014-04-19)
 
5分でわかる! SqljockyでDart+MySQL
5分でわかる! SqljockyでDart+MySQL5分でわかる! SqljockyでDart+MySQL
5分でわかる! SqljockyでDart+MySQL
 
15分でCakePHPを始める方法(Nseg 2013-11-09 )
15分でCakePHPを始める方法(Nseg 2013-11-09 )15分でCakePHPを始める方法(Nseg 2013-11-09 )
15分でCakePHPを始める方法(Nseg 2013-11-09 )
 
Nseg20120929
Nseg20120929Nseg20120929
Nseg20120929
 
Nseg20120825
Nseg20120825Nseg20120825
Nseg20120825
 

15分で知るVagrant (NSEG 2013-08-24)