?? Excited to Share My DevOps Course Project: Building a Multi-Tier Application Environment!??
Krishantha Bandara
IT Assistant @phoenix pvt ltd BSc (Hons) Computer Science and Software Engineering Degree (Grade - First Class)
Introduction
In today’s fast-paced digital landscape, the ability to deliver applications quickly and reliably is paramount. This is where DevOps comes into play, bridging the gap between development and operations to enhance collaboration and efficiency. In this article, I will share my journey of setting up a robust multi-tier application environment using various technologies, including Vagrant, Tomcat, Nginx, RabbitMQ, and MySQL. By the end of this post, you will have a clear understanding of the steps involved in creating a resilient application infrastructure.
Project Overview
The goal of my project was to build a scalable and maintainable web application that could handle a significant amount of traffic while ensuring data integrity and performance. The architecture I chose consists of several key components:
Environment Preparation
Prerequisites
Before diving into the setup, ensure you have the following installed on your machine:
To install the Vagrant Hostmanager plugin, run the following command:
$ vagrant plugin install vagrant-hostmanager
Cloning the Repository
Start by cloning the source code repository:
$ git clone https://github.com/KrishanthaBSomarathna/DevOps_Project
$ cd vprofile-project
$ git checkout main
Bringing Up the VMs
Navigate to the Vagrant directory and bring up the virtual machines:
$ cd vagrant/
$ vagrant up
Note: Bringing up all the VMs may take some time, depending on your system's resources.
Service Configuration
1. MySQL Setup
To set up MySQL, SSH into the database VM:
$ vagrant ssh db01
Verify the hosts entry and update it if necessary:
# cat /etc/hosts
Update the OS and install the necessary packages:
# yum update -y
# yum install epel-release -y
# yum install git mariadb-server -y
Start and enable the MariaDB service:
# systemctl start mariadb
# systemctl enable mariadb
2. Memcache Setup
Memcache is crucial for caching database queries. Install it using:
领英推荐
# yum install memcached -y
# systemctl start memcached
# systemctl enable memcached
3. RabbitMQ Setup
Next, set up RabbitMQ for message brokering:
$ vagrant ssh app01
# yum install rabbitmq-server -y
# systemctl start rabbitmq-server
# systemctl enable rabbitmq-server
Allow RabbitMQ through the firewall:
# firewall-cmd --add-port=5672/tcp --permanent
# firewall-cmd --reload
4. Tomcat Setup
SSH into the Tomcat VM and install the necessary dependencies:
$ vagrant ssh app01
# yum update -y
# yum install epel-release -y
# dnf -y install java-11-openjdk java-11-openjdk-devel
# dnf install git maven wget -y
Deploy your application by copying the WAR file:
# cp target/vprofile-v2.war /usr/local/tomcat/webapps/ROOT.war
# systemctl start tomcat
# systemctl enable tomcat
5. Nginx Setup
Finally, set up Nginx as a reverse proxy:
$ vagrant ssh web01
# apt update
# apt upgrade
# apt install nginx -y
Create a configuration file for your application:
# vi /etc/nginx/sites-available/vproapp
Add the following content:
upstream vproapp {
server app01:8080;
}
server {
listen 80;
location / {
proxy_pass https://vproapp;
}
}
Enable the configuration and restart Nginx:
# ln -s /etc/nginx/sites-available/vproapp /etc/nginx/sites-enabled/
# systemctl restart nginx
Testing and Validation
After setting up all the services, it’s crucial to test the application. Use tools like Postman or curl to send requests to your application and verify that it responds correctly. Monitor the logs for any errors and ensure that all services are running smoothly.
Lessons Learned
Throughout this project, I learned several valuable lessons:
Conclusion
Building a robust multi-tier application environment is a rewarding experience that enhances your understanding of DevOps practices. By following the steps outlined in this article, you can create a scalable and maintainable application infrastructure. I encourage you to explore these technologies further and share your experiences with the community.
#DevOps #Vagrant #Docker #MySQL #Nginx #Tomcat #RabbitMQ #LearningJourney