๐ง 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:
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
Subscribe to my newsletter
Read articles from Shaharyar Shakir directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
