---
title: "Environment variables and ports"
description: "CoraDB environment variables (CORADB, CORADB_DATABASES, ...), PATH and JAVA_HOME settings, locales, and the TCP ports CoraDB uses."
url: "https://www.coradb.ai/manual/env.html"
markdown_url: "https://www.coradb.ai/manual/markdown/env.md"
product: "CoraDB"
version: "1.0"
keywords: "coradb environment variables, CORADB, CORADB_DATABASES, CORADB_MSG_LANG, CORADB_TMP, .coradb.sh, coradb ports, coradb firewall, coradb locale"
---

# Environment variables and ports

CoraDB programs find their installation, databases and message language through environment variables. The installer sets them; this page explains them, how to check or change them, and which network ports CoraDB uses.

## CoraDB environment variables

- **CORADB**: The directory where CoraDB is installed. This variable must be set accurately since all programs included in the CoraDB system uses this environment variable as reference.
- **CORADB_DATABASES**: The environment variable that designates the location of the **databases.txt** file. The CoraDB system stores the absolute path of database volumes in the **\$CORADB_DATABASES/databases.txt** file. See [databases.txt file](https://www.coradb.ai/manual/admin/db_manage.html#databasestxt-file).
- **CORADB_MSG_LANG**: The environment variable that specifies usage messages and error messages in CoraDB. The initial value upon start is not defined. If it is not defined, it follows the configured locale when [createdb](https://www.coradb.ai/manual/admin/admin_utils.html#createdb). For more information, see [Language & charset setting](https://www.coradb.ai/manual/env.html#language--charset-setting).

> **Note:**
> After changing **CORADB_MSG_LANG**, restart CoraDB (`coradb service stop`, `coradb service start`) so that the servers use the new language.


- **CORADB_TMP**: The environment variable that specifies the location where the cora_master process and the cora_broker process store the UNIX domain socket file in CoraDB for Linux. If it is not specified, the cora_master process stores the UNIX domain socket file under the **/tmp** directory and the cora_broker process stores the UNIX domain socket file under the **\$CORADB/var/CORADB_SOCK** directory (not used in CoraDB for Windows).

**CORADB_TMP** value has some constraints, which are as follows:

- Since the maximum length of the UNIX socket path is 108, when a path longer than 108 is entered in **\$CORADB_TMP**, an error is displayed.

  ``` bash
  $ export CORADB_TMP=/home1/testusr/coradb=/tmp/123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
  $ coradb server start apricot

  The $CORADB_TMP is too long. (/home1/testusr/coradb=/tmp/123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789)
  ```

- When the relative path is entered, an error is displayed.

  ``` bash
  $ export CORADB_TMP=./var 
  $ coradb server start testdb

  The $CORADB_TMP should be an absolute path. (./var)
  ```

**CORADB_TMP** can be used to avoid the following problems that can occur at the default path of the UNIX domain socket that CoraDB uses.

- **/tmp** is used to store the temporary files in Linux. If the system administrator periodically and voluntarily cleans the space, the UNIX domain socket may be removed. In this case, configure **\$CORADB_TMP** to another path, not **/tmp**.
- The maximum length of the UNIX socket path is 108. When the installation path of CoraDB is too long and the **\$CORADB/var/CORADB_SOCK** path that store the UNIX socket path for cora_broker exceeds 108 characters, the broker cannot be executed. Therefore, the path of **\$CORADB_TMP** must not exceed 108 characters.

The above mentioned environment variables are set when the CoraDB is installed. However, the following commands can be used to verify the setting.

- Linux

  ``` bash
  % printenv CORADB
  % printenv CORADB_DATABASES
  % printenv CORADB_MSG_LANG
  % printenv CORADB_TMP
  ```

- Windows

  ``` text
  C:\> set CORADB
  ```

## OS environment and Java environment variables

- PATH: In the Linux environment, the directory **\$CORADB/bin**, which includes a CoraDB system executable file, must be included in the PATH environment variable.
- LD_LIBRARY_PATH: In the Linux environment, **\$CORADB/lib**, the directory of the CoraDB shared libraries, must be included in the **LD_LIBRARY_PATH** (or **SHLIB_PATH** or **LIBPATH**) environment variable.
- Path: In the Windows environment, the **%CORADB%\bin**, which is a directory that contains CoraDB system's execution file, must be included in the **Path** environment variable.
- JAVA_HOME: To use the Java stored procedure in the CoraDB system, a Java Virtual Machine (JVM) must be installed, and the **JAVA_HOME** environment variable must designate the concerned directory. See the [Configuring for CoraDB Java SP server](https://www.coradb.ai/manual/admin/control_javasp.html#configuring-for-coradb-java-sp-server).
- JVM_PATH: To use the Java stored procedure in the CoraDB system, the **JVM_PATH** environment variable can specify the JVM library (libjvm) path explicitly instead of finding the library from **JAVA_HOME**. See the [Configuring for CoraDB Java SP server](https://www.coradb.ai/manual/admin/control_javasp.html#configuring-for-coradb-java-sp-server).

## Configuring the environment variable

**For Windows**

If the CoraDB system has been installed on Windows, then the installation program automatically sets the necessary environment variable. Select \[Systems Properties\] in \[My Computer\] and select the \[Advanced\] tab. Click the \[Environment Variable\] button and check the setting in the \[System Variable\]. The settings can be changed by clicking on the \[Edit\] button. See the Windows help for more information on how to change the environment variable on Windows.

**For Linux**

If the CoraDB system has been installed on Linux, the installation program automatically creates the **.coradb.sh** or **.coradb.csh** file and makes configurations so that the files are automatically called from the installation account's shell log-in script. The following is the contents of . **coradb.sh** environment variable configuration that was created in an environment that uses sh, bash, etc.

```bash
CORADB=/home/coradb/CoraDB
CORADB_DATABASES=$CORADB/databases
if [ "x${LD_LIBRARY_PATH}x" = xx ]; then
  LD_LIBRARY_PATH=$CORADB/lib
else
  LD_LIBRARY_PATH=$CORADB/lib:$LD_LIBRARY_PATH
fi
SHLIB_PATH=$LD_LIBRARY_PATH
LIBPATH=$LD_LIBRARY_PATH
PATH=$CORADB/bin:$PATH
export CORADB
export CORADB_DATABASES
export LD_LIBRARY_PATH
export SHLIB_PATH
export LIBPATH
export PATH
```

## Language & charset setting

The language and charset of a database are given after the database name when it is created, for example `coradb createdb testdb en_US.utf8`. The following locales are available:

- **en_US.iso88591**: English ISO-88591 encoding(.iso88591 can be omitted)
- **ko_KR.euckr**: Korean EUC-KR encoding
- **ko_KR.utf8**: Korean UTF-8 encoding(.utf8 can be omitted)
- **de_DE.utf8**: German UTF-8 encoding
- **es_ES.utf8**: Spanish UTF-8 encoding
- **fr_FR.utf8**: French UTF-8 encoding
- **it_IT.utf8**: Italian UTF-8 encoding
- **ja_JP.utf8**: Japanese UTF-8 encoding
- **km_KH.utf8**: Cambodian UTF-8 encoding
- **tr_TR.utf8**: Turkish UTF-8 encoding(.utf8 can be omitted)
- **vi_VN.utf8**: Vietnamese UTF-8 encoding
- **zh_CN.utf8**: Chinese UTF-8 encoding
- **ro_RO.utf8**: Romanian UTF-8 encoding

The charset determines how strings are stored; the language determines the default collation and the formats of dates and numbers. Locales other than en_US must be compiled before use; see [Locale setting](https://www.coradb.ai/manual/sql/i18n_locale.html).

For more details related to charset, locale and collation settings, see [An overview of globalization](https://www.coradb.ai/manual/sql/i18n.html).


## Port setting

When a firewall separates applications, brokers and database servers, open the ports CoraDB uses. The listener of each connection must accept connections on its port.

On Linux, open the ports listed below with your firewall tool. On Windows, some ports are chosen at random, so it is safer to allow the CoraDB programs in Windows Defender Firewall (Control Panel > Windows Defender Firewall > Allow an app through Windows Firewall) than to open ports:

- `%CORADB%\bin\cora_broker.exe` for the broker
- `%CORADB%\bin\cora_cas.exe` for the CAS processes
- `%CORADB%\bin\cora_master.exe` for the master process
- `%CORADB%\bin\cora_server.exe` for the database server
- `%CORADB%\bin\cora_cmserver.exe` for the CoraDB Manager Server (CMS)
- `%CORADB%\bin\cora_javasp.exe` for the Java SP server


## Default ports for CoraDB

| Listener | Requester | Linux port | Windows port | Firewall | Connection |
|---|---|---|---|---|---|
| cora_broker | Application | BROKER_PORT | BROKER_PORT | Open | Once, At connect |
| CAS | Application | BROKER_PORT | APPL_SERVER_PORT … APPL_SERVER_PORT + number of CAS − 1 | Open | Kept |
| cora_master | CAS, corasql | coradb_port_id | coradb_port_id | Open | Once, At connect |
| cora_server | CAS, corasql | coradb_port_id | A random free port | Linux: open; Windows: allow the program | Kept |
| Client machine (CAS, corasql) | cora_server | ECHO (7) | ECHO (7) | Open | Periodic |
| Server machine (cora_server) | CAS, corasql | ECHO (7) | ECHO (7) | Open | Periodic |
| CMS | Management clients | cm_port (8001) | cm_port (8001) | Open | Kept |
| cora_javasp | cora_server (through CAS) | java_stored_procedure_port | java_stored_procedure_port | Open | Kept |

- `BROKER_PORT` and `APPL_SERVER_PORT` are set per broker in `coradb_broker.conf` (see [Broker configuration](https://www.coradb.ai/manual/admin/config_broker.html)); `coradb_port_id` and `java_stored_procedure_port` in `coradb.conf` (see [System parameters](https://www.coradb.ai/manual/admin/config.html)); `cm_port` in `cm.conf`, the configuration of CMS. The default `java_stored_procedure_port` is 0: a random free port.
- The server and its clients check each other's liveness through the ECHO (7) port. If it cannot be opened on both sides, set [check_peer_alive](https://www.coradb.ai/manual/admin/config_resources.html#check_peer_alive) to `none`.

### How a connection is made

```text
application - cora_broker
            -> CAS  -  cora_master
                    -> cora_server
```

`-` marks a connection made once, `->` one that is kept open, pointing to the listener.

1. The application connects to the broker on `BROKER_PORT`.
2. The broker chooses a free CAS and hands the connection over. On Linux this happens through a Unix domain socket, so the application keeps using `BROKER_PORT`. On Windows, the application connects to the CAS on port `APPL_SERVER_PORT` + CAS number − 1; without `APPL_SERVER_PORT`, the first CAS uses `BROKER_PORT` + 1. With `BROKER_PORT` 33000, CAS 1, 2 and 3 use ports 33001, 33002 and 33003.
3. The CAS asks the master process, on `coradb_port_id`, for a connection to the database server.
4. The CAS connects to the server: on Linux through a Unix domain socket handed over by the master, so only `coradb_port_id` is needed; on Windows through a random free port, so a firewall between broker and server must allow `cora_server.exe`.
5. The CAS keeps its server connection after the application disconnects, until the CAS restarts.


### Java SP server port

When a stored function written in Java is called, the CAS passes the call between the database server and the Java SP server (`cora_javasp`), which listens on `java_stored_procedure_port`.
