dbi services Blog
Welcome to the dbi services Blog! This IT blog focuses on database, middleware, and OS technologies such as Oracle, Microsoft SQL Server & SharePoint, EMC Documentum, MySQL, PostgreSQL, Sybase, Unix/Linux, etc. The dbi services blog represents the view of our consultants, not necessarily that of dbi services. Feel free to comment on our blog postings.
Manage templates manually with Oracle Virtual Box
To create environments for testing, development, or demonstration, several identical virtual machines are required. Use a technology as VMware vSphere or Microsoft Hyper-V, for implementing a dedicated virtualized infrastructure and use templates, would be the best choice.
This solution offers both advanced administration and security capabilities, and allows a centralized access for users. However such an infrastructure needs dedicated servers and networks and could represent high costs. Furthermore it is not always usable from outside the company.
So what if a consultant needs to make a demo to his client, only using his laptop without Internet access?
I searched for a free solution to create easily multiple identical virtual machines on my laptop. To do that, I tried to manage templates with Oracle Virtual Box and found an easy solution, that I wanted to share with you. It consists in one script created on the host, and one script created on the template.
Two steps are necessary:
On the host side
A) First create a template machine on the host
B) Next create a configuration file which stores all information to customize the new virtual machine (template to use, new hostname, new IP...)
C) Finally, create and run a configuration script. This script will:
- create one or more virtual machines based on the template, reading lines registered on the configuration file. The Virtual Box command used for each line is:
"C:\Program Files\Oracle\VirtualBox\VBoxManage" clonevm --name --basefolder --register
- attribute to each new virtual machine a shared folder (between the host and the new virtual machine). The Virtual Box command used is:
"C:\Program Files\Oracle\VirtualBox\VBoxManage" sharedfolder add --name --hostpath
The specific parameters file is also generated by the script, for each new virtual machine.
- generate a specific parameter file into the shared folder. Simple OS command could be used for this step.
- start the new virtual machine. The Virtual Box command used is:
"C:\Program Files\Oracle\VirtualBox\VBoxManage" startvm --type headless
See the Virtual Box manual to know more about available commands
On the guest side
The guest is started automatically by the previous script. At its first startup, a local script previously created on the template is run. This script will:
- access the shared folder
- read the specific parameters file and get values from it
- launch system commands (such as hostname changing) to customize the new virtual machine
- restart the new virtual machine to achieve the customization
This script can include all actions you need, for example renaming the hostname, changing network configuration, but required parameters must be registered on the specific parameters file.
The following schema illustrates the different steps on host and guest sides:
Such a solution offers several advantages for a consultant:
- This is a mobile solution: people can locally manage environments without Internet access.
- This is a free and durable solution: Oracle Virtual Box is free and regularly updated (4.1.22 released on 2012 7th September)
- This is an easy way to create multiple machines without fastidious actions: people just need one script and one configuration file to generate multiple identical virtual machine
It is just limited by laptop capacities, in term of disk and memory.
Note that it cannot be used to make complex virtualized environments, because concurrent access on disk will considerably reduce performances of each virtual machine.
dbi services chose this solution to create small training environments. It allows to generate new environments for each session using identical templates, and allows each consultant to offer a training everywhere: no need to transport big servers, and no connection to the client’s network is necessary. Only a powerful laptop and a switch are required!
In a future article, I will detail the content of each script, using an example based on a real situation.