Pages

Friday 17 October 2014

Vagrant (Virtual Machine Manager on ubuntu)

Virtual Machine Manager + Vagrant + Generate Multiple VM's + Windows +
 Common Errors + VMware

Steps to starts

. Create a folder anywhere and give entry in the folder
   mkdir tarun

 . cd tarun

 . vagrant init   #it will generate a file named "vagrant" with cinfigurations.

 . cd vagrant

 . Add a box into the ".vagrant.d\boxes\" in C drive.

 . run command  :-
   vagrant box add precise64 "C:\Users\admin\.vagrant.d\boxes\precise64.box"

 . When you will enter into the vagrant folder you will find a vagrant configuration file. In vagrant configuration file create a global configuration for virtual box.
 
   config.vm.box = "precise64"

 . Create the three layers.
   vagrant up

 . Define 3 enviornments with same virtual box.

    config.vm.define "web" do |web|
      #web.vm.box = "web"
      #web.vm.hostname = "web"
      web.vm.network :private_network, ip: "192.168.33.10"
      web.vm.network :forwarded_port, guest: 80, host: 8080
    end

    config.vm.define "db" do |db|
      #db.vm.box = "db"
      #db.vm.hostname = "mysql"
      db.vm.network "private_network", ip: "192.168.10.22"
      db.vm.network :forwarded_port, guest: 3306, host: 8888
    end

    config.vm.define "master" do |master|
      #master.vm.box = "master"
      #master.vm.hostname = "master"
      master.vm.network "private_network", ip: "192.168.10.23"
      master.vm.network :forwarded_port, guest: 80, host: 8080
    end

  . Define networks to communicate.
    master.vm.network "private_network", ip: "192.168.10.23"

  . Define port  
    master.vm.network :forwarded_port, guest: 80, host: 8080

  . After changing run command
    vagrant reload   #helps to configure the changed configuration

  . After generate the three layers, check the virtual box.

  . To enter in the layers, use command
     vergant ssh web 


 ERRORS:

  Error: Failed to create the host-only adapter :-
  Sol:   Reinstall the virtualbox and run it as administration.
    Or update the virtual box

  Error: Vagrant cannot forward the specified ports on this VM, since they
      would collide with some other application that is already listening
      on these ports. The forwarded port to 8080 is already in use
      on the host machine.
  Sol: write    :-   , auto_correct: true
       else :- Change the host, if already defined.

No comments:

Post a Comment