8000 GitHub - myacov/vprofile-local
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

myacov/vprofile-local

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VProfile-Local

Objective:

VProfile-Local is a web application stack designed for local development, aiming to handle multiple services. finally to automate the setup process using Infrastructure as Code (IaC).

Architecture:

Project Architecture Diagram

The Stack:

Tool Use Why Choose It
🧊 VirtualBox Hypervisor for Virtualization Easy to use
🆅 Vagrant Automation Lightweight
🐧 Linux (Ubuntu) OS Popular Linux distribution
🐧 Linux (CentOS 9) OS Popular Linux distribution
🌐 Nginx Load Balancer Web Service
🐈 Apache Tomcat Application Server Popular for Java apps
📨 RabbitMQ Broker/Queuing Agent For messaging tasks
Ⓜ️ Memcached DB Caching For database caching
🐬 MySQL Server SQL Database For data storage

Prerequisites:

  • Computer with at least 8GB RAM and approximately 10GB of free disk space (for running Linux in a virtual machine).
  • Oracle VM VirtualBox
  • Vagrant
  • Vagrant plugin - vagrant-hostmanager (Adds hostnames and IP addresses from the Vagrantfile to every VM hostfile, i.e., /etc/hosts).
  • Git bash

Getting Started:

  1. Clone the source code:
    git clone -b main https://github.com/myacov/vprofile-local.git
  2. Bring up the virtual machines
     vagrant up

Setup VMs

A. MYSQL Setup

  1. Login to the 'db01' VM:
    vagrant ssh db01
  2. Verify the hosts entry; if entries are missing, update them with the appropriate IP and hostnames:
    cat /etc/hosts
  3. Update the OS with the latest patches:
    sudo yum update -y
  4. Set up the repository:
    sudo yum install epel-release -y
  5. Install MariaDB:
    sudo yum install git mariadb-server -y
  6. Start and enable the MariaDB server:
    sudo systemctl start mariadb
    sudo systemctl enable mariadb
    sudo systemctl status mariadb
  7. Run the MySQL secure installation script:
    sudo mysql_secure_installation

    NOTE: Set db root password Example password : admin123

  8. Setup Databa 8000 se name and users.
    mysql -u root -padmin123

grant privileges to user admin (% = remote)

sql>    create database accounts;
sql>    grant all privileges on accounts.* TO 'admin'@'%' identified by 'admin123' ;
sql>    FLUSH PRIVILEGES;
sql>    exit;
  1. Download Source code & Initialize Database.
sudo -i
git clone -b main https://github.com/myacov/vprofile-local.git
cd vprofile-local
mysql -u root -padmin123 accounts < src/main/resources/db_backup.sql
mysql -u root -padmin123 accounts
sql>    show tables;
  1. Restart the MariaDB server:
systemctl restart mariadb

B. Memcache Setup

  1. Login to the 'mc01' vm
    vagrant ssh mc01
  2. Install, start, and enable Memcached on port 11211:
sudo -i
dnf install epel-release -y
dnf install memcached -y
systemctl start memcached
systemctl enable memcached
systemctl status memcached
  1. Allow listening for connections from different VMs (for Tomcat):
sed -i 's/127.0.0.1/0.0.0.0/g' /etc/sysconfig/memcached
sudo systemctl restart memcached

C. RabbitMQ Setup

  1. Login to the RabbitMQ vm
    vagrant ssh rmq01
  1. Update the OS and set up the EPEL repository:
    sudo -i
    yum update -y
    yum install epel-release -y
  1. Install Dependencies and RabbitMQ repository:
   dnf -y install centos-release-rabbitmq-38
  1. Enable RabbitMQ repositry and instll rabbitMQ Server
    dnf --enablerepo=centos-rabbitmq-38 -y install rabbitmq-server
  1. Start and Enable RabbitMQ Server
    systemctl start rabbitmq-server
    systemctl enable rabbitmq-server
    systemctl status rabbitmq-server
  1. For VProfile-specific configuration, create a file and redirect output:
   sh -c 'echo "[{rabbit, [{loopback_users, []}]}]." > /etc/rabbitmq/rabbitmq.config'
  1. RabbitMQ commands - add user and set "administrator" tag . then restart the service
   rabbitmqctl add_user test test
   rabbitmqctl set_user_tags test administrator
   systemctl restart rabbitmq-server

D. Tomcat Setup

  1. Setting up Tomcat Service
    1. Login to the Tomcat vm
        vagrant ssh app01
    1. Update the OS:
        sudo yum update -y
    1. Set up the repository:
        sudo yum install epel-release -y
    1. Install Dependencies: OpenJDK 11, Git, Wget, and Maven:
        dnf -y install java-11-openjdk java-11-openjdk-devel
        dnf install git maven wget -y
    1. Download & Install Tomcat Package
        cd /tmp/
        wget https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.75/bin/apache-tomcat-9.0.75.tar.gz
        tar xzvf apache-tomcat-9.0.75.tar.gz
        useradd --home-dir /usr/local/tomcat --shell /sbin/nologin tomcat
        cp -r /tmp/apache-tomcat-9.0.75/* /usr/local/tomcat/
        chown -R tomcat.tomcat /usr/local/tomcat
    1. Setup systemctl command for Tomcat: Copy and paste the following script to tomcat.service file (path= /etc/systemd/system/tomcat.service):
        [Unit]
        Description=Tomcat
        After=network.target
        [Service]
        User=tomcat
        WorkingDirectory=/usr/local/tomcat
        Environment=JRE_HOME=/usr/lib/jvm/jre
        Environment=JAVA_HOME=/usr/lib/jvm/jre
        Environment=CATALINA_HOME=/usr/local/tomcat
        Environment=CATALINE_BASE=/usr/local/tomcat
        ExecStart=/usr/local/tomcat/bin/catalina.sh run
        ExecStop=/usr/local/tomcat/bin/shutdown.sh
        SyslogIdentifier=tomcat-%i
        [Install]
        WantedBy=multi-user.target
    1. Reload systemd files, then start and enable the Tomcat service:
        systemctl daemon-reload
        systemctl start tomcat
        systemctl enable tomcat
  2. Building & Deploying the Application on Tomcat:
    1. Download Source code
          git clone -b main https://github.com/myacov/vprofile-local.git
    2. Build the code:
          cd vprofile-local
          mvn install
    3. Deploy the artifact:
          systemctl stop tomcat
          rm -rf /usr/local/tomcat/webapps/ROOT*
          cp target/vprofile-v2.war /usr/local/tomcat/webapps/ROOT.war
          systemctl start tomcat

E. Nginx Setup

  1. Login to the Nginx vm
    vagrant ssh web01
  1. Update the OS and install Nginx:
    sudo -i
    apt update
    apt upgrade -y
    apt install nginx -y
  1. Create an Nginx conf file and copy and paste the following script (path= /etc/nginx/sites-available/vproapp)::
    upstream vproapp {
      server app01:8080;
    }
    server {
       listen 80;
       location / {
     proxy_pass http://vproapp;
    }
   }
  1. Remove the default Nginx configuration link:
    rm -rf /etc/nginx/sites-enabled/default
  1. Create a symbolic link to our configuration:
    ln -s /etc/nginx/sites-available/vproapp  /etc/nginx/sites-enabled/vproapp
  1. Restart Nginx:
    systemctl restart nginx

Automating this process - Provisioning

The automated branch includes shell scripts for the Vagrantfile to execute during the provisioning stage.

License:

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0