LoginSignup
3
5

More than 5 years have passed since last update.

VagrantでCentOS7.1の環境を構築

Posted at

1. Boxファイルの取得

$ vagrant box add centos71 https://github.com/CommanderK5/packer-centos-template/releases/download/0.7.1/vagrant-centos-7.1.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'centos71' (v0) for provider: 
    box: Downloading: https://github.com/CommanderK5/packer-centos-template/releases/download/0.7.1/vagrant-centos-7.1.box
==> box: Successfully added box 'centos71' (v0) for 'virtualbox'!

2. 仮想マシンの初期化

$ mkdir centos71vm
$ cd centos71vm
$ vagrant init centos71
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.

3. 仮想マシンへのログイン

  • 仮想マシンの起動
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'centos71'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: centos71vm_default_1455940191858_56370
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
    default: 
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default: 
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default: 
    default: Guest Additions Version: 4.3.30
    default: VirtualBox Version: 5.0
==> default: Mounting shared folders...
    default: /vagrant => /home/katsuya/Documents/centos71vm
  • 仮想マシンにSSH接続
$ vagrant ssh
[vagrant@localhost ~]$ pwd
/home/vagrant

参考文献

  1. [初心者向け]VirtualBoxとVagrantで仮想マシンの立ち上げ _ Design & Technical Note, http://r105.info/2013/11/04/%E5%88%9D%E5%BF%83%E8%80%85%E5%90%91%E3%81%91-virtualbox%E3%81%A8vagrant%E3%81%A7%E4%BB%AE%E6%83%B3%E3%83%9E%E3%82%B7%E3%83%B3%E3%81%AE%E7%AB%8B%E3%81%A1%E4%B8%8A%E3%81%92/, Online; accessed 20-Feburary-2016.
  2. A list of base boxes for Vagrant - Vagrantbox.es, http://www.vagrantbox.es/, Online; accessed 20-Feburary-2016.
3
5
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
3
5