# Tomcat on RHEL 8.x

This article provides step-by-step instructions to install and configure the OvalEdge application on RedHat 8. The setup includes creating users, installing Java, configuring multiple Tomcat instances, setting up database and Elasticsearch details, and running the OvalEdge as a service.

### Prerequisites

Before starting the installation, ensure the following:

* **User Permissions**: You must have sudo privileges.
* **Virtual Machine Requirements**:
  * vCPU: 8 Cores
  * RAM: 32 GB
  * SSD: 100 GB
* **Network Requirements**: Open the following inbound ports on the VM:
  * **Port 22 – SSH (Secure Shell):** Allows secure command-line access to the EC2 instance.
  * **Port 8080 – HTTP Alternate (Apache Tomcat):** Required to expose and access the OvalEdge application UI in the browser.
* **Database**: A MySQL database (AWS RDS or Azure Database for MySQL v8.x) must be available.
* **Elasticsearch**: Pre-installed and accessible with valid host and credentials.
* **Artifacts**: OvalEdge `.war` file, `.jar` files, and configuration files (`log4j.properties`, `oasis.properties`) must be downloaded in advance.

## Installation of OvalEdge Application

The installation includes the following steps:

1. Create OvalEdge Users
2. Install Java
3. Setup Tomcat
   * Tomcat UI Installation
   * Tomcat Job Installation
   * Configure Tomcat as a Service
4. Setup Database
5. Setup Elasticsearch
6. Configure External Jars Path
7. Run OvalEdge

### Create OvalEdge Users

```bash
sudo adduser ovaledge  
sudo passwd ovaledge  
sudo usermod -aG wheel ovaledge  
sudo su - ovaledge  
```

**Create directories** in the user home directory (or a mounted directory):

```bash
mkdir ovaledge  
mkdir -p ovaledge/extprop  
mkdir -p ovaledge/temp  
mkdir -p ovaledge/third_party_jars  
```

**Download artifacts**:

* Place all `.jars` and `.war` files in the `ovaledge` folder.
* Place `log4j.properties` and `oasis.properties` in the `ovaledge/extprop` folder.

### Java Installation

**Install Java 17**:

```bash
sudo yum update  
sudo yum install java-17-openjdk -y  
```

**Verify installation**:

```bash
java -version  
```

### Tomcat Setup

#### **Tomcat UI Installation**

```bash
wget https://archive.apache.org/dist/tomcat/tomcat-10/v10.1.40/bin/apache-tomcat-10.1.40.tar.gz  
tar xvf apache-tomcat-10.1.40.tar.gz  
mv apache-tomcat-10.1.40 tomcatui  
```

**Move the OvalEdge WAR file**:

```bash
mv /home/<user>/ovaledge/ovaledge.war /home/<user>/ovaledge/tomcatui/webapps  
```

**Create `setenv.sh` under `tomcatui/bin/`:**

```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 the UI Tomcat as Job Tomcat:

```bash
cp -R tomcatui tomcatjob  
```

**Update ports in `tomcatjob/conf/server.xml`:**

* Change 8080 → 8081<br>

  <figure><img src="https://content.gitbook.com/content/ztcvwwOJCeaE1n6oHp4C/blobs/RE9Dxxe0mzCbfqv9ym7z/image.png" alt=""><figcaption></figcaption></figure>
* Change 8005 → 8006<br>

  <figure><img src="https://content.gitbook.com/content/ztcvwwOJCeaE1n6oHp4C/blobs/RS9rWrpSS1zypsPMprqv/image.png" alt=""><figcaption></figcaption></figure>

**Create `setenv.sh` under `tomcatjob/bin/`:**

```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"
```

#### **Configure Tomcat as a Service**

**Create `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  
```

**Create `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  
```

**Run security and restore commands:**

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

#### 4. Database Configuration

Edit `/home/<user>ovaledge/extprop/oasis.properties` and update:

<figure><img src="https://content.gitbook.com/content/ztcvwwOJCeaE1n6oHp4C/blobs/oBuGDaRnOV60J5YUknxj/image.png" alt=""><figcaption></figcaption></figure>

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

{% hint style="info" %}
Replace the default OvalEdge user password after database execution.
{% endhint %}

### Elasticsearch Configuration

Navigate to `/home/<user>/ovaledge/extprop/`

Edit `oasis.properties` and configure:

* `es.password`
* `es.host`
* Other Elasticsearch variables as required.<br>

  <figure><img src="https://content.gitbook.com/content/ztcvwwOJCeaE1n6oHp4C/blobs/Agv1JXNsokR5DNqEgRvB/image.png" alt=""><figcaption></figcaption></figure>

### External Jars Path

Update `oasis.properties` with the Jars path:

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

<figure><img src="https://content.gitbook.com/content/ztcvwwOJCeaE1n6oHp4C/blobs/OCPrqvRkdzva9Stj4Q2p/image.png" alt=""><figcaption></figcaption></figure>

### Run OvalEdge

**Reload and enable Tomcat services:**

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

**Start Tomcat services:**

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

**Check status:**

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

### Access OvalEdge

* **Logs are located in:**

  ```
  /home/<user_name>/ovaledge/tomcatui/logs  
  ```
* **Access the application in a browser:**

  ```
  http://<PublicIP>:8080/ovaledge/login  
  ```
* **On the license page:**
  * Enter the license provided by the OvalEdge CSM team.
  * Use the one-time admin credentials displayed.
  * Log in and update the default password.

***

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