Thinking Out Loud

April 13, 2017

My Vagrant Journey

Filed under: Vagrant,VirtualBox — mdinh @ 4:09 am

This is probably nothing new.

Wanted to build my own Vagrant box with prerequisite to install GI/DB.

Instead of creating new network, use existing to assign IP.

Shared Folder uses existing location versus having to copy binaries into Vagrant location.

Same Vagrantfile can be used with a little search and replace.

You might ask, why not automate GI/DB install. I like to practice installating and cloning.

Next, install GG and DG.

After, create 2 RAC clusters using the same Vagrant Box?

dinh@CMWPHV1 MINGW64 /f/Vagrant
$ vboxmanage list hostonlyifs
Name:            VirtualBox Host-Only Ethernet Adapter
GUID:            8898fc55-9a80-4d5e-9a82-d2dc776ef00e
DHCP:            Disabled
IPAddress:       192.168.146.1
NetworkMask:     255.255.255.0
IPV6Address:
IPV6NetworkMaskPrefixLength: 0
HardwareAddress: 0a:00:27:00:00:22
MediumType:      Ethernet
Status:          Up
VBoxNetworkName: HostInterfaceNetworking-VirtualBox Host-Only Ethernet Adapter

dinh@CMWPHV1 MINGW64 /f/Vagrant
$ vagrant box list
There are no installed boxes! Use `vagrant box add` to add some.

dinh@CMWPHV1 MINGW64 /f/Vagrant
$ vagrant global-status
id       name   provider state  directory
--------------------------------------------------------------------
There are no active Vagrant environments on this computer! Or,
you haven't destroyed and recreated Vagrant environments that were
started with an older version of Vagrant.

dinh@CMWPHV1 MINGW64 /f/Vagrant
$ cd arrow1/

dinh@CMWPHV1 MINGW64 /f/Vagrant/arrow1
$ vagrant status
Current machine states:

arrow1                    not created (virtualbox)

The environment has not yet been created. Run `vagrant up` to
create the environment. If a machine is not created, only the
default provider will be shown. So if a provider is not listed,
then the machine is not created for that environment.

dinh@CMWPHV1 MINGW64 /f/Vagrant/arrow1
$ vagrant up
Bringing machine 'arrow1' up with 'virtualbox' provider...
==> arrow1: Box 'ol73-min' could not be found. Attempting to find and install...
    arrow1: Box Provider: virtualbox
    arrow1: Box Version: >= 0
==> arrow1: Box file was not detected as metadata. Adding it directly...
==> arrow1: Adding box 'ol73-min' (v0) for provider: virtualbox
    arrow1: Unpacking necessary files from: file:///F:/Vagrant/ol73-min.box
    arrow1:
==> arrow1: Successfully added box 'ol73-min' (v0) for 'virtualbox'!
==> arrow1: Importing base box 'ol73-min'...
==> arrow1: Matching MAC address for NAT networking...
==> arrow1: Setting the name of the VM: arrow1
==> arrow1: Clearing any previously set network interfaces...
==> arrow1: Preparing network interfaces based on configuration...
    arrow1: Adapter 1: nat
    arrow1: Adapter 2: hostonly
==> arrow1: Forwarding ports...
    arrow1: 22 (guest) => 2011 (host) (adapter 1)
==> arrow1: Running 'pre-boot' VM customizations...
==> arrow1: Booting VM...
==> arrow1: Waiting for machine to boot. This may take a few minutes...
    arrow1: SSH address: 127.0.0.1:2011
    arrow1: SSH username: vagrant
    arrow1: SSH auth method: private key
    arrow1: Warning: Remote connection disconnect. Retrying...
==> arrow1: Machine booted and ready!
[arrow1] GuestAdditions 5.1.18 running --- OK.
==> arrow1: Checking for guest additions in VM...
==> arrow1: Setting hostname...
==> arrow1: Configuring and enabling network interfaces...
==> arrow1: Mounting shared folders...
    arrow1: /vagrant => F:/Vagrant/arrow1
    arrow1: /sf_working => C:/dinh/Dropbox/working
    arrow1: /sf_OracleSoftware => F:/OracleSoftware

dinh@CMWPHV1 MINGW64 /f/Vagrant/arrow1
$ cd ../arrow2/

dinh@CMWPHV1 MINGW64 /f/Vagrant/arrow2
$ vagrant up
Bringing machine 'arrow2' up with 'virtualbox' provider...
==> arrow2: Importing base box 'ol73-min'...
==> arrow2: Matching MAC address for NAT networking...
==> arrow2: Setting the name of the VM: arrow2
==> arrow2: Clearing any previously set network interfaces...
==> arrow2: Preparing network interfaces based on configuration...
    arrow2: Adapter 1: nat
    arrow2: Adapter 2: hostonly
==> arrow2: Forwarding ports...
    arrow2: 22 (guest) => 2012 (host) (adapter 1)
==> arrow2: Running 'pre-boot' VM customizations...
==> arrow2: Booting VM...
==> arrow2: Waiting for machine to boot. This may take a few minutes...
    arrow2: SSH address: 127.0.0.1:2012
    arrow2: SSH username: vagrant
    arrow2: SSH auth method: private key
    arrow2: Warning: Remote connection disconnect. Retrying...
==> arrow2: Machine booted and ready!
[arrow2] GuestAdditions 5.1.18 running --- OK.
==> arrow2: Checking for guest additions in VM...
==> arrow2: Setting hostname...
==> arrow2: Configuring and enabling network interfaces...
==> arrow2: Mounting shared folders...
    arrow2: /vagrant => F:/Vagrant/arrow2
    arrow2: /sf_working => C:/dinh/Dropbox/working
    arrow2: /sf_OracleSoftware => F:/OracleSoftware

dinh@CMWPHV1 MINGW64 /f/Vagrant/arrow2
$ vagrant global-status
id       name   provider   state   directory
-----------------------------------------------------------------------
e779ae1  arrow1 virtualbox running F:/Vagrant/arrow1
7642809  arrow2 virtualbox running F:/Vagrant/arrow2

The above shows information about all known Vagrant environments
on this machine. This data is cached and may not be completely
up-to-date. To interact with any of the machines, you can go to
that directory and run Vagrant, or you can use the ID directly
with Vagrant commands from any directory. For example:
"vagrant destroy 1a2b3c4d"

dinh@CMWPHV1 MINGW64 /f/Vagrant/arrow2
$ vagrant box list
ol73-min (virtualbox, 0)

dinh@CMWPHV1 MINGW64 /f/Vagrant/arrow2
$ vboxmanage list runningvms
"arrow1" {d8e472d1-92c1-4211-ac86-99a8461f7cf5}
"arrow2" {66ad90a6-15ad-4096-a04e-e30c40ad2d70}

dinh@CMWPHV1 MINGW64 /f/Vagrant/arrow2
$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

# vboxmanage list vms
# vagrant package --output ol73-min.box --base ol73-min
# vagrant box add --name arrow1 file:///F:/Vagrant/ol73-min.box
# vboxmanage sharedfolder add "arrow1" --name "OracleSoftware" --hostpath "F:\OracleSoftware" --automount
# vboxmanage modifyvm "ol73-min" --natpf1 "ssh,tcp,,2222,,22"

VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.define "arrow2" , primary: true do |config|
    config.vm.box = "ol73-min"
    config.vm.box_url = "file:///F:/Vagrant/ol73-min.box"
    config.vm.network "private_network", ip: "192.168.146.12"
    config.vm.network "forwarded_port", guest: 22, host: 2012, host_ip: "127.0.0.1", id: "ssh"
    config.vm.box_check_update = false
    config.ssh.insert_key = false
    config.vm.host_name = "arrow2"
    config.vm.synced_folder "F:\\OracleSoftware", "/sf_OracleSoftware", type: "nfs"
    config.vm.synced_folder "C:\\dinh\\Dropbox\\working", "/sf_working", type: "nfs"
    config.vm.provider "virtualbox" do |vb|
      #vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
      #vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
      vb.memory = "1536"
      vb.name = "arrow2"
    end
  end
end

dinh@CMWPHV1 MINGW64 /f/Vagrant/arrow2
$
Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: