Pages

Saturday, January 18, 2014

[VirtualBox] Make SSH connections among the cluster of guest OS

To build up a distributed system, we need the network to connect the nodes.  However, sometimes I cannot have internet access, so I decided to build a local cluster in my laptop.  The first thing is to create a local network among the cluster.  I will list the minimum steps and briefly explain how it works.


Host OS: OSX 10.7
Guest OS: Ubuntu server 12.04

How to build up in-cluster network?

The spirit:
Create a network interface for in-cluster network

On every guest OS panel
Setting -> Network
Besides the first network card with NAT, add second network card with Bridged Adapter.
This will create a new network interface on your GUEST, say eth2

Edit the network interface configuration
Assume the interface is eth2, and we want to set the ip as 192.168.56.100

Add these
/etc/network/interfaces
auto eth2 #automatically activate this interface iface eth2 inet static #this is a static ip, not dhcp, nor loopback address 192.168.56.100#change the number 100 to whatever you want (less than 255) netmask 255.255.255.0

Restart the network process to read the new configuration.
sudo /etc/init.d/networking restart

You can also manually activate the interface by
sudo ifconfig eth2 inet 192.168.56.100

What to communicate with the host?

The spirit: Create another network interface on host, also create new network interface on guest.

Create new network interface on host
On the VirtualBox main panel
Preference -> Network -> Create a new adapter (e.g. vboxnet0)
This will create a new network interface on your HOST, say vboxnet
type ifconfig to check it
In this case, we have vboxnet (doesn't matter), and 192.168.56.1 as the ip

Create new network interface on guest
Similar to in-cluster network, but we choose 'Host-Only' here.

Conclusion

Use different types of network adapter (interface) for different types of communication.
guest-to-guest: Bridge-Adapter
guest-public (outside of the host): NAT
guest-host: Host-Only Adapter

Now, you supposed to be able to connect the host via 192.168. 56.1; You can also connect to the other node via 192.168.56.100

No comments:

Post a Comment