おりそ.doc

自分のしたことをアウトプットする場所

【備忘録】Vagrantでマシンを起動させる

環境

Windows10+vagrant+virtualbox

環境構築は割愛。

Vagrantでマシンを立ち上げる手順

### 対象boxがあるか確認
$ vagrant box list
==> vagrant: A new version of Vagrant is available: 2.3.7 (installed version: 2.2.19)!
==> vagrant: To upgrade visit: https://www.vagrantup.com/downloads.html

bento/centos-7                       (virtualbox, 202110.25.0)
bento/centos7_lamp                   (virtualbox, 0)
centos6-7                            (virtualbox, 0)
juniper/ffp-12.1X47-D15.4-packetmode (virtualbox, 0.5.0)

### よさげなのを初期化

$ vagrant init bento/centos7_lamp
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.

### vagrantfile があるか確認
$ ls -al
total 8
drwxr-xr-x 1 xxx 197121    0 Sep  4 23:50 ./
drwxr-xr-x 1 xxx 197121    0 Aug  9 17:18 ../
-rw-r--r-- 1 xxx 197121 3094 Sep  4 23:50 Vagrantfile

### 起動させる
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'bento/centos7_lamp'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: taittsuu_bot_default_1693839141399_37931
==> default: Vagrant has detected a configuration issue which exposes a
==> default: vulnerability with the installed version of VirtualBox. The
==> default: current guest is configured to use an E1000 NIC type for a
==> default: network adapter which is vulnerable in this version of VirtualBox.
==> default: Ensure the guest is trusted to use this configuration or update
==> default: the NIC type using one of the methods below:
==> default:
==> default:   https://www.vagrantup.com/docs/virtualbox/configuration.html#default-nic-type
==> default:   https://www.vagrantup.com/docs/virtualbox/networking.html#virtualbox-nic-type
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (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: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: No guest additions were detected on the base box for this VM! Guest
    default: additions are required for forwarded ports, shared folders, host only
    default: networking, and more. If SSH fails on this machine, please install
    default: the guest additions and repackage the box to continue.
    default:
    default: This is not an error message; everything may continue to work properly,
    default: in which case you may ignore this message.
==> default: Mounting shared folders...
    default: /vagrant => C:/kankyo/git/taittsuu_bot
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:

mount -t vboxsf -o uid=1000,gid=1000,_netdev vagrant /vagrant

The error output from the command was:

/sbin/mount.vboxsf: mounting failed with the error: No such device

### 新しいディレクトリが出来てることを確認
$ ls -al
total 12
drwxr-xr-x 1 orin 197121    0 Sep  4 23:51 ./
drwxr-xr-x 1 orin 197121    0 Aug  9 17:18 ../
drwxr-xr-x 1 orin 197121    0 Sep  4 23:51 .vagrant/
-rw-r--r-- 1 orin 197121 3094 Sep  4 23:50 Vagrantfile

### vagrant status で状態確認
$ vagrant status
Current machine states:

default                   running (virtualbox)


### ssl ログインしてみる
$ vagrant ssh
Last login: Mon Apr 11 14:14:52 2022 from 10.0.2.2

This system is built by the Bento project by Chef Software
More information can be found at https://github.com/chef/bento
[vagrant@localhost ~]$

### 作業終了時はコレをしよう
$ vagrant halt
==> default: Attempting graceful shutdown of VM...

### 念のため状態確認
$ vagrant status
Current machine states:

default                   poweroff (virtualbox)

参考文献

【備忘録】Vagrant を使用したCentOS7 環境 構築手順 - Qiita