I can setup a multi-tier app locally for you
How I Set Up a Multi-Tier App Locally Using Linux, Bash Scripting, Vagrant, VirtualBox, and More
How this project helps me ?
I wanted to do something on my own, and have something running to showcase my skills and gain confidence, so came across this idea of setting up a webapp on local, tools I used are :
Hypervisor : Oracle VM Virtualbox
Automation tool : Vagrant
Cli : gitbash
Editor : Vscode
What will I deploy ?
A multi-tier social networking java application, let me explain its stack, services used are :
Nginx
Tomcat
MySql
Memcache
Rabbitmq
The Architecture :
How did I do the manual setup?
Github Repo, this contains everything - the source code, vagrant file, bash files, etc
clone the repository to the system
here, i get the document to setup our services, also the multivm vagrant file
using the hostmanager plugin by vagrant, hostnames are mapped to ip addresses that can be found in the /etc/hosts file
All services run on centos boxes, web01 runs on ubuntu box
Brought all vms up by running Vagrant up
Now, validate the vms by doing ssh to all and check the connectivity by doing ping test
And, we have vms ready for our services to be setup !
The services setup is done from the backend to the frontend, we start with :
DB setup :
Time to setup db01, yum update, install epel release repository, install mariadb-server git, start and enable mariadb, mysql_secure_installation, give password admin123 and do yes, now setup the database, login using user and password, create database accounts, show database, run queries to give priviliges, clone git repo, login to the db accounts and input redirect dbbackup file, restart the service
Memcache setup :
Install epel release repo, install memcached, start and enable memcached, change config /etc/sysconfig/memcached allow connection from all instead of local, restart service
Rabbitmq setup :
now for rabbitmq, update the os, install epel release, install rabbitmq repo, enable the repo and install rabbitmq server, start and enable the service, make a change to the config file, add test user and add a tag, restart the service
Tomcat setup :
Setting up tomcat and deploying our app, update os, install epel repository, install openjdk, install git maven wget, get the tomcat url, extract the tarball, now setup the systemctl service by adding a user, copying files to its home directory, change the user, make a tomcat system config file and add configuration, daemon reload, now use systemctl to start and enable service, clone source code, check the application properties file, mvn install, will get a target folder with a war file, stop tomcat service, now remove default usr/local/tomcat/webapps/ROOT and copy the war file there from target with name ROOT.war, start the service
Nginx setup :
now web01, update and upgrade the os with apt, install nginx, make custom nginx config, it contains that we listen on port 80 and route to vproapp that is app01 on 8080, our config is in /etc/nginx/sites-available/vproapp and the default config is in /etc/nginx/sites-enables/default we need to remove the default and create a link from our config to default, now restart the service
the setup is done go to web01 get its ip and enter the ip into the browser with port 80 and validate
BUT...
The setup took a long time, it is not repeatable
We improve the setup by automating it,
What's special in the Automated Setup ?
Just by adding path to the Bash scripts in the multivm file, the setup can be done in few steps, can be easily repeated as we have our INFRASTRUCTURE AS A CODE
All the bashscripts contain the setup for services
The files are in this repo : Githubrepo
Just hit the command Vagrant up and your multi-tier application stack is ready to be used
Here I enter, the hostname or the web01 ip into the browser that listens on port 80 and validate all the services :
This gave me a dopamine hit :
Here, our website is up and running, database is validated, memcache is validated, rabbitmq is validated, nginx and tomcat are working
next project soon...
please give your valuable feedback