Friday, November 21, 2014

Virtualbox for Virtualization

Cloning VMs


A Virtual Machine can be cloned by running this command in the dos prompt:
 VBoxManage clonevm "U14_HDFS_S1" --name "U14_HDFS_S2" --register --basefolder %vm%  

Command Overview:

  • The HDFS slave node (named U14_HDFS_S1) is being cloned as another slave node called U14_HDFS_S2.
  • The --register command ensures that the new VM will show up in the VirtualBox Manager GUI
  • The --basefolder will put the clone into the output folder of your choice (rather than defaulting to the drive that VirtualBox Manager was installed on).


Scripted Cloning

  @echo OFF   
  set name=U14_HDFS_S   
 
 REM start each VM headlessly   
  for /l %%x in (x, 1, y) do (   
   VBoxManage clonevm "U14_HDFS_S1" --name "U14_HDFS_S%%x" --register --basefolder %vm%   
  )   

 REM find the IP address for each VM  
  for /l %%x in (x, 1, y) do (  
   echo U14_HDFS_S%%x  
   VBoxManage guestproperty get "U14_HDFS_S%%x" "/VirtualBox/GuestInfo/Net/0/V4/IP"  
   echo.  
  )  



Starting VMs

A VM can be started via the VirtualBox Manager, but can also be started headlessly through the command line:
 VBoxManage startvm "U14_HDFS_S1" --type headless   

In this case, I'm starting my first HDFS slave in headless mode.


Scripted Start-ups

 @echo OFF  
 set name=U14_HDFS_S  
 for /l %%x in (x, 1, y) do (  
   VBoxManage startvm "U14_HDFS_S%%x" --type headless  
 )  



Stopping VMs

A VM can also be stopped on the command line:
 VBoxManage controlvm "U14_HDFS_S1" poweroff   


Scripted Stopping

 @echo OFF  
 set name=U14_HDFS_S  
 for /l %%x in (x, 1, y) do (  
   VBoxManage controlvm "U14_HDFS_S%%x" poweroff  
 )  

No comments:

Post a Comment