DevOps 3.3: App Setup
"Configuring Your App: DevOps 3.3 - Smooth Application Setup with Tomcat"
Table of contents
TOMCAT SETUP:
Login to the Tomcat VM:
Login to the Tomcat vm
vagrant ssh app01
Verify Hosts entry, if entries missing update them with IP and hostnames using
cat /etc/hosts
.Update the OS to the latest patches using
yum update -y
.Set Repository
using
yum install epel-release -y
.Install dependencies
dnf -y install java-11-openjdk java-11-openjdk-devel
.dnf install git maven wget -y
Change dir to /tmp
cd /tmp/
Download the Tomcat package
wget
https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.75/bin/apache-tomcat-9.0.75.tar.gz
Now extract it using
tar xzvf apache-tomcat-9.0.75.tar.gz
.Add tomcat user
useradd --home-dir /usr/local/tomcat --shell /sbin/nologin tomcat
.Copy data to tomcat home dir using
cp -r /tmp/apache-tomcat-9.0.75/* /usr/local/tomcat/
.Create Tomcat service file
vi /etc/systemd/system/tomcat.service
.Update the file with the below content
[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
Reload the files
systemctl daemon-reload
.Start and enable the service
# systemctl start tomcat # systemctl enable tomcat
Enabling the firewall and allowing port 8080 to access the tomcat.
# systemctl start firewalld # systemctl enable firewalld # firewall-cmd --get-active-zones # firewall-cmd --zone=public --add-port=8080/tcp --permanent # firewall-cmd --reload
CODE BUILD & DEPLOY (app01)
Download Source code
git clone -b main
https://github.com/saswatsam786/devops-project-localUpdate configuration
# cd vprofile-project # vim src/main/resources/application.properties # Update file with backend server details
Build code
mvn install
run it.Deploy artifact
systemctl stop tomcat
Deploy 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 # chown tomcat.tomcat /usr/local/tomcat/webapps -R