๐Ÿ”ง Day 25 โ€“ Manual Stack Setup with Vagrant: Intro & Database Layer

Kicking off a new DevOps mini-series! Learn how to manually set up a full stack Java project using multi-stage Vagrant VMs. Today, we cover the Vagrant environment, plugin setup, and the full MySQL database configuration.

Welcome to Day 25 of my DevOps Journey in Public! ๐Ÿš€

This week, Iโ€™m starting a mini-series on how I manually set up a Java-based project stack using Vagrant multi-VMs โ€” and then how I plan to automate it with provisioning.


๐Ÿงฑ Stack Overview

Weโ€™ll be building and connecting the following services across multiple Vagrant-managed virtual machines:

  • MySQL โ†’ SQL database

  • Memcached โ†’ Caching service

  • RabbitMQ โ†’ Broker/Queue

  • Tomcat โ†’ Application server

  • Nginx โ†’ Web server


๐Ÿ› ๏ธ Prerequisites for This Setup

Before getting started, I made sure to install:

  • Oracle VirtualBox

  • Vagrant

  • Git Bash or a Linux terminal

  • Vagrant plugins:

      vagrant plugin install vagrant-hostmanager
      vagrant plugin install vagrant-vbguest
    

๐Ÿ—‚๏ธ Project Structure

vprofile-project/
โ”œโ”€โ”€ vagrant/
โ”‚   โ””โ”€โ”€ Manual_provisioning/
โ”‚       โ”œโ”€โ”€ Vagrantfile

I cloned the repo and moved into the Manual_provisioning/ directory:

git clone -b main https://github.com/hkhcoder/vprofile-project.git
cd vprofile-project/vagrant/Manual_provisioning
vagrant up

If the VMs failed halfway, I just re-ran vagrant up again.


๐Ÿฌ Step 1: MySQL (MariaDB) Setup

๐Ÿ” SSH into the DB VM

vagrant ssh db01
sudo -i

๐Ÿงพ Install MariaDB

yum install mariadb-server -y
systemctl start mariadb
systemctl enable mariadb

๐Ÿ”’ Secure Installation

mysql_secure_installation
# Root password: admin123

๐Ÿ—„๏ธ Create DB and User

mysql -u root -padmin123
> CREATE DATABASE accounts;
> GRANT ALL PRIVILEGES ON accounts.* TO 'admin'@'%' IDENTIFIED BY 'admin123';
> FLUSH PRIVILEGES;
> exit

๐Ÿ“ฆ Import DB Dump

git clone -b main https://github.com/hkhcoder/vprofile-project.git
cd vprofile-project
mysql -u root -padmin123 accounts < src/main/resources/db_backup.sql

๐Ÿ”ฅ Firewall Configuration

systemctl start firewalld
systemctl enable firewalld
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload

๐Ÿ“Œ Wrapping Up Day 25

โœ… Weโ€™ve:

  • Set up the project environment

  • Installed required plugins

  • Brought up our VMs

  • Installed and configured MariaDB with a test DB and user

Next up? Memcached and RabbitMQ setup in Day 26. See you there! ๐Ÿ‘‹

โžก๏ธ Follow along the series and give feedback! #LearnInPublic #DevOps #Vagrant

0
Subscribe to my newsletter

Read articles from Shaharyar Shakir directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Shaharyar Shakir
Shaharyar Shakir