LoginSignup
0
2

More than 5 years have passed since last update.

vagrant+BOXでCentOS7.3の仮想環境構築手順

Posted at

仮想化手順

まず最初に

BIOSの設定で仮想化支援機能(Intel VT-d)をオンにすること。

Virtual BOXのインストール

ダウンロードURL

インストール方法

  1. welcome to the Oracle VM VirtualBox 5.1.18 setup wizard→Next>
  2. Custom Setup→Next>
  3. Next>
  4. Warning : Network Interfaces(ネットワーク切断の警告(瞬断が起きます))→Yes
  5. Ready to Install→Install

※インストール中にいくつか他のインストールを求められるので、すべてインストールする

Oracle VM VirtualBox Extension Pack インストール

ダウンロードURL

インストール方法

  1. Oracle VM VirtualBoxマネージャーを起動
  2. ファイル>環境設定≫機能拡張 →「新しいパッケージを追加」でOracle VM VirtualBox Extension Packを選択

Vagrantインストール

ダウンロードURL

インストール方法

  1. welcome to the Vagrant Srtup Wizard→Next
  2. End-User License Agreement→I accept the terms in the License Agreementにチェック→Next
  3. Destination Folder→Next
  4. Ready to install Vagrant→Install
  5. Completed the Vagrant Setup Wizard→Finish
  6. You must restart your system for the configuration~(再起動が必要です)→Yes

Microsoft Visual C++ 2010 再頒布可能パッケージ (x86)インストール

ダウンロードURL

  1. 言語を選択:日本語 でダウンロード

ディレクトリの作成、移動

仮想環境配置場所

  • コマンドプロンプトで作業 (※フォルダ名は自由、ここではcentos73と入力)
  • mkdir:ディレクトリの作成
    1. C:> mkdir C:\centos73
  • cd:ディレクトリの移動
    1. C:> cd C:\centos73

BOXのダウンロード

  • コマンドプロンプトで作業
  1. bento/centos-7.3をダウンロードする
    ダウンロードするファイルについては(https://atlas.hashicorp.com/bento)参照

    1. C:\centos73> vagrant box add bento/centos-7.3
  2. Enter your choice: の表示が確認出来れば「2」と入力する。
    →Enter your choice: 2

  3. ダウンロードが出来たことを確認する

    1. C:\centos73> vagrant box list

設定ファイル(Vagrantfile)の自動生成

  • コマンドプロンプトで作業
    1. C:\centos73> vagrant init bento/centos-7.3

設定ファイル(Vagrantfile)の手動修正

  • ソースを直接編集(さくらエディタなどで開く)

  編集ファイル:C:\centos73\Vagrantfile

    29行目 コメントアウト解除
       # config.vm.network "private_network", ip: "192.168.33.10"
     → config.vm.network "private_network", ip: "192.168.33.10"

    46行目 コメントアウト解除
       # config.vm.provider "virtualbox" do |vb|
     → config.vm.provider "virtualbox" do |vb|

    52行目 追加(#vb.memory = "1024" のあと)
     vb.name = "vg_centos7.3"

    53行目 コメントアウト解除
       # end
     → end

    最終行から1行上(endの前の行)に追加
    config.ssh.insert_key = false

仮想マシンの作成

  • コマンドプロンプトで作業
  1. C:\centos73> vagrant up

(※2回目以降は起動コマンドになる)

※もし下記のエラーが発生した場合は無視してよい
The error output from the command was:
/sbin/mount.vboxsf: mounting failed with the error: No such device

作成した環境を確認する

  • TeraTermなどSSH接続出来るツールを使用する
IP:192.168.33.10
ID:vagrant PW:vagrant (一般ユーザ)
ID:root PW:vagrant (root)

仮想マシンの停止

  • 必ず最後に停止すること
    1. C:\centos73> vagrant halt

参考URL

0
2
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
0
2