Java, MySQL, Elasticsearch, and Apache Tomcat
Introduction
This document outlines the steps to upgrade Java, Elasticsearch, and Apache Tomcat to enhance performance, ensure compatibility, and maintain security compliance.
Steps Involved
Java Upgrade (from 1.8.0_412 to 1.8.0_412+)
-
Log in to the server using a user with administrative privileges.
-
Back up the Java cacerts file, which stores trusted security certificates used by the Java Runtime Environment (JRE)
-
Run: sudo cp /usr/lib/jvm/openjdk/jre/lib/security/cacerts path/to/backup_folder
-
-
Use the system package manager (yum) to install or upgrade Java to the latest available version of OpenJDK 1.8:
-
Run: sudo yum -y install java-1.8.0-openjdk
-
-
After the installation is complete, verify the installed version:
-
Run: java -version
-
-
Ensure that the output shows the updated version 1.8.0_412 or newer.
Elasticsearch Upgrade (from 7.17.21 to 7.17.21+)
-
Stop the currently running Elasticsearch service to prevent conflicts during the upgrade:
-
Run: sudo systemctl stop elasticsearch.service
-
-
Upgrade Elasticsearch using the system’s package manager:
-
Run: sudo yum install elasticsearch -y
-
-
After installation, start the Elasticsearch service:
-
Run: sudo systemctl restart elasticsearch
-
-
Validate that Elasticsearch is running and responding correctly:
-
Run: curl -X GET "localhost:9200
-
-
The response should display the new version (7.17.21 or later).
-
Optionally, confirm the upgrade completion:
-
Example: echo "Successfully updated the Elasticsearch version
-
MySQL Enterprise Edition Upgrade (8.0.31 → 8.0.40+)
This section covers the upgrade process of MySQL Enterprise Edition used explicitly for the OvalEdge application.
Step#1: Identify the OvalEdge Database
- Log in to MySQL: mysql -u root -p
- List all databases and note the name used by OvalEdge (e.g., ovaledge_db): SHOW DATABASES;
Step#2: Backup the OvalEdge Database
- Dump the OvalEdge-specific database: mysqldump -u root -p ovaledgedb > /home/ec2-user/ovaledge_db_backup.sql
- Note: Replace ovaledgedb with the actual database name used in your OvalEdge configuration.
Step#3: Backup MySQL Data Directory
- Find the MySQL data directory (typically /var/lib/mysql), and back it up:
sudo systemctl stop mysqld
sudo cp -r /var/lib/mysql /home/ec2-user/mysql_data_backup_8_0_31
Step#4: Uninstall MySQL 8.0.31
- Remove the existing MySQL version: sudo yum remove mysql-server -y
- Optionally, clean up old packages: sudo yum autoremove -y
Step#5: Install MySQL 8.0.40+ Enterprise Edition
- Install the new MySQL version using your organization's enterprise repo or Oracle-provided RPM files.
Example: sudo rpm -ivh mysql-commercial-server-8.0.40-1.el7.x86_64.rpm - Start MySQL: sudo systemctl start mysqld
Step 6: Restore the OvalEdge Database
-
Restore the previously backed-up OvalEdge database: mysql -u root -p < /home/ec2-user/ovaledge_db_backup.sql
Apache Tomcat Upgrade (from 9.0.93 to 9.0.102)
Environment Variables Used
Variable |
Description |
$HOME_DIR |
Home directory path of the VM (e.g., /home/ec2-user) |
$Previous_tomcat |
Full path to the current (old) Tomcat installation (e.g., /home/ec2-user/tomcat) |
$NEW_TOMCAT |
Name of the new Tomcat directory: apache-tomcat-9.0.102 |
$tomcat_file |
URL to download the apache-tomcat-9.0.102.tar.gz archive |
$oe_war |
URL for downloading the OvalEdge WAR file |
$BACKUP_DIR |
Directory path to back up the current Tomcat (e.g., /home/ec2-user/tomcat_backup) |
$linux_user |
Linux user who owns the Tomcat directories (e.g., ec2-user) |
tomcat_latest |
A subdirectory under $HOME_DIR to prepare for the upgrade |
Tomcat Upgrade Instructions
-
Create Upgrade Working Directory
- >> mkdir -p $HOME_DIR/tomcat_latest
- Download Apache Tomcat 9.0.102 Archive
- >> cd $HOME_DIR/tomcat_latest
- >> wget https://downloads.apache.org/tomcat/tomcat-9/v9.0.102/bin/apache-tomcat-9.0.102.tar.gz
- Extract the Tar File
- >> tar -xvf $HOME_DIR/tomcat_latest/apache-tomcat-9.0.102.tar.gz
- This will create the directory: $HOME_DIR/tomcat_latest/apache-tomcat-9.0.102
- Copy setenv.sh from Old to New Tomcat.
- >> cp -rf "$Previous_tomcat/bin/setenv.sh" "$HOME_DIR/tomcat_latest/apache-tomcat-9.0.102/bin/"
- Remove Unused Webapps from the New Tomcat
- >> sudo rm -rf "$HOME_DIR/tomcat_latest/apache-tomcat-9.0.102/webapps/manager"
- >> sudo rm -rf "$HOME_DIR/tomcat_latest/apache-tomcat-9.0.102/webapps/host-manager"
- >> sudo rm -rf "$HOME_DIR/tomcat_latest/apache-tomcat-9.0.102/webapps/examples"
- >> sudo rm -rf "$HOME_DIR/tomcat_latest/apache-tomcat-9.0.102/webapps/docs"
- >> sudo rm -rf "$HOME_DIR/tomcat_latest/apache-tomcat-9.0.102/webapps/ROOT"
- Download the OvalEdge WAR File.
- >> cp $Previous_tomcat/webapps/ovaledge.war $HOME_DIR/tomcat_latest/apache-tomcat-9.0.102/webapps/
- Set Ownership and Permissions
- sudo chown -R "$linux_user:$linux_user" "$HOME_DIR/tomcat_latest" sudo chmod -R 755 "$HOME_DIR/tomcat_latest"
- Backup the Current (Old) Tomcat Installation
- sudo mv "$Previous_tomcat" "$BACKUP_DIR"
- Add Cache Parameter in context.xml
- sed -i '/<\/Context>/ i \ <Resources cacheMaxSize="102400" />' "$HOME_DIR/tomcat_latest/apache-tomcat-9.0.102/conf/context.xml"
- Reset File Ownership on Backup and New Webapps
- sed -i '/<\/Context>/ i \ <Resources cacheMaxSize="102400" />' "$HOME_DIR/tomcat_latest/apache-tomcat-9.0.102/conf/context.xml"
- Start New Tomcat and Verify Logs
Start the Tomcat and check the logs with the below command:
- >> tail -f "$HOME_DIR/tomcat_latest/apache-tomcat-9.0.102/logs/catalina.out
Copyright © 2025, OvalEdge LLC, Peachtree Corners, GA, USA