How to build two CentOS7 environments / Windows10 + VirtualBox + Vagrant

Introduction

In this article, I will explain the procedure to build two virtual machines ** CentOS 7 ** on ** Windows 10 ** using VirtualBox and Vagrant.

environment

--Host OS: Windows10 --Guest OS: 2 CentOS7 (client, server) --Virtual machine construction tool: VirtualBox, Vagrant

About how to build an environment

To build the environment, use a method that combines ** Virtual Box ** and ** Vagrant **.

The reason for using Vagarnt is that you can easily set up the network and build a virtual machine just by operating commands and setting necessary files on the command prompt without touching VirtualBox directly.

After building the environment, you can connect to the virtual machine by SSH connection from the command prompt and operate Linux commands. Of course, it is also possible to make an SSH connection using TeraTerm or PuTTY.

Preparation

Download and install VirtualBox (Windows version)

Download the latest version of VirtualBox from the URL below. https://www.virtualbox.org/wiki/Downloads

After downloading, install it on your PC.

Download & install Vagrant (Windows version)

Download the latest version of Vagrant from the URL below. https://www.vagrantup.com/downloads.html

After downloading, install it on your PC. When the installation is complete, open a command prompt and type the following command. Installation is complete when the installed vagrant version is displayed.

command prompt


C:¥>vagrant -v
Vagrant 2.2.10

Procedure for building two CentOS7 environments

Creating a Vagrantfile

Type the vagrant init command in any directory to create a Vagrantfile.

command prompt


D:\hoge>vagrant init

D:\hoge>dir
2020/10/20  18:25             3,080 Vagrantfile

Editing Vagrantfile

Edit the Vagrantfile as follows.

Vagrantfile


# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://vagrantcloud.com/search.
  config.vm.box = "centos/7"

  config.vm.define :client do | client |
    client.vm.hostname = "client"
    client.vm.network :private_network, ip: "192.168.33.10"
  end

  config.vm.define :server do | server |
    server.vm.hostname = "server"
    server.vm.network :private_network, ip: "192.168.33.20"
  end

  ...

Building a virtual machine

After editing the Vagrantfile, type the vagrant up command and two CentOS 7s will be created in about 2-3 minutes.

command prompt


D:\hoge>vagrant up --provider=virtualbox
Bringing machine 'client' up with 'virtualbox' provider...
Bringing machine 'server' up with 'virtualbox' provider...
==> client: Importing base box 'centos/7'...
==> client: Matching MAC address for NAT networking...
==> client: Checking if box 'centos/7' version '1905.1' is up to date...
~~~ Omitted ~~~
==> server: Setting hostname...
==> server: Configuring and enabling network interfaces...
==> server: Rsyncing folder: /cygdrive/d/hoge/ => /vagrant

Checking the startup status of the virtual machine

You can check the status of the virtual machine with the vagrant status command. If it is running, the startup is successful.

command prompt


D:\hoge>vagrant status
Current machine states:

client                    running (virtualbox)
server                    running (virtualbox)

This environment represents multiple VMs. The VMs are all listed
above with their current state. For more information about a specific
VM, run `vagrant status NAME`.

Connect to virtual machine

Use the vagrant ssh command to connect to the built virtual machine. The default password for root privileges is vagrant. I was able to SSH into the CentOS environment from the command prompt as shown below.

command prompt


D:\hoge>vagrant ssh client
[vagrant@client ~]$
[vagrant@client ~]$ su -
Password:
[root@client ~]#
[root@client ~]# cat /etc/centos-release
CentOS Linux release 7.6.1810 (Core)

that's all.

Recommended Posts

How to build two CentOS7 environments / Windows10 + VirtualBox + Vagrant
How to install Python [Windows]
How to build a python2.7 series development environment with Vagrant
How to build a LAMP environment using Vagrant and VirtulBox Note
How to use Dataiku on Windows
Steps to install VirtualBox on CentOS
How to install pycrypto on Windows
How to deploy django-compressor on Windows
How to install PyPy on CentOS
How to install TensorFlow on CentOS 7
Install VirtualBox on CentOS 7 on VirtualBox (mac + vagrant)
How to build MongoDB C driver
How to install Maven on CentOS
How to install music 21 on windows
How to build my own Linux server
How to build a sphinx translation environment
How to update to Chainer 2.0 (Windows + CUDA 8.0 + CUDNN)
[Kivy] How to install Kivy on Windows [Python]
How to build Hello, World on #Nix
How to use Cmder with PyCharm (Windows)
How to use Google Assistant on Windows 10
How to switch mouse operations on CentOS
How to install richzhang / colorization on Windows 10
How to install Windows Subsystem For Linux
How to update security on CentOS Linux 8
How to install Apache (httpd) on CentOS7
How to make multi-boot USB (Windows 10 compatible)
How to install Eclipse GlassFish 5.1.0 on CentOS 7
How to install Apache (httpd) on CentOS8
How to install python3 with docker centos
[Python] How to use two types of type ()
[Latest] How to build Java environment on Ubuntu
How to quickly install h5py on Windows 10 [Unofficial]
How to add Anaconda Powershell Prompt to Windows Terminal?
How to live a decent life on 2017 Windows
[ESXi (vCenter)] How to add NIC for CentOS 7.3
[Python] How to install OpenCV on Anaconda [Windows]
How to build Java environment on Ubuntu (Linux)
[TF] How to build Tensorflow in Proxy environment
[PyTorch] Sample ⑧ ~ How to build a complex model ~
[CentOS8] How to output Python standard output to systemd log
How to install / verify graphviz on anaconda / windows10
How to force build TensorFlow 2.3.0 for CUDA11 + cuDNN8
Steps to build PyTorch 1.5 for CUDA 10.2 on Windows
How to set a shared folder with the host OS in CentOS7 on VirtualBOX