# Database

## Custom credentials for Databases

By default, credentials for the back-end and database components are using the default ones set by the HollaEx Kit.&#x20;

This setup is okay for demonstrative, small production exchanges in a closed environment. But if you are looking for better security, setting up the custom credentials for back-end is important.

\> Updating the values below may break the exchange if you already have set up the existing one. Modifying credentials is only allowed before running the `hollaex setup`.

### Redis

You can set your credentials from your `secret` file in your HollaEx Kit/settings.&#x20;

```
HOLLAEX_SECRET_REDIS_HOST=$ENVIRONMENT_EXCHANGE_NAME-redis
HOLLAEX_SECRET_REDIS_PORT=6379
HOLLAEX_SECRET_REDIS_PASSWORD=hollaex
HOLLAEX_SECRET_PUBSUB_HOST=$ENVIRONMENT_EXCHANGE_NAME-redis
HOLLAEX_SECRET_PUBSUB_PORT=6379
HOLLAEX_SECRET_PUBSUB_PASSWORD=hollaex
```

While on the exchange setup, HollaEx CLI will create a Redis container based on the provided values above.&#x20;

### PostgreSQL

You can set your credentials from your `secret` file in your HollaEx Kit/settings.&#x20;

```
HOLLAEX_SECRET_DB_NAME=hollaex
HOLLAEX_SECRET_DB_USERNAME=hollaex
HOLLAEX_SECRET_DB_PASSWORD=hollaex
HOLLAEX_SECRET_DB_HOST=$ENVIRONMENT_EXCHANGE_NAME-db
HOLLAEX_SECRET_DB_PORT=5432
```

While on the exchange setup, HollaEx CLI will create a PostgreSQL container based on the provided values above.&#x20;

### InfluxDB

You can set your credentials from your `secret` file in your HollaEx Kit/settings.&#x20;

```
HOLLAEX_SECRET_INFLUX_DB=hollaex
HOLLAEX_SECRET_INFLUX_HOST=$ENVIRONMENT_EXCHANGE_NAME-influxdb
HOLLAEX_SECRET_INFLUX_PORT=8086
HOLLAEX_SECRET_INFLUX_USER=hollaex
HOLLAEX_SECRET_INFLUX_PASSWORD=hollaex
```

While on the exchange setup, HollaEx CLI will create an InfluxDB container based on the provided values above.&#x20;

## External Databases

By default, HollaEx CLI runs all necessary backend servers (Redis, PostgreSQL, InfluxDB) automatically along with the rest of the HollaEx workloads.

It is enough for small or medium size exchange but if you are considering scaling up and have a larger load, you can run HollaEx with an external custom backend system of yours as you wish.

### [Redis](https://docs.hollaex.com/dependencies#redis)

{% hint style="info" %}
You should set up the external Redis which is reachable from your HollaEx server.&#x20;
{% endhint %}

To disable HollaEx CLI to create built-in Redis, please set the value below as `false`. You could find this value in your `configmap` file in your HollaEx Kit/settings.

```
ENVIRONMENT_DOCKER_COMPOSE_RUN_REDIS=false
```

You can set the endpoint, port, and password for your Redis connection at your `secret` file in your HollaEx Kit/settings.

```
HOLLAEX_SECRET_REDIS_HOST=$ENVIRONMENT_EXCHANGE_NAME-redis
HOLLAEX_SECRET_REDIS_PORT=6379
HOLLAEX_SECRET_REDIS_PASSWORD=hollaex

HOLLAEX_SECRET_PUBSUB_HOST=$ENVIRONMENT_EXCHANGE_NAME-redis
HOLLAEX_SECRET_PUBSUB_PORT=6379
HOLLAEX_SECRET_PUBSUB_PASSWORD=hollaex
```

Please run `hollaex restart` to apply once you are all set.

#### Separated Redis for Pub-Sub (Optional)

If you are looking for a more advanced load balancing, it is also possible to separate the pub-sub feature of Redis (for internal communication of HollaEx servers) to a separate one.

{% hint style="info" %}
You should set up the additional Redis for pub-sub which is reachable from your HollaEx server.
{% endhint %}

By default, the HollaEx server uses the same Redis host for handling all pub-sub and the rest of caching related jobs.

You can set the endpoint, port, and password for your pub-sub Redis connection at your secret file in your HollaEx Kit/settings.

```
HOLLAEX_SECRET_PUBSUB_HOST=$ENVIRONMENT_EXCHANGE_NAME-redis
HOLLAEX_SECRET_PUBSUB_PORT=6379
HOLLAEX_SECRET_PUBSUB_PASSWORD=hollaex
```

Please run `hollaex restart` to apply once you are all set.

### [PostgreSQL](https://docs.hollaex.com/dependencies#postgresql)

{% hint style="info" %}
You should set up the external PostgreSQL Database which is reachable from your HollaEx server.
{% endhint %}

{% hint style="info" %}
Please refer [Backup and Restore](https://docs.hollaex.com/get-started/cli-how-tos/get-a-backup-and-restore) section to migrate your existing data into the new DB.
{% endhint %}

To disable HollaEx CLI to create build-in PostgreSQL, please set the value below as `false`. You could find this value at your `configmap` file in your HollaEx Kit/settings.

```
ENVIRONMENT_KUBERNETES_RUN_POSTGRESQL_DB=false
```

You can set the endpoint, port, and credentials for your PostgreSQL connection at your 'secret' file in your HollaEx Kit/settings.

```
HOLLAEX_SECRET_DB_NAME=hollaex
HOLLAEX_SECRET_DB_USERNAME=hollaex
HOLLAEX_SECRET_DB_PASSWORD=hollaex
HOLLAEX_SECRET_DB_HOST=$ENVIRONMENT_EXCHANGE_NAME-db
HOLLAEX_SECRET_DB_PORT=5432
```

Please run `hollaex restart` to apply once you are all set.

### [InfluxDB](https://docs.hollaex.com/dependencies#influxdb)

{% hint style="info" %}
You should set up the external InfluxDB Database which is reachable from your HollaEx server.
{% endhint %}

{% hint style="info" %}
Run `hollaex toolbox --influxdb_migration` (available from the CLI v1.9) to migrate chart data into the new InfluxDB. The chart data are stored at your PostgreSQL.
{% endhint %}

To disable HollaEx CLI to create build-in InfluxDB, please set the value below as `false`. You could find this value in your `configmap` file in your HollaEx Kit/settings.

```
ENVIRONMENT_KUBERNETES_RUN_INFLUXDB=false
```

You can set the endpoint, port, and credentials for your InfluxDB connection at your 'secret' file in your HollaEx Kit/settings.

```
HOLLAEX_SECRET_INFLUX_DB=hollaex
HOLLAEX_SECRET_INFLUX_HOST=$ENVIRONMENT_EXCHANGE_NAME-influxdb
HOLLAEX_SECRET_INFLUX_PORT=8086
HOLLAEX_SECRET_INFLUX_USER=hollaex
HOLLAEX_SECRET_INFLUX_PASSWORD=hollaex
```

Please run `hollaex restart` to apply once you are all set.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hollaex.com/advanced/database.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
