Installing VBox and Vagrant — Creating Two Machines — Ubuntu
- Install Virtual Box:
Step 1: Update your system Open a terminal and run the following command to update your package lists:
sudo apt update
Step 2: Install dependencies Execute the following command to install the necessary dependencies:
sudo apt install build-essential dkms linux-headers-$(uname -r)
Step 3: Add the VirtualBox repository Add the official VirtualBox repository to your system using the following command:
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
Step 4: Add the repository to the software sources Run the following command to add the repository to your software sources:
echo “deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian focal contrib” | sudo tee /etc/apt/sources.list.d/virtualbox.list
Note: The repository used here is for Ubuntu 20.04 (Focal Fossa). Adjust the repository URL accordingly if you are using a different version.
Step 5: Update package lists Update the package lists again to include the newly added repository:
sudo apt update
Step 6: Install VirtualBox Install VirtualBox by executing the following command:
sudo apt install virtualbox
Step 7: Add your user to the vboxusers group For VirtualBox to work properly, you need to add your user to the vboxusers group. Execute the following command:
sudo usermod -aG vboxusers $USER
Step 8: Launch VirtualBox You can now launch VirtualBox by searching for it in the applications menu or by running the following command:
virtualbox
Note: If you are a Windows user please follow the guidelines for the installation from VirtualBox Official Site.
2. Install Vagrant
Step 1: Go to https://www.vagrantup.com/downloads.html and download the binary file of vagrant.
Step 2: Unzip the downloaded zip file using the unzip command in your terminal.
Step 3: Copy the vagrant file in /usr/local/bin.
Step 4: Check the vagrant version using the command vagrant — version
3. Create a Vagrant project folder and a Vagrantfile on it.
Here, the config is set up for two nodes — master and worker with dedicated static IP addressing.
Use the vagrant up command to run the vagrant configuration and scale up the machines.
4. SSH to the servers and check the connections.
- Login to the master by using the command vagrant ssh master and set the hosts on /etc/hosts.
- Login to the worker by using the command vagrant ssh worker and set the hosts on /etc/hosts.
5. Ping the machines.
The End!!
Compiled by: Suryansh Mathema
Date: 18/07/2023