Operations 9 min read

Step‑by‑Step Guide to Building a Local Linux Cluster with VirtualBox

This tutorial walks you through creating four VirtualBox Linux VMs, configuring networking, disabling firewalls, installing Java and Perl, setting up password‑less SSH, and preparing a reusable cluster environment that can later host Redis, Kafka, or Storm clusters.

Wukong Talks Architecture
Wukong Talks Architecture
Wukong Talks Architecture
Step‑by‑Step Guide to Building a Local Linux Cluster with VirtualBox

In this article the author, Wu Kong, explains how to create a four‑node Linux cluster on a local machine using VirtualBox, enabling you to simulate distributed and high‑concurrency scenarios for future e‑commerce projects.

Creating the Virtual Machines

Install VirtualBox, add a Linux ISO image, and create four VMs. Choose Bridge networking and start each VM. During the first boot set the hostname eshop-cache01 and the password huang123 .

Network Configuration

Because the VMs initially cannot reach the Internet, edit the network script to obtain a dynamic IP:

vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=dhcp

Restart the network and verify connectivity:

service network restart
ifconfig

Switch to a static IP (e.g., 192.168.10.86) by modifying the same file:

BOOTPROTO=static
IPADDR=192.168.10.86
NETMASK=255.255.255.0
GATEWAY=192.168.10.1
service network start

Update /etc/hosts to map hostnames to IPs:

vi /etc/hosts
192.168.10.86 eshop-cache01

Installing Supporting Tools

Install SecureCRT (download from Baidu Cloud) for convenient SSH access, and WinSCP for file transfers.

Disable firewalls and SELinux to avoid inter‑node communication issues:

service iptables stop
service ip6tables stop
chkconfig iptables off
chkconfig ip6tables off
vi /etc/selinux/config
SELINUX=disabled

Configure YUM to use Alibaba mirrors, clean the cache, and install basic utilities:

sed -i "s|enabled=1|enabled=0|g" /etc/yum/pluginconf.d/fastestmirror.conf
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo https://www.xmpan.com/Centos-6-Vault-Aliyun.repo
yum clean all
yum makecache
yum install -y wget

Installing Java JDK 7

Copy the JDK RPM to /usr/local and install it:

rpm -ivh jdk-7u65-linux-i586.rpm
rm -rf jdk-7u65-linux-i586.rpm

Set environment variables:

vi ~/.bashrc
export JAVA_HOME=/usr/java/latest
export PATH=$PATH:$JAVA_HOME/bin
source ~/.bashrc
java -version

Installing Perl 5.16.1

Extract the source, install GCC, configure, compile and install:

tar -zxvf perl-5.16.1.tar.gz
yum install -y gcc
cd perl-5.16.1
./Configure -des -Dprefix=/usr/local/perl
make && make test && make install
rm -rf perl-5.16.1.tar.gz

Setting Up Password‑less SSH

On each node generate an RSA key pair and copy the public key to authorized_keys :

ssh-keygen -t rsa
cd /root/.ssh
cp id_rsa.pub authorized_keys

Test the login:

ssh eshop-cache01

Copy each node’s public key to the others to enable mutual password‑less access:

ssh-copy-id -i eshop-cache01
scp authorized_keys eshop-cache02:/root/.ssh
scp authorized_keys eshop-cache03:/root/.ssh
scp authorized_keys eshop-cache04:/root/.ssh

Final Cluster Verification

After configuring /etc/hosts on all machines and confirming SSH connectivity, the four nodes can communicate freely, completing the basic cluster environment.

Encountered Issue

The VMs lost external network access; switching the host’s network from wireless to wired and setting the VirtualBox network adapter to a bridged wired interface resolved the problem.

operationsnetworkLinuxclusterSSHVirtualBox
Wukong Talks Architecture
Written by

Wukong Talks Architecture

Explaining distributed systems and architecture through stories. Author of the "JVM Performance Tuning in Practice" column, open-source author of "Spring Cloud in Practice PassJava", and independently developed a PMP practice quiz mini-program.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.