# Tomcat 10.1.x on Amazon Linux

This document provides step-by-step instructions for installing and configuring the **OvalEdge application** on **Amazon Linux** using Apache Tomcat 10.1.x. It covers user creation, Java and Tomcat setup, database and Elasticsearch integration, and deployment of the OvalEdge application.

## Prerequisites

* **User Access**: Installer must have **sudo privileges**.
* **System**: Amazon Linux VM with sufficient CPU, memory (≥8 GB), and disk space for two Tomcat instances.
* **Network**: Internet access; required ports open: 8080 (UI), 8081 (Job), 3306 (MySQL), 9200 (Elasticsearch, if used).
* **Artifacts**: `ovaledge.war`, external JARs, `log4j.properties`, and `oasis.properties` available in the user’s home directory.
* **Database & Elasticsearch**: Target MySQL and Elasticsearch must be accessible with credentials for `oasis.properties`.

## Steps Involved

1. **Create OvalEdge User**
   * Create a new system user for OvalEdge:

     ```bash
     sudo adduser ovaledge
     ```
   * Set a password for the new user:

     ```bash
     sudo passwd ovaledge
     ```
   * Add the user to the `wheel` group for administrative privileges:

     ```bash
     sudo usermod -aG wheel ovaledge
     ```
   * Switch to the OvalEdge user account:

     ```bash
     sudo su - ovaledge
     ```

2. **Create Required Directories**
   * Create the following directories under the OvalEdge user home directory or a mounted directory:

     ```bash
     mkdir -p ovaledge/extprop
     mkdir -p ovaledge/temp
     mkdir -p ovaledge/third_party_jars
     ```
   * Download all shared artifacts (`.jars` & `.war`) into the `ovaledge` folder under the user's home directory.
   * Download the `log4j.properties` and `oasis.properties` files into the `ovaledge/extprop` folder.<br>

3. **Java Installation**
   * Update system packages:

     ```bash
     sudo yum update
     ```
   * Install **Java 17 (Amazon Corretto)**:

     ```bash
     sudo yum install java-17-amazon-corretto -y
     ```
   * Verify the Java installation:

     ```bash
     java -version
     ```

4. **Tomcat Setup**
   * Tomcat UI Installation
     * Download Tomcat in the `ovaledge` directory:

       ```bash
       wget https://archive.apache.org/dist/tomcat/tomcat-10/v10.1.40/bin/apache-tomcat-10.1.40.tar.gz
       ```
     * Extract the downloaded archive:

       ```bash
       tar xvf apache-tomcat-10.1.40.tar.gz
       ```
     * Rename the extracted folder to `tomcatui`:

       ```bash
       mv apache-tomcat-10.1.40 tomcatui
       ```
     * Move the `ovaledge.war` file to the `webapps` folder:

       ```bash
       mv /home/<user>/ovaledge/ovaledge.war /home/<user>/ovaledge/tomcatui/webapps
       ```
     * Create `setenv.sh` in `tomcatui/bin/` with the following parameters:

       ```bash
       export CATALINA_OPTS="-Duse.http=true \
       -DOVALEDGE_SECURITY_TYPE=db \
       -Dext.properties.dir=file:/home/<user>/ovaledge/extprop/ \
       -Xms7g -Xmx9g \
       -Dpod.type=ovaledge-ui-deployment \
       -Dlog4j.configuration=file:/home/<user>/ovaledge/extprop/log4j.properties"

       ```
   * Tomcat Job Installation
     * Copy `tomcatui` to create `tomcatjob`:

       ```bash
       cp -R tomcatui tomcatjob
       ```
     * Edit the `server.xml` file in `tomcatjob/conf/` to update ports:
       * Change HTTP port from `8080` → `8081`\
         &#x20;\
         ![](https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FpLhfjc9JjJSjmQMI5o4c%2Fimage.png?alt=media\&token=80f91ac9-202a-4e9f-aecf-67c3d10af2d5)
       * Change shutdown port from `8005` → `8006`&#x20;

         <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FfxFJeNBrkhg0lgHBVOG1%2Fimage.png?alt=media&#x26;token=94adcf1c-8c3e-4660-86df-a78eb7561216" alt=""><figcaption></figcaption></figure>
     * In `tomcatjob/bin/`, create `setenv.sh` with the following:

       ```bash
       export CATALINA_OPTS="-Duse.http=true \
       -DOVALEDGE_SECURITY_TYPE=db \
       -Dext.properties.dir=file:/home/<user>/ovaledge/extprop/ \
       -Xms7g -Xmx9g \
       -Dpod.type=ovaledge-job-deployment \
       -Dlog4j.configuration=file:/home/<user>/ovaledge/extprop/log4j.properties"
       ```

5. **Tomcat as a Service**
   * Go to `/etc/systemd/system` and create service files:
     * **Tomcat UI (`tomcat1.service`)**:

       ```ini
       [Unit]
       Description=Apache Tomcat Web Application Container
       After=network.target

       [Service]
       Type=forking
       ExecStart=/home/<user>/ovaledge/tomcatui/bin/startup.sh
       ExecStop=/home/<user>/ovaledge/tomcatui/bin/shutdown.sh
       User=<username_vm>
       Group=<username_vm>

       [Install]
       WantedBy=multi-user.target
       ```
     * **Tomcat Job (`tomcat2.service`)**:

       ```ini
       [Unit]
       Description=Apache Tomcat Web Application Container
       After=network.target

       [Service]
       Type=forking
       ExecStart=/home/<user>/ovaledge/tomcatjob/bin/startup.sh
       ExecStop=/home/<user>/ovaledge/tomcatjob/bin/shutdown.sh
       User=<username_vm>
       Group=<username_vm>

       [Install]
       WantedBy=multi-user.target
       ```
   * Apply SELinux context for Tomcat directories:

     ```bash
     sudo semanage fcontext -a -t bin_t "/home/<user_name>/ovaledge/tomcatui(/.*)?"
     sudo semanage fcontext -a -t bin_t "/home/<user_name>/ovaledge/tomcatjob(/.*)?"
     sudo restorecon -Rv /home/<user_name>/ovaledge/tomcatui
     sudo restorecon -Rv /home/<user_name>/ovaledge/tomcatjob
     ```

6. **Set up Database**

   * Navigate to `extprop`:

   ```bash
   cd /home/<user>/ovaledge/extprop/
   ```

   * Update `oasis.properties` with database details:

   ```properties
   url=jdbc:mysql://<vm_host or cloud_host>:3306/ovaledgedb?useUnicode=true&character_set_server=utf8mb4&useSSL=false&allowPublicKeyRetrieval=true
   ```

   ⚠️ After executing the OvalEdge Master database, change the default user password and update it in `oasis.properties`.\
   \
   \&#xNAN;*Sample Reference Screenshot:*

   <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2F1SoBNT8eW32OuP0suWKK%2Fimage.png?alt=media&#x26;token=83eed1a7-1a7c-4625-a067-f4f235c05aa9" alt=""><figcaption></figcaption></figure>

7. **Elasticsearch Integration**
   * Edit `oasis.properties` in `extprop` to configure Elasticsearch variables (`es.password`, `es.host`, etc.).\
     \
     \&#xNAN;*Sample Reference Screenshot:*

     <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FFPlDrj5GSS7kBpOvtNO3%2Fimage.png?alt=media&#x26;token=2980885d-c95f-4c31-855e-a199e4a7e534" alt=""><figcaption></figcaption></figure>

8. **External Jars Path**

   * In `oasis.properties`, update the path to the external JARs:

   ```properties
   /home/<username>/ovaledge/third_party_jars/
   ```

   \
   \&#xNAN;*Sample Reference Screenshot:*

   <figure><img src="https://1813356899-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhTnkoJQml0pok9awFDhx%2Fuploads%2FDgUTA4jsxYaYuY4JQXfq%2Fimage.png?alt=media&#x26;token=18685d28-2806-459f-96f0-1ad79f8673c9" alt=""><figcaption></figcaption></figure>

9. **Run OvalEdge**

   * Reload systemd and enable services:

   ```bash
   sudo systemctl daemon-reload
   sudo systemctl enable tomcat1.service
   sudo systemctl enable tomcat2.service
   ```

   * Start the Tomcat services:

   ```bash
   sudo systemctl start tomcat1.service
   sudo systemctl start tomcat2.service
   ```

   * Check the status of both services:

   ```bash
   sudo systemctl status tomcat1.service
   sudo systemctl status tomcat2.service
   ```

   * Check Tomcat UI logs:

   ```bash
   tail -f /home/<user_name>/ovaledge/tomcatui/logs
   ```

   * Access the application at:

   ```
   http://<PublicIP>:8080/ovaledge/login
   ```

   * Apply the license provided by the OvalEdge CSM Team.
   * Log in with the one-time admin credentials and immediately change the default password.

***

Copyright © 2025, OvalEdge LLC, Peachtree Corners, GA, USA.
