Schlagwort-Archive: Java

VirtualBox tutorial dedicated to the creation of an distributed environment for Java developing

Background
This VirtualBox tutorial is about the creation of an distributed environment for Java developing. Background is, that I am teaching Advanced Java Programming (named PROG2 at ZHAW). Topics of the PROG2 lecture are:

  1. Multi-Threading (Basic and Advanced Threading Concepts)
  2. Input/Output (JDBC, File-IO, TPC/UDP, Client-Server)
  3. Testing (Mockups, Mokito)
  4. Graphical User Interfaces (Swing/AWT/Android)

Motivations for this tutorial do exist many, but the first and foremost was the desire to test networked Java applications in a (close to real) distributed environment.

Basic System Layout
The basic setup is inspired by the virtual environment proposed for a local OpenStack deployment, described in detail in tutorial „Creating a VirtualBox-based Test Infrastructure„. It consists of:

  1. One Master Node (aka Controller Node)
  2. Two Worker Nodes (Compute Nodes)

Basic System Configuration

  1. Hardware: VT Enabled PC
  2. Host Operating Systems: OpenSuse
  3. Virtualization: VirtualBox
  4. Virtual Networking: Host only connections. a VirtualBox concept for providing purely internal networks between your host and Virtual Machines
  5. Guest Operating Systems: Ubuntu Server (LTS or not doesn’t make a difference here)

Hardware Support for Virtualization
Whether or not your local host machine provides hardware support for Virtualization Technologies (VT, vmx or svm) can be found out by running this command in a terminal „cat /proc/cpuinfo |grep -E „vmx|svm““. Here is what I got on my Dell Ultrabook (VMX support is indicated in bold)

tmb@tmbuell:~> cat /proc/cpuinfo |grep -E „vmx|svm“
flags : fpu vme de (…) eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est (…) flags : fpu vme de pse tsc (…) ds_cpl vmx smx est flags : fpu vme de pse (…) monitor ds_cpl vmx smx est tm2 (…) bmi2 ms invpcid rtm flags : fpu vme de pse tsc msr (…) monitor ds_cpl vmx smx est tm2 ssse3

The Guest OS
tmb@tmbuell:~> less /etc/SuSE-release
openSUSE 13.1 (x86_64)
VERSION = 13.1
CODENAME = Bottle
# /etc/SuSE-release is deprecated and will be removed in the future, use /etc/os-release instead

Virtualization based on VirtualBox
Installing VirtualBox on OpenSuse is trivial using zypper and a terminal:
tmb@tmbuell:~> zypper install virtualbox
zypper search virtualbox
Loading repository data…
Reading installed packages…

S | Name | Summary | Type
–+——————————+——————————————–+———–
i | python-virtualbox | Python bindings for virtualbox | package
i | virtualbox | VirtualBox is an Emulator | package
| virtualbox | VirtualBox is an Emulator | srcpackage
i | virtualbox-devel | Devel files for virtualbox | package
| virtualbox-guest-kmp-default | Guest kernel modules for VirtualBox | ackage
i | virtualbox-guest-kmp-desktop | Guest kernel modules for VirtualBox | package
| virtualbox-guest-kmp-pae | Guest kernel modules for VirtualBox | package
i | virtualbox-guest-tools | VirtualBox guest tools | package
i | virtualbox-guest-x11 | VirtualBox X11 drivers for mouse and video | package
| virtualbox-host-kmp-default | Host kernel module for VirtualBox | package
i | virtualbox-host-kmp-desktop | Host kernel module for VirtualBox | package
| virtualbox-host-kmp-pae | Host kernel module for VirtualBox | package
i | virtualbox-qt | Qt GUI part for virtualbox | package
| virtualbox-websrv | WebService GUI part for virtualbox | package

Viruaal Machine Creation and Configuration
The selected environment requires the creation of several VMs, whereas most of them do share the same basic characteristics and configuration. A smart approach is to configure and then to use „Cloning“ to create duplicates.

Since we’ll have several VMs that are associated with each other we have to configure a set of Virtual Networks. For that launch Virtual Box, navigate to File>Preferences>Network. Then choose the option to add „Host-Only Networks“. Create three Host-Only Network Connections; Vboxnet0-Vboxnet2.

Configure Vboxnet0 with IPv4 Address 10.10.10.1 and IPv4 Network Mask 255.255.255.0, Vboxnet1 with IPv4 Address 10.20.20.1 and IPv4 Network Mask 255.255.255.0, and Vboxnet2 IPv4 Address 192.168.100.1 and IPv4 Network Mask 255.255.255.0.

Stay Tuned, More To Come On
Network Configuration, SSH Access, Port Forwarding, Guest installation, Sharing between Guests and Guest, and Guest and Hosts (Shared Folder, USB, SFTP), Guest Additions, Java installation, Git and GitHub