> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/self-managed-enterprise-edition/use-self-managed-enterprise-edition/advanced-configuration/external-db/redis/use-an-external-redis-database.md).

# Use an external self-managed Redis database with your installation

Harness Self-Managed Enterprise Edition requires you to install a database by default. You can optionally use an external database with your installation. This enables you to separate your data from node execution. To use an external self-managed Redis database with your Harness Self-Managed Enterprise Edition installation, you must ensure that your hardware, software, and network meet the minimum requirements for installation and configuration.

Redis offers an enterprise on-premise solution to deploy an HA solutions that functions like a single server. You can install Redis on your preferred choice of virtual machines and provide the endpoint in your Harness Helm charts. Harness recommends this solution to install Redis in HA mode.

This tutorial describes how to configure an external self-managed Redis database for your installation.

### Hardware requirements <a href="#hardware-requirements" id="hardware-requirements"></a>

Harness recommends a Redis configuration with the following minimum hardware:

* 3 VMs
* 8 cores per machine
* 8GB memory per machine
* 64GB disk per machine (SSD preferred)
* 1GB/s minimum network bandwidth

### Software requirements <a href="#software-requirements" id="software-requirements"></a>

External database setup requires the following software:

* Supported OS: Ubuntu 20.04 LTS

### Prerequisites <a href="#prerequisites" id="prerequisites"></a>

The following prerequisites are needed:

* A Redis Labs account. To sign up, go to the [Redis Cloud Console](https://app.redislabs.com/#/).
* Redis Enterprise. To download Redis for Ubuntu 20.04, go to [Redis enterprise](https://redis.io/downloads/#redis-stack-downloads).
* A public or internal domain name, for example `harness-redis-abc.com`.

### Set up firewall rules <a href="#set-up-firewall-rules" id="set-up-firewall-rules"></a>

External Redis requires firewall rule setup to add ports to your allowlist.

{% hint style="warning" %}
Example settings used in this tutorial are for instructional purposes only. Replace the examples with your organization's IP requirements. Harness recommends following your organization's standards for firewall rule settings.
{% endhint %}

To create a firewall rule, do the following:

1. Select the network you want to use for your Redis nodes, for example Default.
2. Go to the **Firewall** tab, and create a new rule using the below configurations.

   | Protocol | Port        | Description                                    |
   | -------- | ----------- | ---------------------------------------------- |
   | ICMP     | \*          | Redis gossip protocol                          |
   | UDP      | 53, 5353    | Redis DNS                                      |
   | TCP      | 10000-20000 | Redis connectivity                             |
   | TCP      | 8443        | Secure (HTTPS) access to the web management UI |
3. For testing purposes, set the source IP ranges to your public IP.

### Install Redis <a href="#install-redis" id="install-redis"></a>

After you configure your firewall rules, you must install Redis. To install Redis, you must create three VMs, create DNS records, configure your Redis cluster, configure your Redis database, and test your connectivity.

#### Create your VMs <a href="#create-your-vms" id="create-your-vms"></a>

{% hint style="warning" %}
Example passwords used in this tutorial are for instructional purposes only. Replace the examples with your own secure passwords. Harness recommends following your organization's standards for password security, including the use of strong passwords. Strong passwords are:

* At least 12 characters long. Longer passwords are more secure.
* Any combination of uppercase letters, lowercase letters, numbers, and symbols.
* Not a word in the dictionary of any language or the name of a person, place, character, or organization.
* Unique for each account.
  {% endhint %}

To create your VMs, do the following:

1. Select the machine type based on the hardware requirements above.
2. Change the boot disk to Ubuntu 20.04 LTS.
3. Reserve internal and external static IP addresses for the VM.
4. SSH into the VM.
5. Run the following commands.

   ```shell
   wget <redis-download-url>
   ```

   ```shell
   tar xf <redis-file-name>
   ```
6. Disable port 53. For more information, go to [Ensure port availability](https://docs.redis.com/latest/rs/installing-upgrading/install/prepare-install/port-availability/#port-53) in the Redis documentation.

   Output:

   ```shell
   sudo: unable to resolve host <hostname>: Temporary failure in name resolution
   ```
7. Run the following command.

   ```shell
   sudo ./install.sh -y
   ```
8. Check the installation logs for errors.
9. Repeat the steps to configure your other two VMs.

#### Create DNS records <a href="#create-dns-records" id="create-dns-records"></a>

To create DNS records, do the following:

1. Go to the DNS portal of your domain registrar.
2. Create three type A records with subdomains for the public domain name, for example, `node1.harness-redis-abc.com`, `node2.harness-redis-abc.com`, and `node3.harness-redis-abc.com`.
3. Add the internal IP and external IP for each VM in their respective A records.
4. Create one NS record with a different subdomain, for example `redis.harness-redis.com`.
5. Add the subdomains of all your nodes, for example `node1.harness-redis.com`, `node2.harness-redis.com`, and `node3.harness-redis.com`.

#### Configure your Redis cluster <a href="#configure-your-redis-cluster" id="configure-your-redis-cluster"></a>

To configure your Redis cluster, do the following:

1. Open `https://<EXTERNAL_IP_OF_NODE1>:8443` in your browser, and then complete the following on the node setup page.

   1. Enable Flash Storage.
   2. Select **+** next to the IP, add the external IP, and then select **Save**.
   3. Disable external traffic on the internal IP.
   4. Add the DNS record subdomain in the **FQDN** field used in the NS record, for example, `redis.harness-redis.com`.
   5. Create your admin credentials.
   6. Select **Create Cluster**.
   7. Select **Next**.

   <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>You can skip the cluster key for now if the page opens. (You can procure a license key from Redis Labs later, if required.)</p></div>
2. Open `https://<EXTERNAL_IP_OF_NODE2>:8443` in your browser, and then complete the following on the node setup page.
   1. Enable Flash Storage.
   2. Select **+** next to the IP, add the external IP, and then select **Save**.
   3. Disable external traffic on the internal IP.
   4. Select **Join cluster**.
   5. Add the internal IP of your first node.
   6. Enter your admin credentials.
   7. Select **Create**.
3. Open `https://<EXTERNAL_IP_OF_NODE3>:8443` in your browser, and then complete the following on the node setup page.
   1. Enable Flash Storage.
   2. Select **+** next to the IP, add the external IP, and then select **Save**.
   3. Disable external traffic on the internal IP.
   4. Select **Join cluster**.
   5. Add the internal IP of your first node.
   6. Enter your admin credentials.
   7. Select **Create**.

#### Configure your Redis database <a href="#configure-your-redis-database" id="configure-your-redis-database"></a>

To configure your Redis database, do the following:

1. Open `https://<YOUR_NODE1_EXTERNAL_IP>:8443` in your browser.
2. Select the **Databases** tab.
3. Select **Single region Redis database**.
4. Select runs on RAM.
5. Enable replication.
6. Set the database memory to 2GB.
7. Enter the database password.
8. Select **Create**.
9. Copy the **Internal Endpoint** for later use.

#### Test connectivity <a href="#test-connectivity" id="test-connectivity"></a>

You can test your connectivity using the Redis CLI.

To test your connectivity using, do the following:

1. Run the following command.

   ```shell
   redis-cli -h <YOUR_INTERNAL_ENDPOINT> -p <port>
   ```
2. Run the following.

   ```shell
   ping
   ```

The expected response is `pong`.

3. Run the following.

   ```shell
   set foo bar
   ```
4. Run the following.

   ```shell
   get foo
   ```

   The expected response is `bar`.

### Configure your Harness environment and Helm chart <a href="#configure-your-harness-environment-and-helm-chart" id="configure-your-harness-environment-and-helm-chart"></a>

After you've tested your connectivity, you're ready to configure your Harness environment.

To configure your Harness environment and Helm chart, do the following:

* Create a secret in the namespace where harness is installed with following data

  ```yaml
  data:
    root-password: <REDIS_PASSWORD>
    root-username: ""
  ```
* Add the following override entries to your newly-installed Harness Redis instance.

  ```yaml
  global:
    database:
      redis:
        installed: false
        hosts:
        - <YOUR_INTERNAL_ENDPOINT_AND_PORT>
        secretName: "REDIS_SECRET"
        userKey: "ROOT_USERNAME"
        passwordKey: "ROOT_PASSWORD"
  ```
