LoginSignup
31
32

More than 5 years have passed since last update.

MacOSXにvagrantを入れて起動、停止するまでのメモ

Last updated at Posted at 2013-05-10

VirtualBoxのインストール

www.virtualbox.orgのDownloadsからイメージファイルをダウンロードする。
ダウンロードし終わったら、マウントしてインストールする。

Vagrantのインストール

(2013/5/11修正) 1.0系はもう古いそうなので、ワイルドに1.2.2を入れる。予め下記のコマンドで消しておくこと。

% sudo gem uninstall vagrant

vagrantのダウンロードページから必要なバージョンをダウンロードする。
ダウンロードし終わったら、マウントしてインストールする。

インストールが終わったらバージョン確認。

% vagrant --version
Vagrant version 1.2.2

ひな形となるボックスの用意

vagrantbox.es に記載されている仮想マシンのボックスを利用する

今回はサーバに合わせて、CentOS6.4を用意

% vagrant box add centos64 http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130309.box
Password:
[vagrant] Downloading with Vagrant::Downloaders::HTTP...
[vagrant] Downloading box: http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130309.box
[vagrant] Extracting box...
[vagrant] Verifying box...
[vagrant] Cleaning up downloaded box...

仮想マシン作成

% vagrant init centos64

以下の表示が出たら成功。

A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

仮想マシン起動する

% vagrant up

以下の表示が出たら起動。

Bringing machine 'default' up with 'virtualbox' provider...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
[default] Configuring and enabling network interfaces...
[default] Mounting shared folders...
[default] -- /vagrant

仮想マシンへのssh

% vagrant ssh

仮想マシン停止

% vagrant halt

トラブル

~/.vagrant.d/insecure_private_key が古くて vagrant up ができない

% vagrant up
Password:
Bringing machine 'default' up with 'virtualbox' provider...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] Failed to connect to VM!
Failed to connect to VM via SSH. Please verify the VM successfully booted
by looking at the VirtualBox GUI.

のようなエラーが出ていた。

% vagrant ssh
The private key to connect to the machine via SSH must be owned
by the user running Vagrant. This is a strict requirement from
SSH itself. Please fix the following key to be owned by the user
running Vagrant:

/Users/***/.vagrant.d/insecure_private_key

sshをすると、エラーが発生してログイン出来ない。

% vagrant hult --force

で一旦強制停止し、下記のようにして再度立ち上げたところ解決した。

% rm ~/.vagrant.d/insecure_private_key
% vagrant up

参考

...というかほぼコピー
Vagrantで簡単仮想マシン構築|Ryuzee.com

31
32
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
31
32